【发布时间】:2015-02-24 11:22:41
【问题描述】:
嘿,我在 Windows 上有一个简单的线程:
while (!MainThreadHasFinished) {
cv::Mat frame = (cv::Mat)lpParameter; //Casting try.
cv::imshow("Camera image", (frame)); //Show Img in window
printf("img printed"); //print text to cmd
if (cv::waitKey(1) == 27) // exit this loop when ESC was pressed
break;
}
return 0;
}
问题在于我无法做到cv::imshow,这似乎不是对 cv::Mat 的强制转换 :)
我将线程创建为:
DWORD thread_ID;
HANDLE handle_NumberCruncher = CreateThread(
NULL, // default security attributes
0, // use default stack size
NumberCruncher, // thread function name
&frame, // argument to thread function
0, // use default creation flags
&thread_ID); // returns the thread identifier
我在 MSDN 和 Stack 上看到过多个关于投射的参考,但没有关于图像的内容。
如果这是不可能的,那么一般的问题是如何在线程之间解析数据。想法是可以在主线程中对图像进行一些处理,然后将其解析为不是每个图像都需要的一些更高级的东西。不使用全局变量。因为线程可能在不同的处理器上,就像一个例子:)
【问题讨论】:
-
线程没有锁 - 唷。
标签: c++ windows multithreading opencv visual-studio-2013