Yesterday I downloaded VCPKG and then downloaded some libraries for a pretty simple project. After searched for OpenCV, I downloaded it and everything was working fine. But then, when I downloaded the contrib extra library, for the dnn_superres module, it stopped working. I thought it was a string problem because I was giving it paths and absolute paths, but nothing changed, and I still got the error that I describe here.
I thought it was a video problem, maybe it was corrupted (even if I could still see it with Windows Media Player), so I downloaded a random video and tried with that, still not worked.
After that I added a fix I found on the internet, that is to add CAP_DSHOW or any other plugin for conversion. Something changed, but I wasn't still able to open the file, found out because of a (!video.isOpened) statement.
Maybe I'm doing something wrong, I'm still new to the IDE and to vcpkg, I tried to build it myself, but it didn't work...
Steps to reproduce
#include <iostream>
#include <string>
#include <boost/filesystem.hpp>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/dnn_superres.hpp>
using namespace std;
using namespace cv;
using namespace dnn_superres;
using namespace boost::filesystem;
int main()
{
string filename;
cout << "Drag the file here: ";
getline(cin, filename);
VideoCapture video(filename, CAP_DSHOW);
if (!video.isOpened())
{
cout << "Error reading the video" << endl;
return -1;
}
double fps = video.get(CAP_PROP_FPS), frames = video.get(CAP_PROP_FRAME_COUNT), duration = (frames / fps) / 60;
cout << "Source FPS: " << fps << endl;
cout << "Total frames in the video: " << frames << endl;
cout << "Video length in minutes: around " << round(duration) << " minutes" << endl;
DnnSuperResImpl sr;
sr.readModel("C:/Users/sergi/OneDrive/Desktop/Progetti/C++/AnimeEnhancer/ESPCN_x3.pb");
sr.setModel("espcn", 3);
create_directory("temp"); current_path("temp");
for (int i=0; i<frames; i++)
{
Mat frame, upframe;
if (!video.read(frame))
{
cout << "Error reading the frame" << endl;
return -1;
}
sr.upsample(frame, upframe);
upframe = frame;
if (!upframe.empty())
{
cout << "Error upscaling the frame" << endl;
return -1;
}
imwrite(to_string(i) + ".jpg", upframe);
cout << "Elaborated frame " << i << " of " << frames << endl;
}
video.release();
return 0;
}
The first error was the following:
[ WARN:0] global C:\Users\sergi\vcpkg-master\buildtrees\opencv4\src\4.3.0-8460981b10.clean\modules\videoio\src\cap_msmf.cpp (681) CvCapture_MSMF::initStream Failed to set mediaType (stream 0, (0x0 @ 1) MFVideoFormat_RGB32(unsupported media type)
Source FPS: 1
Total frames in the video: 5.01886e+09
Video length in minutes: around 8.36477e+07 minutes
OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.3.0) Error: Unspecified error (FAILED: fs.is_open(). Can't open "ESPCN_ x3.pb") in cv::dnn::ReadProtoFromBinaryFile, file C:\Users\sergi\vcpkg-master\buildtrees\opencv4\src\4.3.0-8460981b10.clean\modules\dnn\src\caffe\caffe_io.cpp, line 1132
C:\Users\sergi\OneDrive\Desktop\Progetti\C++\AnimeEnhancer\Release\AnimeEnhancer.exe (processo 2052) terminato. Codice restituito: -1073740791.
Premere un tasto qualsiasi per chiudere questa finestra...
System information (version)
Detailed description
Yesterday I downloaded VCPKG and then downloaded some libraries for a pretty simple project. After searched for OpenCV, I downloaded it and everything was working fine. But then, when I downloaded the contrib extra library, for the dnn_superres module, it stopped working. I thought it was a string problem because I was giving it paths and absolute paths, but nothing changed, and I still got the error that I describe here. I thought it was a video problem, maybe it was corrupted (even if I could still see it with Windows Media Player), so I downloaded a random video and tried with that, still not worked.
After that I added a fix I found on the internet, that is to add CAP_DSHOW or any other plugin for conversion. Something changed, but I wasn't still able to open the file, found out because of a (!video.isOpened) statement. Maybe I'm doing something wrong, I'm still new to the IDE and to vcpkg, I tried to build it myself, but it didn't work...
Steps to reproduce
The first error was the following:
My build information:
Issue submission checklist