C OPENCV图像在Boost线程中不显示
c++ opencv image not display inside the boost thread
im开发c++
应用程序我使用了boost
,opencv
。并创建Boost线程并调用该线程中的功能。该函数具有OpenCV Imread(我使用cvloadimage检查了检查,但我得到的结果相同),但是PROGRAME无法完成并进行预先出口。
请在我使用的代码下面找到
boost::thread *thread_reconstruct;
int main( int argc, const char** argv )
{
thread_reconstruct = new boost::thread( &FuncCreate );
return 0;
}
void FuncCreate()
{
while (true)
{
compute_left_descriptors(g_nameRootFolder.c_str());
}
}
void compute_left_descriptors(const char* name_dir)
{
char namebuf[1024];
sprintf(namebuf, "%s/Left/%04d_left.bmp", name_dir, 1);
// Program ended with exit code: 0 programe exit from here.
Mat input_left = imread(namebuf, CV_LOAD_IMAGE_COLOR);
imshow("Right View", input_left);
waitKey(0);
printf("donen");
}
请尝试此版本的代码,并告诉我们它是否有效
boost::thread *thread_reconstruct;
int main( int argc, const char** argv )
{
cv::namedWindow("Right View"); // this will create a window. Sometimes new windows can't be created in another thread, so we do it here in the main function.
thread_reconstruct = new boost::thread( &FuncCreate );
thread_reconstruct->join(); // this will make your program wait here until the thread has finished processing. Otherwise your program would exit directly.
return 0;
}
void FuncCreate()
{
while (true)
{
compute_left_descriptors(g_nameRootFolder.c_str());
}
}
void compute_left_descriptors(const char* name_dir)
{
char namebuf[1024];
sprintf(namebuf, "%s/Left/%04d_left.bmp", name_dir, 1);
// Program ended with exit code: 0 programe exit from here.
Mat input_left = imread(namebuf, CV_LOAD_IMAGE_COLOR);
if(input_left.empty()) printf("could not load imagen");
imshow("Right View", input_left);
waitKey(0); // if you dont want to press a key before each new image, you can change this to waitKey(30);
printf("donen");
}
相关文章:
- 从不同线程使用int64的不同字节安全吗
- 主函数跳过线程并且不加入以显示所需的输出
- Apache 崩溃并显示错误 R6016 没有足够的空间来存储线程数据
- 如何在对话框编辑框中显示来自 UI 线程类 Run() 函数的字符串
- 在状态栏上显示来自不同线程中回调的消息
- C OPENCV图像在Boost线程中不显示
- 任务管理器显示的线程比我创建的线程多
- 显示Q对话框时出现QT线程问题
- 对于多线程应用程序中的显示任务,原子锁或互斥锁是必须的吗
- 线程和进程的示例来显示差异
- 尝试显示线程优先级时出现分段错误
- cv::imshow 在不同的线程上不显示 cv::mat 颜色
- 线程不刷新数据,在屏幕中显示数据时出错
- 为什么Visual Studio显示多个线程,即使我的MFC应用不是多线程的?
- 当在线程命名后附加调试器时,本地c++线程名称不会显示在visual studio线程窗口中
- 我如何在另一个线程Qt显示MessageBox
- 多线程:如何在wxthread中使显示图像的GUI线程和处理图像同步的工作线程无阻塞
- 来自回溯的堆栈跟踪未显示导致多线程环境下崩溃的方法
- 提升线程示例显示错误,它无法匹配调用"boost::线程::线程(<未解析的重载函数类型>)"的函数
- 如何从视频播放器的辅助线程在主窗口中显示