opencv 读取摄像头并保存视屏,可是视屏无法播放
openCV编写的代码:读取摄像头并保存视屏,可是保存的视屏使用暴风影音无法播放。也转换不了格式。为什么??#include"stdafx.h"#include"cv.h...
openCV编写的代码:读取摄像头并保存视屏,可是保存的视屏使用暴风影音无法播放。也转换不了格式。为什么??
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
#include "conio.h"
int main( ) {
CvCapture *capture = cvCaptureFromCAM( CV_CAP_ANY );
IplImage *image = NULL; //*dst = NULL;
image = cvQueryFrame( capture );
CvSize size = cvGetSize( image );
//dst = cvCreateImage( size, image->depth, 1 );
double fps = 10;
CvVideoWriter* writer = cvCreateVideoWriter( "Video from CAMERA.avi", CV_FOURCC('X','V','I','D'), fps, size, 1 );
cvNamedWindow( "haha", 1);
while( (image = cvQueryFrame( capture )) != NULL )
{
printf("Enteredn");
//cvCvtColor( image, dst, CV_RGB2GRAY );
cvShowImage("haha", image);
cvWriteFrame( writer, image );
if( (cvWaitKey(100)) == 27 )
break;
}
cvReleaseVideoWriter( &writer );
cvReleaseCapture( &capture );
//cvReleaseImage( &dst );
cvDestroyWindow( "haha" ); 展开
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
#include "conio.h"
int main( ) {
CvCapture *capture = cvCaptureFromCAM( CV_CAP_ANY );
IplImage *image = NULL; //*dst = NULL;
image = cvQueryFrame( capture );
CvSize size = cvGetSize( image );
//dst = cvCreateImage( size, image->depth, 1 );
double fps = 10;
CvVideoWriter* writer = cvCreateVideoWriter( "Video from CAMERA.avi", CV_FOURCC('X','V','I','D'), fps, size, 1 );
cvNamedWindow( "haha", 1);
while( (image = cvQueryFrame( capture )) != NULL )
{
printf("Enteredn");
//cvCvtColor( image, dst, CV_RGB2GRAY );
cvShowImage("haha", image);
cvWriteFrame( writer, image );
if( (cvWaitKey(100)) == 27 )
break;
}
cvReleaseVideoWriter( &writer );
cvReleaseCapture( &capture );
//cvReleaseImage( &dst );
cvDestroyWindow( "haha" ); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询