gpt4 book ai didi

c - OpenCV : How to use cvWaitKey() form a different thread other than the one created the window?

转载 作者:行者123 更新时间:2023-11-30 16:03:43 24 4
gpt4 key购买 nike

我遇到了一个问题,需要你的帮助。我一直在尝试使用 cvWaitKey() 函数从创建的窗口捕获键盘敲击。如果我从创建窗口的同一线程调用 cvWaitKey,该函数工作正常,但是当我从一个线程创建窗口并从另一个线程调用 cvWaitKey() 时,它不会返回正确的 key ,它会阻塞 cvWaitKey(0)对于任何大于零的超时,返回 -1。

最佳答案

是的,这行不通。 cvWaitKey()是通过调用PeekMessage() API函数实现的。它只能看到与该线程关联的消息队列上的消息。您创建的线程没有任何窗口。

对此没有明显的解决方法,您必须在创建窗口的线程上调用它。调用 GetAsyncKeyState() 可能会起作用,但这是一种非常不同的方法。

关于c - OpenCV : How to use cvWaitKey() form a different thread other than the one created the window?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3802796/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com