I am migrating from VS2013 to VS2017 and from OpenCV 2.4 to 3.4.
C++ MFC.
I have run the CMake on OpenCV 3.4.14 to compile with VS2017.
I have built the resulting OpenCV solution in VS2017.
I have modified the old VS2013/OpenCV project with all of the new OpenCV library and include directories and Linker Input Additional Dependencies.
I have copied all necessary OpenCV dll files to the proper places.
I have #included the new OpenCV 3.4 modules such as <opencv2/imgcodecs.hpp
I have #included the “C” files in the module sub-directories such as opencv2/videoio/videoio_c.h>
I have checked and double checked that everything is as it should be based on what it was previously but with the new references to VS2017, OpenCV 3.4.14, and to the Windows10 SDK
It compiles without problem. However when I run the code that always worked in the previous version I can’t get past getting a CvCapture for the opening .avi video in either Debug or Release mode
In the code sample below:
FILENAME is a char
capture is a CvCapture
The video file OpeningVideo.avi is in the the main directory, the \Debug, and the \Release directories. (just in case) and it is a valid video.
When I run the code below the “catch” never hits but the capture returns NULL.
try {
// No error to catch just that capture is NULL
capture = cvCreateFileCapture((const char*)FILENAME);
}catch (...) {
std::string strMessage = GetLastErrorAsString();
// Convert string to CString / Convert std::string to CString
CString csMessage(strMessage.c_str());
AfxMessageBox( csMessage, MB_ICONERROR);
}
I have hard coded the video file name in every configuration possible such as capture = cvCreateFileCapture("OpeningVideo.avi");
and all the way up to the full path.
As a test I did the C++ version with the code
cv::Mat frameCPP;
cv::VideoCapture captureCPP;
captureCPP.open((const char*)FILENAME);
bool bOpen = captureCPP.isOpened(); // returns true
captureCPP.read(frameCPP); // captureCPP remains NULL
Anyone have any clues? Like I said this was all running fine for a long time with VS2013 and OpenCV 2.4.7 but something that I can’t figure out has changed.
Thanks in advance.
Ed