Learning OpenCV: cvSmooth processing

来源:互联网 发布:mac 进程管理器 编辑:程序博客网 时间:2024/05/22 07:53
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
#include "cv.h"
#include "highgui.h"


int g_slider_position = 0;
CvCapture * g_capture = NULL;


void onTrackbarSlide(int pos)
{
cvSetCaptureProperty(g_capture,CV_CAP_PROP_POS_FRAMES,pos);
}


int main(void)
{
cvNamedWindow("video",CV_WINDOW_AUTOSIZE);
g_capture = cvCreateFileCapture("E:\\test\\fish1.avi");
int frames = (int)cvGetCaptureProperty(g_capture,CV_CAP_PROP_FRAME_COUNT);
if(frames != 0)
{
cvCreateTrackbar("position","video",&g_slider_position,frames,onTrackbarSlide);
}
IplImage * frame = NULL;
frame = cvQueryFrame(g_capture);
if(g_capture == NULL)
{
cout<<"read video file error!"<<endl;
}
IplImage * outFrame = NULL;
outFrame = cvCreateImage(cvGetSize(frame),IPL_DEPTH_8U,frame->nChannels);
cvNamedWindow("outvideo",CV_WINDOW_AUTOSIZE);
while(1)
{
frame = cvQueryFrame(g_capture);
if(frame == NULL)
{
break;
}
cvShowImage("video",frame);
cvSmooth(frame,outFrame,CV_GAUSSIAN,3);
cvShowImage("outvideo",outFrame);
char c = cvWaitKey(33);
if(c == 27)
{
break;
}
}
cvReleaseCapture(&g_capture);
g_capture = NULL;
cvDestroyWindow("video");
cvDestroyWindow("outvideo");
cvReleaseImage(&outFrame);
outFrame = NULL;
return 0;
}

0 0