I have a strange problem with opencv running on an Ubuntu. I installed OpenCV from the apt sources. And most of the Examples work fine.
我在Ubuntu上运行opencv时遇到了一个奇怪的问题。我从apt源安装了OpenCV。大多数示例都运行良好。
But in my programs, which are working with Mac OS, no windows are created.
但在我的Mac OS程序中,没有创建窗口。
The following code is showing a window and an image in this on my Mac but not on my Ubuntu powered machine
以下代码在我的Mac上显示了一个窗口和一个图像,但在我的Ubuntu驱动的机器上没有
import time
from opencv import highgui
if __name__ == '__main__':
highgui.cvNamedWindow('Image', highgui.CV_WINDOW_AUTOSIZE)
highgui.cvMoveWindow('Image', 10, 40)
image = highgui.cvLoadImage("verena.jpg", 1)
highgui.cvShowImage('Image', image)
time.sleep(3)
The code is taken from one of the examples that is actually working on both machines.
代码取自实际在两台机器上工作的一个示例。
2 个解决方案
#1
The code works if I add a highgui.cvStartWindowThread() call before creating the window.
如果我在创建窗口之前添加highgui.cvStartWindowThread()调用,则代码可以正常工作。
Now the next question would be why the program works on mac os without starting the windowThread.
现在接下来的问题是为什么程序在没有启动windowThread的情况下在mac os上工作。
#2
For the new binding, I mean cv2
. The code is cv2.startWindowThread()
对于新绑定,我的意思是cv2。代码是cv2.startWindowThread()
#1
The code works if I add a highgui.cvStartWindowThread() call before creating the window.
如果我在创建窗口之前添加highgui.cvStartWindowThread()调用,则代码可以正常工作。
Now the next question would be why the program works on mac os without starting the windowThread.
现在接下来的问题是为什么程序在没有启动windowThread的情况下在mac os上工作。
#2
For the new binding, I mean cv2
. The code is cv2.startWindowThread()
对于新绑定,我的意思是cv2。代码是cv2.startWindowThread()