`
#include <opencv2/opencv.hpp>
#include <iostream>
int main() {
std::string videoPath = R"(C:UsersDELLlightfieldRendererrestexturesmychocopie2.mp4)";
try {
cv::VideoCapture cap(videoPath);
if (!cap.isOpened()) {
std::cerr << "Error: Unable to open video file: " << videoPath << std::endl;
return -1;
}
} catch (const cv::Exception& e) {
std::cerr << "Exception occurred: " << e.what() << std::endl;
return -1;
}
std::cout << "Video file opened successfully." << std::endl;
return 0;
}
`
This is my code, and if I run this,
[ERROR:[email protected]] global cap.cpp:175 cv::VideoCapture::open VIDEOIO(MSMF): raised C++ exception:
bad array new length
[ERROR:[email protected]] global cap.cpp:166 cv::VideoCapture::open VIDEOIO(CV_IMAGES): raised OpenCV exception:
OpenCV(4.8.0) C:DEVvcpkgbuildtreesopencv4src4.8.0-c8729c356c.cleanmodulesvideoiosrccap_images.cpp:235: error: (-5:Bad argument) CAP_IMAGES: error, expected ‘0?[1-9][du]’ pattern, got: (?7. in function ‘cv::icvExtractPattern’
[ERROR:[email protected]] global cap.cpp:175 cv::VideoCapture::open VIDEOIO(CV_MJPEG): raised C++ exception:
string too long
Error: Unable to open video file: C:UsersDELLlightfieldRendererrestexturesmychocopie2.mp4
How can I solve this?
I’m using opencv 4.8.0 and it installed by vcpkg.
I used ‘cap.open(videopath)’ too but it doesn’t work.
It occurs same error.