OpenCV 视频编辑?

发布于 2024-12-04 13:33:40 字数 1090 浏览 0 评论 0原文

我正在使用 OpenCV 并尝试将高斯模糊应用于传入的视频流。我基本上使用 cvQueryFrame 来删除框架,模糊它并将框架显示到屏幕上。但问题是,我的视频在应用模糊后卡在第一帧......有人知道为什么吗?它基本上显示一帧而不是视频。当我删除模糊时,它再次开始输出视频。

#include "cv.h"
#include "highgui.h"
#include "cvaux.h"

#include <iostream>
using namespace std;

int main()
{

//declare initial data
IplImage *grabCapture= 0; //used for inital video frame capture
IplImage *process =0; //used for processing
IplImage *output=0; //displays final output

CvCapture* vidStream= cvCaptureFromCAM(0);

cvNamedWindow ("Output", CV_WINDOW_AUTOSIZE);

int createimage=1;

while (1)
{

grabCapture= cvQueryFrame (vidStream);

if (createimage==1)
    {
        process= cvCreateImage (cvGetSize(grabCapture), IPL_DEPTH_16U, 3);

        createimage=0;

    }

*process=*grabCapture;
cvSmooth (process,process,CV_GAUSSIAN,7,7); //line that makes it display frame instead of video


cvShowImage("Output",process);

}


//clean up data
cvReleaseImage (&grabCapture);
cvReleaseImage (&process);
cvReleaseImage (&output);
cvReleaseCapture (&vidStream);


return 0;

}

I am using OpenCV and trying to apply a Gaussian Blur to an incoming video stream. I basically use cvQueryFrame to remove a frame, blur it and display the frame onto the screen. The thing is though, my video gets stuck on the first frame after I apply the blur....anyone know why? its basically showing one frame instead of a video. The second I remove the blur it starts outputting video again.

#include "cv.h"
#include "highgui.h"
#include "cvaux.h"

#include <iostream>
using namespace std;

int main()
{

//declare initial data
IplImage *grabCapture= 0; //used for inital video frame capture
IplImage *process =0; //used for processing
IplImage *output=0; //displays final output

CvCapture* vidStream= cvCaptureFromCAM(0);

cvNamedWindow ("Output", CV_WINDOW_AUTOSIZE);

int createimage=1;

while (1)
{

grabCapture= cvQueryFrame (vidStream);

if (createimage==1)
    {
        process= cvCreateImage (cvGetSize(grabCapture), IPL_DEPTH_16U, 3);

        createimage=0;

    }

*process=*grabCapture;
cvSmooth (process,process,CV_GAUSSIAN,7,7); //line that makes it display frame instead of video


cvShowImage("Output",process);

}


//clean up data
cvReleaseImage (&grabCapture);
cvReleaseImage (&process);
cvReleaseImage (&output);
cvReleaseCapture (&vidStream);


return 0;

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟花肆意 2024-12-11 13:33:40

您错过了对 cvWaitKey 的调用。这是告诉 OpenCV 处理事件并防止 GUI 冻结的唯一方法。

尝试添加此行:

cvWaitKey(10);

cvShowImage("Output",process); 之后。

编辑:这里是 cvWaitKey 的文档

You are missing a call to cvWaitKey. This is the only way to tell OpenCV to process events and thus prevent the GUI from freezing.

Try adding this line:

cvWaitKey(10);

after cvShowImage("Output",process);.

Edit: here is the documentation for cvWaitKey

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文