#include<iostream>
#include<opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main()
{
VideoCapture capture;
Mat frame;
const string source = "/home/gear/big_disk_c/wangjd/shipintest/789.mp4";
// frame= capture.open("789.mp4");
frame= capture.open(source);
if(!capture.isOpened())
{
printf("can not open ...\n");
return -1;
}
printf("1213131\n");
// namedWindow("output", CV_WINDOW_AUTOSIZE);
while (capture.read(frame))
{
imshow("output", frame);
waitKey(10);
}
capture.release();
return 0;
}
Reason: Path. I have a permission problem with this server, and it will report an error if I write the full path. And the executable file I generated and the video file are not in the same directory, …/789.mp4 will not be read, only the two put together to read. Later I found out that
The constructor of capture.open() passed in a const string, so I instantiated a const string source first, then I could write the full path, and then passed it in.
const string source = "/home/gear/big_disk_c/wangjd/shipintest/789.mp4";
frame= capture.open(source);