i am trying to read video using opencv2.4.13. The code is written in cpp. The "Segmentation fault (core dump) error occurred at the video_capture= cv::VideoCapture(video_fname);. Please advise. Thanks

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 Answers