gpt4 book ai didi

c - 在 OpenCV 中读取 AVI 文件时出现未知错误

转载 作者:行者123 更新时间:2023-11-30 18:08:31 25 4
gpt4 key购买 nike

每当我尝试读取 avi 文件并在 Windows XP 中使用 Opencv 2.1 和 VS 2008 转换为灰度时

我不明白为什么我会同时收到以下运行时错误,但我无法获得有关它的帮助

错误 1

[NULL @ 0x37da10]Invalid and inefficient vfw-avi packed B frames detected fps=23 frame (w, h) = (640, 272) Output #0, avi, to 'test.avi': Stream #0.0: Video: mpeg4, yuv420p, 640x272, q=2-31, 11141 kb/s, 90k tbn, 23 .98 tbc [mpeg4 @ 0x37f920]removing common factors from framerate [mpeg4 @ 0x37da10]Invalid and inefficient vfw-avi packed B frames detected Compiler did not align stack variables. Libavcodec has been miscompiled and may be very slow or crash. This is not a bug in libavcodec, but in the compiler. You may try recompiling using gcc >= 4.2. Do not report crashes to FFmpeg developers. [mpeg4 @ 0x37da10]Invalid and inefficient vfw-avi packed B frames detected

如果我尝试其他 avi 文件,则会出现以下运行时错误

错误2

fps=15 frame (w, h) = (176, 184) Output #0, avi, to 'demo.avi': Stream #0.0: Video: mpeg4, yuv420p, 176x184, q=2-31, 2072 kb/s, 90k tbn, 15 tbc Compiler did not align stack variables. Libavcodec has been miscompiled and may be very slow or crash. This is not a bug in libavcodec, but in the compiler. You may try recompiling using gcc >= 4.2. Do not report crashes to FFmpeg developers.

我真的不知道这是怎么回事,这是我学习 OpenCV 的代码,

// VideoCon.cpp : Defines the entry point for the console application.


#include "stdafx.h"


#include <cv.h>
#include <highgui.h>
#include <stdio.h>



int main( int argc, char* argv[] ) {
cvNamedWindow( "Example2_10", CV_WINDOW_AUTOSIZE );
cvNamedWindow( "Log_Polar", CV_WINDOW_AUTOSIZE );
CvCapture* capture = cvCreateFileCapture( "Rambo.avi" );
if (!capture){
return -1;
}
IplImage* bgr_frame;
double fps = cvGetCaptureProperty (
capture,
CV_CAP_PROP_FPS
);
printf("fps=%d\n",(int)fps);

CvSize size = cvSize(
(int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH),
(int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT)
);

printf("frame (w, h) = (%d, %d)\n",size.width,size.height);
#ifndef NOWRITE
CvVideoWriter* writer = cvCreateVideoWriter(
// On linux Will only work if you've installed ffmpeg development files correctly,
"test.avi",
// otherwise segmentation fault. Windows probably better.
CV_FOURCC('D','X','5','0'),
fps,
size
);
#endif
IplImage* logpolar_frame = cvCreateImage(
size,
IPL_DEPTH_8U,
3
);

IplImage* gray_frame = cvCreateImage(
size,
IPL_DEPTH_8U,
1
);

while( (bgr_frame=cvQueryFrame(capture)) != NULL ) {
cvShowImage( "Example2_10", bgr_frame );
cvConvertImage( //We never make use of this gray image
bgr_frame,
gray_frame,
CV_RGB2GRAY
);
cvLogPolar( bgr_frame, logpolar_frame,
//This is just a fun conversion the mimic's the human visual system
cvPoint2D32f(bgr_frame->width/2,
bgr_frame->height/2),
40,
CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS );
cvShowImage( "Log_Polar", logpolar_frame );
//Sigh, on linux, depending on your ffmpeg, this often won't work ...
#ifndef NOWRITE
cvWriteToAVI( writer, logpolar_frame );
#endif
char c = cvWaitKey(10);
if( c == 27 ) break;
}
#ifndef NOWRITE
cvReleaseVideoWriter( &writer );
#endif
cvReleaseImage( &gray_frame );
cvReleaseImage( &logpolar_frame );
cvReleaseCapture( &capture );
}

最佳答案

我的猜测是您的计算机上没有安装正确的编解码器。尝试安装一些合适的编解码器。

关于c - 在 OpenCV 中读取 AVI 文件时出现未知错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3334808/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com