简体   繁体   English

如何抓住一个OpenCV框架而不显示它或不创建cvNamedWindow?

[英]how to grab a OpenCV frame without showing it or without creating cvNamedWindow?

I do not understand why OpenCV doesn't work when we do not need to create OpenCV window using cvNamedWindow. 我不明白为什么当我们不需要使用cvNamedWindow创建OpenCV窗口时,OpenCV不起作用。 Actually, I do not want to use OpenCV GUI window, I want to use third party GUI in order to display grabbed frame, So for this, i do not need to create OpenCV window. 实际上,我不想使用OpenCV GUI窗口,我想使用第三方GUI来显示抓取的框架,因此,我不需要创建OpenCV窗口。 But When I do not create OpenCV window, my application gets stuck, nothing works, and when I do create OpenCV window using cvNamedWindow, everything works fine. 但是,当我不创建OpenCV窗口时,我的应用程序被卡住,没有任何效果,当我使用cvNamedWindow创建OpenCV窗口时,一切正常。

Any suggestion, whats the reason? 有什么建议,原因是什么? how can I grab OpenCV frame without creating its GUI window? 如何在不创建GUI窗口的情况下抓取OpenCV框架?

I am using OpenCV 2.4.3 (cvQueryFrame), VS2010 c++, WindowsXP 我正在使用OpenCV 2.4.3(cvQueryFrame),VS2010 c ++,WindowsXP

Thanks. 谢谢。

you probably need to skip the waitKey() call, too ;) 您可能也需要跳过waitKey()调用;)

(also, do yourself a favour, and skip the c-api. it's a real PITA and will go away soon) (此外,请帮自己一个忙,跳过c-api。这是真正的PITA,很快就会消失)

That's because you are grabbing images at a faster rate than what the camera can ouput. 这是因为您以比相机无法输出的速度更快的速度捕获图像。 You need to add a little delay to your while cycle. 您需要在while周期中增加一些延迟。 If your camera does 25FPS, you should add ~1/25 of a second or so. 如果您的相机的速度为25FPS,则应加上〜1/25秒左右。

Solved: The problem was this, actually, I was creating a third party GUI window inside of the pthread which was causing its infinite updating. 解决:问题是,实际上,我在pthread内创建了一个第三方GUI窗口,这导致了它的无限更新。 When I created window outside of the pthread, it works fine. 当我在pthread之外创建窗口时,它可以正常工作。

procedure is this: 程序是这样的:

void Init()
{
   createGUIwin(w, h);
   init_pthread();
}

void init_pthread(void*)
{
   //createGUIwin(w, h); // before I was creating GUIwin here
   while(ON)
   {
      frame = getOCVframe();
      UpdateGUIwin(frame);
      key = cvWaitKey(10);
   }
}

Thanks everyone. 感谢大家。 I appreciate your answers. 感谢您的回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM