vs中用opencv写入视频,看看哪里不对?
#include<highgui.h>#include<cv.h>intmain(intargc,char*argv[]){CvCapture*capture=cvCre...
#include <highgui.h>
#include <cv.h>
int main(int argc,char * argv[])
{
CvCapture * capture = cvCreateFileCapture("C:\\Users\\wsm\\Desktop\\aaa.avi");
//capture =cvCreateFileCapture(argv[1]);
cvNamedWindow("example",CV_WINDOW_AUTOSIZE);
if(!capture)
{
return -1;
}
IplImage * bgr_frame = cvQueryFrame(capture);
double fps = cvGetCaptureProperty(capture,CV_CAP_PROP_FPS);
CvSize size = cvSize((int)cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH),(int)cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT));
CvVideoWriter * writer = cvCreateVideoWriter("out-avi",CV_FOURCC('M','J','P','G'),fps,size);
IplImage * logpolar_frame = cvCreateImage(size,IPL_DEPTH_8U,3);
while((bgr_frame=cvQueryFrame(capture))!= NULL)
{
//以图像中心位原点,缩放比例40,双线性插值,空白部分填充黑色。
cvLogPolar(bgr_frame,logpolar_frame,cvPoint2D32f(bgr_frame->width/2,bgr_frame->height/2),40,CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS);
cvWriteFrame(writer,logpolar_frame);
cvShowImage("example",logpolar_frame);
char c = cvWaitKey(33);
if(c==27) break;
}
cvWaitKey(0);
cvReleaseVideoWriter(&writer);
cvReleaseImage(&logpolar_frame);
cvReleaseCapture(&capture);
cvDestroyAllWindows();
return 0;
}
为什么出来结果是这样子的,郁闷,求大神指导…… 展开
#include <cv.h>
int main(int argc,char * argv[])
{
CvCapture * capture = cvCreateFileCapture("C:\\Users\\wsm\\Desktop\\aaa.avi");
//capture =cvCreateFileCapture(argv[1]);
cvNamedWindow("example",CV_WINDOW_AUTOSIZE);
if(!capture)
{
return -1;
}
IplImage * bgr_frame = cvQueryFrame(capture);
double fps = cvGetCaptureProperty(capture,CV_CAP_PROP_FPS);
CvSize size = cvSize((int)cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH),(int)cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT));
CvVideoWriter * writer = cvCreateVideoWriter("out-avi",CV_FOURCC('M','J','P','G'),fps,size);
IplImage * logpolar_frame = cvCreateImage(size,IPL_DEPTH_8U,3);
while((bgr_frame=cvQueryFrame(capture))!= NULL)
{
//以图像中心位原点,缩放比例40,双线性插值,空白部分填充黑色。
cvLogPolar(bgr_frame,logpolar_frame,cvPoint2D32f(bgr_frame->width/2,bgr_frame->height/2),40,CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS);
cvWriteFrame(writer,logpolar_frame);
cvShowImage("example",logpolar_frame);
char c = cvWaitKey(33);
if(c==27) break;
}
cvWaitKey(0);
cvReleaseVideoWriter(&writer);
cvReleaseImage(&logpolar_frame);
cvReleaseCapture(&capture);
cvDestroyAllWindows();
return 0;
}
为什么出来结果是这样子的,郁闷,求大神指导…… 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
展开全部
结果不就应该是这样么?
更多追问追答
追问
结果应该是正常的人形视频啊,上面那个变形了啊,我是按书上的写的,为什么会这样?是哪一步不对吗?
cvLogPolar(bgr_frame,logpolar_frame,cvPoint2D32f(bgr_frame->width/2,bgr_frame->height/2),40,CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS);
是不是这步有问题
追答
cvLogPolar是把当前的图像坐标转换到极坐标形式下,做出来的图就是这个样子的。
你可以参考下面这篇博文http://blog.csdn.net/hitwengqi/article/details/6895215
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询