简体   繁体   English

编写并显示图像OpenCV

[英]Writing & showing Image OpenCV

I am recording a video footage and preforming various image processing methods on each frame to obtain desired result. 我正在录制视频录像,并在每帧上执行各种图像处理方法以获得所需的结果。

Now once I get the result I am looking for i want to capture and store a particular frame on my hdd. 现在,一旦获得结果,我正在寻找要捕获的特定帧并将其存储在我的硬盘上。

To do this I am using imwrite function to write the frame as a jpg. 为此,我使用imwrite函数将框架写为jpg。 then I use imshow to display this frame in a namesWindow. 然后我使用imshow在namesWindow中显示此框架。

The problem is that when all the conditions are meet to store the image my program instead of storing the image, gives me a run time error....... 问题是,当满足所有条件来存储图像而不是存储图像时,程序会出现运行时错误。

Here is the code: 这是代码:

for(vector<double>::iterator iter_dis = Left_Point_distance.begin(); iter_dis != Left_Point_distance.end();++iter_dis)
    {


        if(*iter_dis > 20 && center.y >= 120 && center.x >=510 && Box[0].width > Box[0].height)
        {

            char* window_Punches = "Punches";
            namedWindow(window_Punches ,1);

            Mat Hook;

            imwrite("C:\\Hook.jpg", Hook);
            imshow(window_Punches, Hook);


        }


        if(*iter_dis >20 && center.y <=60)
        {

        }

    }

Going through opencv tutorials This is how this how its done but in my case is not working...... 查看opencv教程这是如何完成的,但是在我看来,这是行不通的……

Further more all the process takes place in a infinite while loop, and videoframes are stored in Mat frame; 此外,所有过程都在无限的while循环中进行,视频帧存储在Mat帧中; which is then displayed in a window using imshow function. 然后使用imshow功能将其显示在窗口中。

Can anybody spot what am doing wrong here....? 有人可以在这里发现问题所在吗?

您定义了Mat Hook,但是在尝试使用imwrite()编写时为空

What do you expect from this code: 您对以下代码有什么期望:

  Mat Hook;

  imwrite("C:\\Hook.jpg", Hook);
  imshow(window_Punches, Hook);

You create an empty matrix and use it. 您创建一个空矩阵并使用它。

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

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