[英]Segmentation Fault with opencv on reading a video from a file
i am running a simple code to capture a video from a file but its return a segmentation fault 我正在运行一个简单的代码来从文件中捕获视频,但它返回分段错误
#include "opencv2/highgui/highgui.hpp"
#include<opencv2/opencv.hpp>
#include <stdio.h>
//#include <iostream>
using namespace cv;
using namespace std;
int main()
{
CvCapture* capture = cvCreateFileCapture("/home/ayush/20130521053652.avi");
IplImage* frame = NULL;
if(!capture)
{
printf("Video Not Opened\n");
return -1;
}
int width = (int)cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH);
int height = (int)cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT);
double fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
int frame_count = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT);
printf("Video Size = %d x %d\n",width,height);
printf("FPS = %f\nTotal Frames = %d\n",fps,frame_count);
while(1)
{
frame = cvQueryFrame(capture);
if(!frame)
{
printf("Capture Finished\n");
break;
}
cvShowImage("video",frame);
cvWaitKey(10);
}
cvReleaseCapture(&capture);
return 0;
}
i am also tried this above code which is actually a solution for a particular question but its still giving me a same thing... 我也在上面的代码中尝试过这实际上是一个特定问题的解决方案,但它仍然给我同样的事情...
Video file information 视频文件信息
$file 20130521053652.avi
20130521053652.avi: RIFF (little-endian) data, AVI, 640 x 480, 30.00 fps, video:
some more information 一些更多的信息
Dimensions: 640 x 480
Codec: 24-bit RGB
Framerate: 30 frames per second
Bitrate: N/A
i think there must be issue with codec my platform is linux/ubuntu 12.04 LTS please can any body suggest me solution for this 我认为编解码器一定存在问题,我的平台是linux / ubuntu 12.04 LTS,请问有谁可以为我提供解决方案
Through gdb debugger the Segmentation fault is giving at frame = cvQueryFrame(capture)
通过gdb调试器,细分错误在
frame = cvQueryFrame(capture)
o/p is something this o / p是这个
(gdb)
66 frame = cvQueryFrame(capture);
(gdb)
Program received signal SIGSEGV, Segmentation fault.
__memcpy_ssse3 () at ../sysdeps/i386/i686/multiarch/memcpy-ssse3.S:160
160 ../sysdeps/i386/i686/multiarch/memcpy-ssse3.S: No such file or directory.
through Qt IDE ==> Debugging 通过Qt IDE ==>调试
0xb751d9fa <+0x146a> movzbl (%eax),%eax
1951 in ../sysdeps/i386/i686/multiarch/memcpy-ssse3.S
0xb751d9fd <+0x146d> mov %al,(%edx)
1952 in ../sysdeps/i386/i686/multiarch/memcpy-ssse3.S
1953 in ../sysdeps/i386/i686/multiarch/memcpy-ssse3.S
0xb751d9ff <+0x146f> mov 0x8(%esp),%eax
1954 in ../sysdeps/i386/i686/multiarch/memcpy-ssse3.S
1955 in ../sysdeps/i386/i686/multiarch/memcpy-ssse3.S
1956 in ../sysdeps/i386/i686/multiarch/memcpy-ssse3.S
1957 in ../sysdeps/i386/i686/multiarch/memcpy-ssse3.S
1958 in ../sysdeps/i386/i686/multiarch/memcpy-ssse3.S
1959 in ../sysdeps/i386/i686/multiarch/memcpy-ssse3.S
0xb751da03 <+0x1473> pop %ebx
0xb751da04 <+0x1474
I had the same issue in OpenCV 2.4, using cvCaptureFromFile()/cvQueryFrame(). 我在OpenCV 2.4中使用cvCaptureFromFile()/ cvQueryFrame()遇到了相同的问题。 Converting my AVI to an FLV (using avconv) worked for me.
将我的AVI转换为FLV(使用avconv)为我工作。
My guess is that this is an OpenCV bug. 我的猜测是这是一个OpenCV错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.