Issue 1:
System information (version)

OpenCV1.zip

Hello,

I make an example program with opencv on my main computer (windows 10 x64) with opencv4.4.0, visual c++ 2019 and it work fine on the main computer. I have compiled sources files as explain on the opencv site.

When i try to run it on a windows 7 x64 computer after importing all the dll (core440, videoio, ....) , i got the error :

...opencv-4.4.0\modules\videoio\src\cap_msmf.cpp (682) CvCapture_MSMF::initStream Failed to set mediaType (stream 0, (640x480 @ 30) MFVideoFormat_RGB24(unsupported media type)

I am serarching all other the web for few hours now but found nothing helping me... Does someone here have a solution ?

Thanks !

#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <string>
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>
#include <stdio.h>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
double Fiducial_Diameter = 0.5;
Mat src;

if (argc < 3) {
cerr << "ERROR! Argument missing\n";
return -1;
}
string num = argv[1];
string diam = argv[2];

VideoCapture cap;
int deviceID = stoi(num);	// 0 = open default camera
int apiID = cv::CAP_ANY;	// 0 = autodetect default API

// open selected camera using selected API
cap.open(deviceID, apiID);
// check if we succeeded
if (!cap.isOpened()) {
cerr << "ERROR! Unable to open camera\n";
return -1;
}
//--- GRAB AND WRITE LOOP
cout << "Start grabbing" << endl
<< "Press any key to terminate" << endl;
for (;;)
{
// wait for a new frame from camera and store it into 'frame'
cap.read(src);
// check if we succeeded
if (src.empty()) {
cerr << "ERROR! blank frame grabbed\n";
break;
}
// show live and wait for a key with timeout long enough to show images
// Get center of the image
Point CenterOfImage = Point(src.size().width / 2, src.size().height / 2);
circle(src, CenterOfImage, stoi(diam), Scalar(0, 255, 000), 1, LINE_AA);

imshow("Live", src);
if (waitKey(5) >= 0)
break;
}
return EXIT_SUCCESS;
}

Issue 2:
Win 7, CMake 3.18.1, VS 2015 community, opencv 422f802 with Qt 5.15 and eigen.

Reading a frame from VideoCapture thrown exception:

[ INFO:0] global C:\Lib\opencv\source\opencv\modules\videoio\src\videoio_registr
y.cpp (191) cv::`anonymous-namespace'::VideoBackendRegistry::VideoBackendRegistr
y VIDEOIO: Enabled backends(7, sorted by priority): FFMPEG(1000); GSTREAMER(990)
; INTEL_MFX(980); MSMF(970); DSHOW(960); CV_IMAGES(950); CV_MJPEG(940)
[ INFO:0] global C:\Lib\opencv\source\opencv\modules\videoio\src\backend_plugin.
cpp (370) cv::impl::getPluginCandidates Found 2 plugin(s) for GSTREAMER
[ INFO:0] global C:\Lib\opencv\source\opencv\modules\videoio\src\backend_plugin.
cpp (175) cv::impl::DynamicLib::libraryLoad load c:\Lib\opencv\build_x64\bin\ope
ncv_videoio_gstreamer440_64d.dll => FAILED
[ INFO:0] global C:\Lib\opencv\source\opencv\modules\videoio\src\backend_plugin.
cpp (175) cv::impl::DynamicLib::libraryLoad load opencv_videoio_gstreamer440_64d
.dll => FAILED
[ WARN:0] global C:\Lib\opencv\source\opencv\modules\videoio\src\cap_msmf.cpp (6
77) CvCapture_MSMF::initStream Failed to set mediaType (stream 0, (640x480 @ 30)
MFVideoFormat_RGB24(codec not found)

Cap backend: MSMF

Test code:

#include <opencv2/imgcodecs.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2//highgui.hpp>
#include <fstream>
#include <iostream>

using namespace std;
using namespace cv;

int main(int argc, char** argv)
{
VideoCapture cap;
Mat frame;
bool bIsOpen = cap.open(0);
cout << "\nCap backend: " << cap.getBackendName() << endl;
if (!bIsOpen) {
cout << "Can't open camera!" << endl;
return -1;
}
while (waitKey() != 27) {
try {
cap >> frame; // <- exception here
}
catch (Exception &e) {
cout << e.err;
}
if (frame.empty()) {
cout << "Empty frame captured!" << endl;
return -1;
}
imshow("cap", frame);
}

return 0;
}

In debug it is seen that error occurs here:

opencv/modules/core/src/copy.cpp

Line 298
in
dbab8d8

CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippiCopy_8u_C1R_L, sptr, (int)src.step, dptr, (int)dst.step, ippiSizeL(sz.width, sz.height)) >= 0)

Reproduced on several different PC with different cameras.

Last known OpenCV ver. where this code work is 4.12.