I modified matrix_wrap.cpp to print some of these variables: std::printf("mtype: %d, type0: %d, cv_mat_mtype: %d, cv_mat_type0: %d, \n", mtype, type0, CV_MAT_CN(mtype), CV_MAT_CN(type0));
Mostly the variables read: mtype: 12, type0: 12, cv_mat_mtype: 2, cv_mat_type0: 2,
but finally (where the assert happens), I get: mtype: 13, type0: 4, cv_mat_mtype: 2, cv_mat_type0: 1,
not sure what these variables mean or why they are different in this specific case.
Updates:
I thought something might be wrong with the marker file I was using. So I added this function:
Thank you Sir. I had updated the line to: cvtColor(img, imgCopy, cv::COLOR_BGR2GRAY);
Even after this change, i get the same error.
It is a simple Aruco marker file for marker 10. As you can see from my earlier update, I dont think the file is the issue because even when I generate the marker and directly pass to the detector, i still get the same exception
and initializing the img variable as follows: cv::Mat imgCopy, img = generateMarker(10);
Till yesterday I was using Opencv 4.10. I tried with 4.8 and got same result. Today I tried with 4.5.3 and it worked perfectly fine though the code is a bit different.
Looks like I interchanged the variables while calling detectMarker. It should have been detector.detectMarkers(imgCopy, markerCorners, markerIds); in my program.