-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
cv::aruco::refineDetectedMarkers change detectedCorners[i] shape in some cases #14014
Copy link
Copy link
Closed
Labels
bugcategory: contribTarget patches to **opencv_contrib** repository: https://github.com/opencv/opencv_contribTarget patches to **opencv_contrib** repository: https://github.com/opencv/opencv_contrib
Milestone
Description
Opencv 4.0.1-dev python version with cmake
visual studio 2017 win 64
I don't understand why cv.aruco.refineDetectedMarkers changes ndarray shape :
My code :
import cv2 as cv
import numpy as np
dico = cv.aruco.Dictionary_get(cv.aruco.DICT_7X7_250)
board= cv.aruco.CharucoBoard_create(8, 5, 0.03455, 0.02164, dico)
detectorParams=cv.aruco.DetectorParameters_create()
detectorParams.cornerRefinementMethod = cv.aruco.CORNER_REFINE_SUBPIX
detectorParams.cornerRefinementMinAccuracy = 0.01
x = cv.imread("c:/tmp/nonerecover.png")
if x is None:
print("Oops")
exit()
print ("Detect ")
refAruco,ids,refus = cv.aruco.detectMarkers(image=x, dictionary=dico,parameters=detectorParams)
print("type ", type(refAruco[0]), "shape ",refAruco[0].shape, "len ",len(refAruco))
refAruco,ids,refus,recover = cv.aruco.refineDetectedMarkers(x, board, refAruco,ids,rejectedCorners=refus)
print("Refine\nRecover ",recover)
print("type ", type(refAruco[0]), "shape ",refAruco[0].shape, "len ",len(refAruco))
x = cv.imread("c:/tmp/recover.png")
if x is None:
print("Oops")
exit()
print ("Detect ")
refAruco,ids,refus = cv.aruco.detectMarkers(image=x, dictionary=dico,parameters=detectorParams)
print("type ", type(refAruco[0]), "shape ",refAruco[0].shape, "len ",len(refAruco))
refAruco,ids,refus,recover = cv.aruco.refineDetectedMarkers(x, board, refAruco,ids,rejectedCorners=refus)
print("Refine\nRecover ",recover)
print("type ", type(refAruco[0]), "shape ",refAruco[0].shape, "len ",len(refAruco))
results :
Detect
type <class 'numpy.ndarray'> shape (1, 4, 2) len 20
Refine
Recover None
type <class 'numpy.ndarray'> shape (1, 4, 2) len 20
Detect
type <class 'numpy.ndarray'> shape (1, 4, 2) len 19
Refine
Recover [[6]]
type <class 'numpy.ndarray'> shape (4, 1, 2) len 20
shape (1, 4, 2) means 1 array with 4 points in plane
shape (4, 1, 2) why does shape change?
There is no problem with c++ code (of course you cannot change size as in python )
Ptr<aruco::Dictionary> dico = aruco::getPredefinedDictionary(aruco::PREDEFINED_DICTIONARY_NAME(cv::aruco::DICT_7X7_250));
Ptr<aruco::CharucoBoard> board = aruco::CharucoBoard::create(8, 5, 0.03455, 0.02164, dico);
Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create();
detectorParams.get()->cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX;
detectorParams.get()->cornerRefinementMinAccuracy = 0.01;
vector< int > ids;
vector< vector< Point2f > > refAruco, refus;
vector<Point2f> echiquier;
Mat x = imread("c:/tmp/nonerecover.png");
cout << "\nDetect\n";
aruco::detectMarkers(x, dico, refAruco, ids, detectorParams, refus);
cout << "size refaruco : " << refAruco.size() << endl;
cout << "size refus : " << refus.size() << endl;
aruco::refineDetectedMarkers(x, board, refAruco, ids, refus);
cout << "\nRefine\n";
cout << "size refaruco : " << refAruco.size() << endl;
cout << "size refus : " << refus.size() << endl;
x = imread("c:/tmp/recover.png");
refus.clear();
ids.clear();
refAruco.clear();
cout << "\nDetect\n";
aruco::detectMarkers(x, dico, refAruco, ids, detectorParams,refus);
cout << "size refaruco : " << refAruco.size() << endl;
cout << "size refus : " << refus.size() << endl;
aruco::refineDetectedMarkers(x, board, refAruco, ids, refus);
cout << "\nRefine\n";
cout << "size refaruco : " << refAruco.size() << endl;
cout << "size refus : " << refus.size() << endl;
Results :
G:\LiDetect
size refaruco : 20
size refus : 41
Refine
size refaruco : 20
size refus : 41
Detect
size refaruco : 19
size refus : 42
Refine
size refaruco : 20
size refus : 41
. . .
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugcategory: contribTarget patches to **opencv_contrib** repository: https://github.com/opencv/opencv_contribTarget patches to **opencv_contrib** repository: https://github.com/opencv/opencv_contrib

