Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
3a7437b6
Commit
3a7437b6
authored
Aug 25, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #748 from savuor:fix/aruco_negative_z
parents
5d9fd70c
ea3d3414
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
5 deletions
+80
-5
aruco.hpp
modules/aruco/include/opencv2/aruco.hpp
+2
-1
aruco.cpp
modules/aruco/src/aruco.cpp
+8
-3
test_boarddetection.cpp
modules/aruco/test/test_boarddetection.cpp
+69
-0
aruco_board_detection.markdown
...ials/aruco_board_detection/aruco_board_detection.markdown
+1
-1
No files found.
modules/aruco/include/opencv2/aruco.hpp
View file @
3a7437b6
...
...
@@ -322,8 +322,9 @@ class CV_EXPORTS_W GridBoard : public Board {
* @param distCoeffs vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
* @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
* (@sa Rodrigues).
* (@sa Rodrigues).
Used as initial guess if not empty.
* @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
* Used as initial guess if not empty.
*
* This function receives the detected markers and returns the pose of a marker board composed
* by those markers.
...
...
modules/aruco/src/aruco.cpp
View file @
3a7437b6
...
...
@@ -1311,9 +1311,14 @@ int estimatePoseBoard(InputArrayOfArrays _corners, InputArray _ids, Ptr<Board> &
if
(
objPoints
.
total
()
==
0
)
// 0 of the detected markers in board
return
0
;
_rvec
.
create
(
3
,
1
,
CV_64FC1
);
_tvec
.
create
(
3
,
1
,
CV_64FC1
);
solvePnP
(
objPoints
,
imgPoints
,
_cameraMatrix
,
_distCoeffs
,
_rvec
,
_tvec
);
bool
useExtrinsicGuess
=
true
;
if
(
_rvec
.
empty
()
||
_tvec
.
empty
())
{
_rvec
.
create
(
3
,
1
,
CV_64FC1
);
_tvec
.
create
(
3
,
1
,
CV_64FC1
);
useExtrinsicGuess
=
false
;
}
solvePnP
(
objPoints
,
imgPoints
,
_cameraMatrix
,
_distCoeffs
,
_rvec
,
_tvec
,
useExtrinsicGuess
);
// divide by four since all the four corners are concatenated in the array for each marker
return
(
int
)
objPoints
.
total
()
/
4
;
...
...
modules/aruco/test/test_boarddetection.cpp
View file @
3a7437b6
...
...
@@ -338,3 +338,72 @@ TEST(CV_ArucoRefine, accuracy) {
CV_ArucoRefine
test
;
test
.
safe_run
();
}
TEST
(
CV_ArucoBoardPose
,
CheckNegativeZ
)
{
double
matrixData
[
9
]
=
{
-
3.9062571886921410e+02
,
0.
,
4.2350000000000000e+02
,
0.
,
3.9062571886921410e+02
,
2.3950000000000000e+02
,
0.
,
0.
,
1
};
cv
::
Mat
cameraMatrix
=
cv
::
Mat
(
3
,
3
,
CV_64F
,
matrixData
);
cv
::
Ptr
<
cv
::
aruco
::
Board
>
boardPtr
(
new
cv
::
aruco
::
Board
);
cv
::
aruco
::
Board
&
board
=
*
boardPtr
;
board
.
ids
.
push_back
(
0
);
board
.
ids
.
push_back
(
1
);
vector
<
cv
::
Point3f
>
pts3d
;
pts3d
.
push_back
(
cv
::
Point3f
(
0.326198
f
,
-
0.030621
f
,
0.303620
f
));
pts3d
.
push_back
(
cv
::
Point3f
(
0.325340
f
,
-
0.100594
f
,
0.301862
f
));
pts3d
.
push_back
(
cv
::
Point3f
(
0.255859
f
,
-
0.099530
f
,
0.293416
f
));
pts3d
.
push_back
(
cv
::
Point3f
(
0.256717
f
,
-
0.029557
f
,
0.295174
f
));
board
.
objPoints
.
push_back
(
pts3d
);
pts3d
.
clear
();
pts3d
.
push_back
(
cv
::
Point3f
(
-
0.033144
f
,
-
0.034819
f
,
0.245216
f
));
pts3d
.
push_back
(
cv
::
Point3f
(
-
0.035507
f
,
-
0.104705
f
,
0.241987
f
));
pts3d
.
push_back
(
cv
::
Point3f
(
-
0.105289
f
,
-
0.102120
f
,
0.237120
f
));
pts3d
.
push_back
(
cv
::
Point3f
(
-
0.102926
f
,
-
0.032235
f
,
0.240349
f
));
board
.
objPoints
.
push_back
(
pts3d
);
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
Point2f
>
pts2d
;
pts2d
.
push_back
(
cv
::
Point2f
(
37.7
f
,
203.3
f
));
pts2d
.
push_back
(
cv
::
Point2f
(
38.5
f
,
120.5
f
));
pts2d
.
push_back
(
cv
::
Point2f
(
105.5
f
,
115.8
f
));
pts2d
.
push_back
(
cv
::
Point2f
(
104.2
f
,
202.7
f
));
corners
.
push_back
(
pts2d
);
pts2d
.
clear
();
pts2d
.
push_back
(
cv
::
Point2f
(
476.0
f
,
184.2
f
));
pts2d
.
push_back
(
cv
::
Point2f
(
479.6
f
,
73.8
f
));
pts2d
.
push_back
(
cv
::
Point2f
(
590.9
f
,
77.0
f
));
pts2d
.
push_back
(
cv
::
Point2f
(
587.5
f
,
188.1
f
));
corners
.
push_back
(
pts2d
);
Vec3d
rvec
,
tvec
;
int
nUsed
=
cv
::
aruco
::
estimatePoseBoard
(
corners
,
board
.
ids
,
boardPtr
,
cameraMatrix
,
Mat
(),
rvec
,
tvec
);
ASSERT_EQ
(
nUsed
,
2
);
cv
::
Matx33d
rotm
;
cv
::
Point3d
out
;
cv
::
Rodrigues
(
rvec
,
rotm
);
out
=
cv
::
Point3d
(
tvec
)
+
rotm
*
Point3d
(
board
.
objPoints
[
0
][
0
]);
ASSERT_GT
(
out
.
z
,
0
);
corners
.
clear
();
pts2d
.
clear
();
pts2d
.
push_back
(
cv
::
Point2f
(
38.4
f
,
204.5
f
));
pts2d
.
push_back
(
cv
::
Point2f
(
40.0
f
,
124.7
f
));
pts2d
.
push_back
(
cv
::
Point2f
(
102.0
f
,
119.1
f
));
pts2d
.
push_back
(
cv
::
Point2f
(
99.9
f
,
203.6
f
));
corners
.
push_back
(
pts2d
);
pts2d
.
clear
();
pts2d
.
push_back
(
cv
::
Point2f
(
476.0
f
,
184.3
f
));
pts2d
.
push_back
(
cv
::
Point2f
(
479.2
f
,
75.1
f
));
pts2d
.
push_back
(
cv
::
Point2f
(
588.7
f
,
79.2
f
));
pts2d
.
push_back
(
cv
::
Point2f
(
586.3
f
,
188.5
f
));
corners
.
push_back
(
pts2d
);
nUsed
=
cv
::
aruco
::
estimatePoseBoard
(
corners
,
board
.
ids
,
boardPtr
,
cameraMatrix
,
Mat
(),
rvec
,
tvec
);
ASSERT_EQ
(
nUsed
,
2
);
cv
::
Rodrigues
(
rvec
,
rotm
);
out
=
cv
::
Point3d
(
tvec
)
+
rotm
*
Point3d
(
board
.
objPoints
[
0
][
0
]);
ASSERT_GT
(
out
.
z
,
0
);
}
modules/aruco/tutorials/aruco_board_detection/aruco_board_detection.markdown
View file @
3a7437b6
...
...
@@ -74,7 +74,7 @@ The parameters of estimatePoseBoard are:
-
```markerCorners```
and
```markerIds```
: structures of detected markers from
```detectMarkers()```
function.
-
```board```
: the
```Board```
object that defines the board layout and its ids
-
```cameraMatrix```
and
```distCoeffs```
: camera calibration parameters necessary for pose estimation.
-
```rvec```
and
```tvec```
: estimated pose of the Board.
-
```rvec```
and
```tvec```
: estimated pose of the Board.
If not empty then treated as initial guess.
-
The function returns the total number of markers employed for estimating the board pose. Note that not all the
markers provided in
```markerCorners```
and
```markerIds```
should be used, since only the markers whose ids are
listed in the
```Board::ids```
structure are considered.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment