#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
#include "cv.h"
#include "highgui.h"
#include <assert.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;
}
double fps = cvGetCaptureProperty(g_capture,CV_CAP_PROP_FPS);
int m_width = frame->width;
int m_height = frame->height;
CvSize m_size = cvSize(m_width,m_height);
CvVideoWriter * writer =NULL;
//writer = cvCreateVideoWriter("E:\\test.mp4",CV_FOURCC('M','J','P','G'),fps,m_size,1);
writer = cvCreateVideoWriter("E:\\test.avi",-1,fps,m_size,1);
if(writer == NULL)
{
cout<<"create video writer error!"<<endl;
return -1;
}
IplImage * logpolar_frame = cvCreateImage(m_size,IPL_DEPTH_8U,3);
cvNamedWindow("writer",1);
while((frame=cvQueryFrame(g_capture))!=NULL)
{
cvLogPolar(frame,logpolar_frame,cvPoint2D32f(frame->width/2,frame->height/2),40.0,CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS);
if(frame == NULL)
{
break;
}
cvWriteFrame(writer,logpolar_frame);
cvShowImage("video",frame);
cvShowImage("writer",logpolar_frame);
char c = cvWaitKey(33);
if(c == 27)
{
break;
}
}
cvReleaseCapture(&g_capture);
g_capture = NULL;
cvDestroyWindow("video");
cvReleaseVideoWriter(&writer);
writer = NULL;
cvReleaseImage(&logpolar_frame);
logpolar_frame = NULL;
cvDestroyWindow("writer");
return 0;
}
#include <iostream>
#include <fstream>
using namespace std;
#include "cv.h"
#include "highgui.h"
#include <assert.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;
}
double fps = cvGetCaptureProperty(g_capture,CV_CAP_PROP_FPS);
int m_width = frame->width;
int m_height = frame->height;
CvSize m_size = cvSize(m_width,m_height);
CvVideoWriter * writer =NULL;
//writer = cvCreateVideoWriter("E:\\test.mp4",CV_FOURCC('M','J','P','G'),fps,m_size,1);
writer = cvCreateVideoWriter("E:\\test.avi",-1,fps,m_size,1);
if(writer == NULL)
{
cout<<"create video writer error!"<<endl;
return -1;
}
IplImage * logpolar_frame = cvCreateImage(m_size,IPL_DEPTH_8U,3);
cvNamedWindow("writer",1);
while((frame=cvQueryFrame(g_capture))!=NULL)
{
cvLogPolar(frame,logpolar_frame,cvPoint2D32f(frame->width/2,frame->height/2),40.0,CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS);
if(frame == NULL)
{
break;
}
cvWriteFrame(writer,logpolar_frame);
cvShowImage("video",frame);
cvShowImage("writer",logpolar_frame);
char c = cvWaitKey(33);
if(c == 27)
{
break;
}
}
cvReleaseCapture(&g_capture);
g_capture = NULL;
cvDestroyWindow("video");
cvReleaseVideoWriter(&writer);
writer = NULL;
cvReleaseImage(&logpolar_frame);
logpolar_frame = NULL;
cvDestroyWindow("writer");
return 0;
}