尝试使用opencv读取视频时出现分段错误

时间:2019-04-29 08:37:03

标签: c++ opencv segmentation-fault coredump

我正在尝试使用opencv2.4.13读取视频。该代码用cpp编写。 “ video_capture= cv::VideoCapture(video_fname);发生了分段错误(核心转储)错误。请告知。谢谢

int main(int argc, char *argv[])
{
    if(argc != 2) {
        printf("must provide one command argument with the video file or stream to open\n");
        return 1;
    }
    std::string video_fname;
    video_fname = std::string(argv[1]);
    cv::VideoCapture video_capture;
    bool from_camera = false;
    if(video_fname == "0") {
       video_capture = cv::VideoCapture(0);
       from_camera = true;
    } else {
       std::cout<<"i am here"<<std::endl;

       video_capture=  cv::VideoCapture(video_fname);
    }


    if(!video_capture.isOpened()) {

       fprintf(stderr, "could not open video %s\n", video_fname.c_str());
       video_capture.release();
       return 1;
    }
}

....
return 0;
}

0 个答案:

没有答案