Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfc0af69

Browse files
remove charuco duplication
1 parente247b68 commitfc0af69

File tree

2 files changed

+26
-473
lines changed

2 files changed

+26
-473
lines changed

‎modules/aruco/src/aruco.cpp‎

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -59,64 +59,19 @@ int estimatePoseBoard(InputArrayOfArrays corners, InputArray ids, const Ptr<Boar
5959
return (int)objPoints.total() /4;
6060
}
6161

62-
63-
/**
64-
* Check if a set of 3d points are enough for calibration. Z coordinate is ignored.
65-
* Only axis parallel lines are considered
66-
*/
67-
staticbool_arePointsEnoughForPoseEstimation(const vector<Point3f> &points) {
68-
if(points.size() <4)returnfalse;
69-
70-
vector<double> sameXValue;// different x values in points
71-
vector<int> sameXCounter;// number of points with the x value in sameXValue
72-
for(unsignedint i =0; i < points.size(); i++) {
73-
bool found =false;
74-
for(unsignedint j =0; j < sameXValue.size(); j++) {
75-
if(sameXValue[j] == points[i].x) {
76-
found =true;
77-
sameXCounter[j]++;
78-
}
79-
}
80-
if(!found) {
81-
sameXValue.push_back(points[i].x);
82-
sameXCounter.push_back(1);
83-
}
84-
}
85-
86-
// count how many x values has more than 2 points
87-
int moreThan2 =0;
88-
for(unsignedint i =0; i < sameXCounter.size(); i++) {
89-
if(sameXCounter[i] >=2) moreThan2++;
90-
}
91-
92-
// if we have more than 1 two xvalues with more than 2 points, calibration is ok
93-
if(moreThan2 >1)
94-
returntrue;
95-
returnfalse;
96-
}
97-
9862
boolestimatePoseCharucoBoard(InputArray charucoCorners, InputArray charucoIds,
99-
const Ptr<CharucoBoard> &board, InputArray cameraMatrix,
100-
InputArray distCoeffs, InputOutputArray rvec,
101-
InputOutputArray tvec,bool useExtrinsicGuess) {
63+
const Ptr<CharucoBoard> &board, InputArray cameraMatrix,
64+
InputArray distCoeffs, InputOutputArray rvec,
65+
InputOutputArray tvec,bool useExtrinsicGuess) {
10266
CV_Assert((charucoCorners.getMat().total() == charucoIds.getMat().total()));
103-
104-
// need, at least, 4 corners
10567
if(charucoIds.getMat().total() <4)returnfalse;
10668

107-
vector<Point3f> objPoints;
108-
objPoints.reserve(charucoIds.getMat().total());
109-
for(unsignedint i =0; i < charucoIds.getMat().total(); i++) {
110-
int currId = charucoIds.getMat().at<int >(i);
111-
CV_Assert(currId >=0 && currId < (int)board->getChessboardCorners().size());
112-
objPoints.push_back(board->getChessboardCorners()[currId]);
113-
}
114-
115-
// points need to be in different lines, check if detected points are enough
116-
if(!_arePointsEnoughForPoseEstimation(objPoints))returnfalse;
69+
// get object and image points for the solvePnP function
70+
Mat objPoints, imgPoints;
71+
board->matchImagePoints(charucoCorners, charucoIds, objPoints, imgPoints);
72+
solvePnP(objPoints, imgPoints, cameraMatrix, distCoeffs, rvec, tvec, useExtrinsicGuess);
11773

118-
solvePnP(objPoints, charucoCorners, cameraMatrix, distCoeffs, rvec, tvec, useExtrinsicGuess);
119-
returntrue;
74+
return objPoints.total() >0ull;
12075
}
12176

12277
booltestCharucoCornersCollinear(const Ptr<CharucoBoard> &board, InputArray charucoIds) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp