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
063c191d
Commit
063c191d
authored
Dec 19, 2015
by
folz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aruco: Use shared Ptrs to support exporting
parent
9b06bb28
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
443 additions
and
332 deletions
+443
-332
aruco.hpp
modules/aruco/include/opencv2/aruco.hpp
+50
-39
charuco.hpp
modules/aruco/include/opencv2/aruco/charuco.hpp
+14
-13
dictionary.hpp
modules/aruco/include/opencv2/aruco/dictionary.hpp
+52
-9
calibrate_camera.cpp
modules/aruco/samples/calibrate_camera.cpp
+25
-24
calibrate_camera_charuco.cpp
modules/aruco/samples/calibrate_camera_charuco.cpp
+28
-27
create_board.cpp
modules/aruco/samples/create_board.cpp
+3
-3
create_board_charuco.cpp
modules/aruco/samples/create_board_charuco.cpp
+3
-3
create_diamond.cpp
modules/aruco/samples/create_diamond.cpp
+1
-1
create_marker.cpp
modules/aruco/samples/create_marker.cpp
+1
-1
detect_board.cpp
modules/aruco/samples/detect_board.cpp
+26
-25
detect_board_charuco.cpp
modules/aruco/samples/detect_board_charuco.cpp
+27
-26
detect_diamonds.cpp
modules/aruco/samples/detect_diamonds.cpp
+23
-23
detect_markers.cpp
modules/aruco/samples/detect_markers.cpp
+24
-24
aruco.cpp
modules/aruco/src/aruco.cpp
+0
-0
charuco.cpp
modules/aruco/src/charuco.cpp
+0
-0
dictionary.cpp
modules/aruco/src/dictionary.cpp
+83
-36
test_arucodetection.cpp
modules/aruco/test/test_arucodetection.cpp
+29
-26
test_boarddetection.cpp
modules/aruco/test/test_boarddetection.cpp
+26
-24
test_charucodetection.cpp
modules/aruco/test/test_charucodetection.cpp
+28
-28
No files found.
modules/aruco/include/opencv2/aruco.hpp
View file @
063c191d
...
@@ -121,30 +121,32 @@ namespace aruco {
...
@@ -121,30 +121,32 @@ namespace aruco {
* - errorCorrectionRate error correction rate respect to the maximun error correction capability
* - errorCorrectionRate error correction rate respect to the maximun error correction capability
* for each dictionary. (default 0.6).
* for each dictionary. (default 0.6).
*/
*/
struct
CV_EXPORTS
DetectorParameters
{
struct
CV_EXPORTS
_W
DetectorParameters
{
DetectorParameters
();
DetectorParameters
();
int
adaptiveThreshWinSizeMin
;
CV_WRAP
static
Ptr
<
DetectorParameters
>
create
();
int
adaptiveThreshWinSizeMax
;
int
adaptiveThreshWinSizeStep
;
CV_PROP_RW
int
adaptiveThreshWinSizeMin
;
double
adaptiveThreshConstant
;
CV_PROP_RW
int
adaptiveThreshWinSizeMax
;
double
minMarkerPerimeterRate
;
CV_PROP_RW
int
adaptiveThreshWinSizeStep
;
double
maxMarkerPerimeterRate
;
CV_PROP_RW
double
adaptiveThreshConstant
;
double
polygonalApproxAccuracyRate
;
CV_PROP_RW
double
minMarkerPerimeterRate
;
double
minCornerDistanceRate
;
CV_PROP_RW
double
maxMarkerPerimeterRate
;
int
minDistanceToBorder
;
CV_PROP_RW
double
polygonalApproxAccuracyRate
;
double
minMarkerDistanceRate
;
CV_PROP_RW
double
minCornerDistanceRate
;
bool
doCornerRefinement
;
CV_PROP_RW
int
minDistanceToBorder
;
int
cornerRefinementWinSize
;
CV_PROP_RW
double
minMarkerDistanceRate
;
int
cornerRefinementMaxIterations
;
CV_PROP_RW
bool
doCornerRefinement
;
double
cornerRefinementMinAccuracy
;
CV_PROP_RW
int
cornerRefinementWinSize
;
int
markerBorderBits
;
CV_PROP_RW
int
cornerRefinementMaxIterations
;
int
perspectiveRemovePixelPerCell
;
CV_PROP_RW
double
cornerRefinementMinAccuracy
;
double
perspectiveRemoveIgnoredMarginPerCell
;
CV_PROP_RW
int
markerBorderBits
;
double
maxErroneousBitsInBorderRate
;
CV_PROP_RW
int
perspectiveRemovePixelPerCell
;
double
minOtsuStdDev
;
CV_PROP_RW
double
perspectiveRemoveIgnoredMarginPerCell
;
double
errorCorrectionRate
;
CV_PROP_RW
double
maxErroneousBitsInBorderRate
;
CV_PROP_RW
double
minOtsuStdDev
;
CV_PROP_RW
double
errorCorrectionRate
;
};
};
...
@@ -171,8 +173,8 @@ struct CV_EXPORTS DetectorParameters {
...
@@ -171,8 +173,8 @@ struct CV_EXPORTS DetectorParameters {
* @sa estimatePoseSingleMarkers, estimatePoseBoard
* @sa estimatePoseSingleMarkers, estimatePoseBoard
*
*
*/
*/
CV_EXPORTS
void
detectMarkers
(
InputArray
image
,
Dictionary
dictionary
,
OutputArrayOfArrays
corners
,
CV_EXPORTS
_W
void
detectMarkers
(
InputArray
image
,
Ptr
<
Dictionary
>
&
dictionary
,
OutputArrayOfArrays
corners
,
OutputArray
ids
,
DetectorParameters
parameters
=
DetectorParameters
(),
OutputArray
ids
,
const
Ptr
<
DetectorParameters
>
&
parameters
=
DetectorParameters
::
create
(),
OutputArrayOfArrays
rejectedImgPoints
=
noArray
());
OutputArrayOfArrays
rejectedImgPoints
=
noArray
());
...
@@ -205,7 +207,7 @@ CV_EXPORTS void detectMarkers(InputArray image, Dictionary dictionary, OutputArr
...
@@ -205,7 +207,7 @@ CV_EXPORTS void detectMarkers(InputArray image, Dictionary dictionary, OutputArr
* (-markerLength/2, markerLength/2, 0), (markerLength/2, markerLength/2, 0),
* (-markerLength/2, markerLength/2, 0), (markerLength/2, markerLength/2, 0),
* (markerLength/2, -markerLength/2, 0), (-markerLength/2, -markerLength/2, 0)
* (markerLength/2, -markerLength/2, 0), (-markerLength/2, -markerLength/2, 0)
*/
*/
CV_EXPORTS
void
estimatePoseSingleMarkers
(
InputArrayOfArrays
corners
,
float
markerLength
,
CV_EXPORTS
_W
void
estimatePoseSingleMarkers
(
InputArrayOfArrays
corners
,
float
markerLength
,
InputArray
cameraMatrix
,
InputArray
distCoeffs
,
InputArray
cameraMatrix
,
InputArray
distCoeffs
,
OutputArrayOfArrays
rvecs
,
OutputArrayOfArrays
tvecs
);
OutputArrayOfArrays
rvecs
,
OutputArrayOfArrays
tvecs
);
...
@@ -221,7 +223,7 @@ CV_EXPORTS void estimatePoseSingleMarkers(InputArrayOfArrays corners, float mark
...
@@ -221,7 +223,7 @@ CV_EXPORTS void estimatePoseSingleMarkers(InputArrayOfArrays corners, float mark
* - The dictionary which indicates the type of markers of the board
* - The dictionary which indicates the type of markers of the board
* - The identifier of all the markers in the board.
* - The identifier of all the markers in the board.
*/
*/
class
CV_EXPORTS
Board
{
class
CV_EXPORTS
_W
Board
{
public
:
public
:
// array of object points of all the marker corners in the board
// array of object points of all the marker corners in the board
...
@@ -229,7 +231,7 @@ class CV_EXPORTS Board {
...
@@ -229,7 +231,7 @@ class CV_EXPORTS Board {
std
::
vector
<
std
::
vector
<
Point3f
>
>
objPoints
;
std
::
vector
<
std
::
vector
<
Point3f
>
>
objPoints
;
// the dictionary of markers employed for this board
// the dictionary of markers employed for this board
Dictionary
dictionary
;
Ptr
<
Dictionary
>
dictionary
;
// vector of the identifiers of the markers in the board (same size than objPoints)
// vector of the identifiers of the markers in the board (same size than objPoints)
// The identifiers refers to the board dictionary
// The identifiers refers to the board dictionary
...
@@ -243,7 +245,7 @@ class CV_EXPORTS Board {
...
@@ -243,7 +245,7 @@ class CV_EXPORTS Board {
* More common type of board. All markers are placed in the same plane in a grid arrangment.
* More common type of board. All markers are placed in the same plane in a grid arrangment.
* The board can be drawn using drawPlanarBoard() function (@sa drawPlanarBoard)
* The board can be drawn using drawPlanarBoard() function (@sa drawPlanarBoard)
*/
*/
class
CV_EXPORTS
GridBoard
:
public
Board
{
class
CV_EXPORTS
_W
GridBoard
:
public
Board
{
public
:
public
:
/**
/**
...
@@ -274,8 +276,8 @@ class CV_EXPORTS GridBoard : public Board {
...
@@ -274,8 +276,8 @@ class CV_EXPORTS GridBoard : public Board {
* This functions creates a GridBoard object given the number of markers in each direction and
* This functions creates a GridBoard object given the number of markers in each direction and
* the marker size and marker separation.
* the marker size and marker separation.
*/
*/
static
GridBoard
create
(
int
markersX
,
int
markersY
,
float
markerLength
,
float
markerSeparation
,
CV_WRAP
static
Ptr
<
GridBoard
>
create
(
int
markersX
,
int
markersY
,
float
markerLength
,
Dictionary
dictionary
);
float
markerSeparation
,
Ptr
<
Dictionary
>
&
dictionary
);
/**
/**
*
*
...
@@ -332,7 +334,7 @@ class CV_EXPORTS GridBoard : public Board {
...
@@ -332,7 +334,7 @@ class CV_EXPORTS GridBoard : public Board {
* The function returns the number of markers from the input employed for the board pose estimation.
* The function returns the number of markers from the input employed for the board pose estimation.
* Note that returning a 0 means the pose has not been estimated.
* Note that returning a 0 means the pose has not been estimated.
*/
*/
CV_EXPORTS
int
estimatePoseBoard
(
InputArrayOfArrays
corners
,
InputArray
ids
,
const
Board
&
board
,
CV_EXPORTS
_W
int
estimatePoseBoard
(
InputArrayOfArrays
corners
,
InputArray
ids
,
Ptr
<
Board
>
&
board
,
InputArray
cameraMatrix
,
InputArray
distCoeffs
,
OutputArray
rvec
,
InputArray
cameraMatrix
,
InputArray
distCoeffs
,
OutputArray
rvec
,
OutputArray
tvec
);
OutputArray
tvec
);
...
@@ -370,12 +372,12 @@ CV_EXPORTS int estimatePoseBoard(InputArrayOfArrays corners, InputArray ids, con
...
@@ -370,12 +372,12 @@ CV_EXPORTS int estimatePoseBoard(InputArrayOfArrays corners, InputArray ids, con
* using projectPoint function. If not, missing marker projections are interpolated using global
* using projectPoint function. If not, missing marker projections are interpolated using global
* homography, and all the marker corners in the board must have the same Z coordinate.
* homography, and all the marker corners in the board must have the same Z coordinate.
*/
*/
CV_EXPORTS
void
refineDetectedMarkers
(
CV_EXPORTS
_W
void
refineDetectedMarkers
(
InputArray
image
,
const
Board
&
board
,
InputOutputArrayOfArrays
detectedCorners
,
InputArray
image
,
Ptr
<
Board
>
&
board
,
InputOutputArrayOfArrays
detectedCorners
,
InputOutputArray
detectedIds
,
InputOutputArray
rejectedCorners
,
InputOutputArray
detectedIds
,
InputOutputArray
rejectedCorners
,
InputArray
cameraMatrix
=
noArray
(),
InputArray
distCoeffs
=
noArray
(),
InputArray
cameraMatrix
=
noArray
(),
InputArray
distCoeffs
=
noArray
(),
float
minRepDistance
=
10.
f
,
float
errorCorrectionRate
=
3.
f
,
bool
checkAllOrders
=
true
,
float
minRepDistance
=
10.
f
,
float
errorCorrectionRate
=
3.
f
,
bool
checkAllOrders
=
true
,
OutputArray
recoveredIdxs
=
noArray
(),
DetectorParameters
parameters
=
DetectorParameters
());
OutputArray
recoveredIdxs
=
noArray
(),
const
Ptr
<
DetectorParameters
>
&
parameters
=
DetectorParameters
::
create
());
...
@@ -396,7 +398,7 @@ CV_EXPORTS void refineDetectedMarkers(
...
@@ -396,7 +398,7 @@ CV_EXPORTS void refineDetectedMarkers(
* the markers in the image. The marker borders are painted and the markers identifiers if provided.
* the markers in the image. The marker borders are painted and the markers identifiers if provided.
* Useful for debugging purposes.
* Useful for debugging purposes.
*/
*/
CV_EXPORTS
void
drawDetectedMarkers
(
InputOutputArray
image
,
InputArrayOfArrays
corners
,
CV_EXPORTS
_W
void
drawDetectedMarkers
(
InputOutputArray
image
,
InputArrayOfArrays
corners
,
InputArray
ids
=
noArray
(),
InputArray
ids
=
noArray
(),
Scalar
borderColor
=
Scalar
(
0
,
255
,
0
));
Scalar
borderColor
=
Scalar
(
0
,
255
,
0
));
...
@@ -418,7 +420,7 @@ CV_EXPORTS void drawDetectedMarkers(InputOutputArray image, InputArrayOfArrays c
...
@@ -418,7 +420,7 @@ CV_EXPORTS void drawDetectedMarkers(InputOutputArray image, InputArrayOfArrays c
* Given the pose estimation of a marker or board, this function draws the axis of the world
* Given the pose estimation of a marker or board, this function draws the axis of the world
* coordinate system, i.e. the system centered on the marker/board. Useful for debugging purposes.
* coordinate system, i.e. the system centered on the marker/board. Useful for debugging purposes.
*/
*/
CV_EXPORTS
void
drawAxis
(
InputOutputArray
image
,
InputArray
cameraMatrix
,
InputArray
distCoeffs
,
CV_EXPORTS
_W
void
drawAxis
(
InputOutputArray
image
,
InputArray
cameraMatrix
,
InputArray
distCoeffs
,
InputArray
rvec
,
InputArray
tvec
,
float
length
);
InputArray
rvec
,
InputArray
tvec
,
float
length
);
...
@@ -435,13 +437,14 @@ CV_EXPORTS void drawAxis(InputOutputArray image, InputArray cameraMatrix, InputA
...
@@ -435,13 +437,14 @@ CV_EXPORTS void drawAxis(InputOutputArray image, InputArray cameraMatrix, InputA
*
*
* This function returns a marker image in its canonical form (i.e. ready to be printed)
* This function returns a marker image in its canonical form (i.e. ready to be printed)
*/
*/
CV_EXPORTS
void
drawMarker
(
Dictionary
dictionary
,
int
id
,
int
sidePixels
,
OutputArray
img
,
CV_EXPORTS
_W
void
drawMarker
(
Ptr
<
Dictionary
>
&
dictionary
,
int
id
,
int
sidePixels
,
OutputArray
img
,
int
borderBits
=
1
);
int
borderBits
=
1
);
/**
/**
* @brief Draw a planar board
* @brief Draw a planar board
* @sa _drawPlanarBoardImpl
*
*
* @param board layout of the board that will be drawn. The board should be planar,
* @param board layout of the board that will be drawn. The board should be planar,
* z coordinate is ignored
* z coordinate is ignored
...
@@ -454,7 +457,15 @@ CV_EXPORTS void drawMarker(Dictionary dictionary, int id, int sidePixels, Output
...
@@ -454,7 +457,15 @@ CV_EXPORTS void drawMarker(Dictionary dictionary, int id, int sidePixels, Output
* This function return the image of a planar board, ready to be printed. It assumes
* This function return the image of a planar board, ready to be printed. It assumes
* the Board layout specified is planar by ignoring the z coordinates of the object points.
* the Board layout specified is planar by ignoring the z coordinates of the object points.
*/
*/
CV_EXPORTS
void
drawPlanarBoard
(
const
Board
&
board
,
Size
outSize
,
OutputArray
img
,
CV_EXPORTS_W
void
drawPlanarBoard
(
Ptr
<
Board
>
&
board
,
Size
outSize
,
OutputArray
img
,
int
marginSize
=
0
,
int
borderBits
=
1
);
/**
* @brief Implementation of drawPlanarBoard that accepts a raw Board pointer.
*/
void
_drawPlanarBoardImpl
(
Board
*
board
,
Size
outSize
,
OutputArray
img
,
int
marginSize
=
0
,
int
borderBits
=
1
);
int
marginSize
=
0
,
int
borderBits
=
1
);
...
@@ -487,8 +498,8 @@ CV_EXPORTS void drawPlanarBoard(const Board &board, Size outSize, OutputArray im
...
@@ -487,8 +498,8 @@ CV_EXPORTS void drawPlanarBoard(const Board &board, Size outSize, OutputArray im
* detected markers from several views of the Board. The process is similar to the chessboard
* detected markers from several views of the Board. The process is similar to the chessboard
* calibration in calibrateCamera(). The function returns the final re-projection error.
* calibration in calibrateCamera(). The function returns the final re-projection error.
*/
*/
CV_EXPORTS
double
calibrateCameraAruco
(
CV_EXPORTS
_W
double
calibrateCameraAruco
(
InputArrayOfArrays
corners
,
InputArray
ids
,
InputArray
counter
,
const
Board
&
board
,
InputArrayOfArrays
corners
,
InputArray
ids
,
InputArray
counter
,
Ptr
<
Board
>
&
board
,
Size
imageSize
,
InputOutputArray
cameraMatrix
,
InputOutputArray
distCoeffs
,
Size
imageSize
,
InputOutputArray
cameraMatrix
,
InputOutputArray
distCoeffs
,
OutputArrayOfArrays
rvecs
=
noArray
(),
OutputArrayOfArrays
tvecs
=
noArray
(),
int
flags
=
0
,
OutputArrayOfArrays
rvecs
=
noArray
(),
OutputArrayOfArrays
tvecs
=
noArray
(),
int
flags
=
0
,
TermCriteria
criteria
=
TermCriteria
(
TermCriteria
::
COUNT
+
TermCriteria
::
EPS
,
30
,
DBL_EPSILON
));
TermCriteria
criteria
=
TermCriteria
(
TermCriteria
::
COUNT
+
TermCriteria
::
EPS
,
30
,
DBL_EPSILON
));
...
...
modules/aruco/include/opencv2/aruco/charuco.hpp
View file @
063c191d
...
@@ -59,7 +59,7 @@ namespace aruco {
...
@@ -59,7 +59,7 @@ namespace aruco {
* calibration and pose estimation.
* calibration and pose estimation.
* This class also allows the easy creation and drawing of ChArUco boards.
* This class also allows the easy creation and drawing of ChArUco boards.
*/
*/
class
CV_EXPORTS
CharucoBoard
:
public
Board
{
class
CV_EXPORTS
_W
CharucoBoard
:
public
Board
{
public
:
public
:
// vector of chessboard 3D corners precalculated
// vector of chessboard 3D corners precalculated
...
@@ -97,8 +97,8 @@ class CV_EXPORTS CharucoBoard : public Board {
...
@@ -97,8 +97,8 @@ class CV_EXPORTS CharucoBoard : public Board {
* This functions creates a CharucoBoard object given the number of squares in each direction
* This functions creates a CharucoBoard object given the number of squares in each direction
* and the size of the markers and chessboard squares.
* and the size of the markers and chessboard squares.
*/
*/
static
CharucoBoard
create
(
int
squaresX
,
int
squaresY
,
float
squareLength
,
float
marker
Length
,
CV_WRAP
static
Ptr
<
CharucoBoard
>
create
(
int
squaresX
,
int
squaresY
,
float
square
Length
,
Dictionary
dictionary
);
float
markerLength
,
Ptr
<
Dictionary
>
&
dictionary
);
/**
/**
*
*
...
@@ -154,8 +154,8 @@ class CV_EXPORTS CharucoBoard : public Board {
...
@@ -154,8 +154,8 @@ class CV_EXPORTS CharucoBoard : public Board {
* also returned in charucoIds.
* also returned in charucoIds.
* The function returns the number of interpolated corners.
* The function returns the number of interpolated corners.
*/
*/
CV_EXPORTS
int
interpolateCornersCharuco
(
InputArrayOfArrays
markerCorners
,
InputArray
markerIds
,
CV_EXPORTS
_W
int
interpolateCornersCharuco
(
InputArrayOfArrays
markerCorners
,
InputArray
markerIds
,
InputArray
image
,
const
CharucoBoard
&
board
,
InputArray
image
,
Ptr
<
CharucoBoard
>
&
board
,
OutputArray
charucoCorners
,
OutputArray
charucoIds
,
OutputArray
charucoCorners
,
OutputArray
charucoIds
,
InputArray
cameraMatrix
=
noArray
(),
InputArray
cameraMatrix
=
noArray
(),
InputArray
distCoeffs
=
noArray
());
InputArray
distCoeffs
=
noArray
());
...
@@ -180,8 +180,8 @@ CV_EXPORTS int interpolateCornersCharuco(InputArrayOfArrays markerCorners, Input
...
@@ -180,8 +180,8 @@ CV_EXPORTS int interpolateCornersCharuco(InputArrayOfArrays markerCorners, Input
* The function checks if the input corners are enough and valid to perform pose estimation.
* The function checks if the input corners are enough and valid to perform pose estimation.
* If pose estimation is valid, returns true, else returns false.
* If pose estimation is valid, returns true, else returns false.
*/
*/
CV_EXPORTS
bool
estimatePoseCharucoBoard
(
InputArray
charucoCorners
,
InputArray
charucoIds
,
CV_EXPORTS
_W
bool
estimatePoseCharucoBoard
(
InputArray
charucoCorners
,
InputArray
charucoIds
,
CharucoBoard
&
board
,
InputArray
cameraMatrix
,
Ptr
<
CharucoBoard
>
&
board
,
InputArray
cameraMatrix
,
InputArray
distCoeffs
,
OutputArray
rvec
,
OutputArray
tvec
);
InputArray
distCoeffs
,
OutputArray
rvec
,
OutputArray
tvec
);
...
@@ -198,7 +198,7 @@ CV_EXPORTS bool estimatePoseCharucoBoard(InputArray charucoCorners, InputArray c
...
@@ -198,7 +198,7 @@ CV_EXPORTS bool estimatePoseCharucoBoard(InputArray charucoCorners, InputArray c
* This function draws a set of detected Charuco corners. If identifiers vector is provided, it also
* This function draws a set of detected Charuco corners. If identifiers vector is provided, it also
* draws the id of each corner.
* draws the id of each corner.
*/
*/
CV_EXPORTS
void
drawDetectedCornersCharuco
(
InputOutputArray
image
,
InputArray
charucoCorners
,
CV_EXPORTS
_W
void
drawDetectedCornersCharuco
(
InputOutputArray
image
,
InputArray
charucoCorners
,
InputArray
charucoIds
=
noArray
(),
InputArray
charucoIds
=
noArray
(),
Scalar
cornerColor
=
Scalar
(
255
,
0
,
0
));
Scalar
cornerColor
=
Scalar
(
255
,
0
,
0
));
...
@@ -230,8 +230,8 @@ CV_EXPORTS void drawDetectedCornersCharuco(InputOutputArray image, InputArray ch
...
@@ -230,8 +230,8 @@ CV_EXPORTS void drawDetectedCornersCharuco(InputOutputArray image, InputArray ch
* receives a list of detected corners and its identifiers from several views of the Board.
* receives a list of detected corners and its identifiers from several views of the Board.
* The function returns the final re-projection error.
* The function returns the final re-projection error.
*/
*/
CV_EXPORTS
double
calibrateCameraCharuco
(
CV_EXPORTS
_W
double
calibrateCameraCharuco
(
InputArrayOfArrays
charucoCorners
,
InputArrayOfArrays
charucoIds
,
const
CharucoBoard
&
board
,
InputArrayOfArrays
charucoCorners
,
InputArrayOfArrays
charucoIds
,
Ptr
<
CharucoBoard
>
&
board
,
Size
imageSize
,
InputOutputArray
cameraMatrix
,
InputOutputArray
distCoeffs
,
Size
imageSize
,
InputOutputArray
cameraMatrix
,
InputOutputArray
distCoeffs
,
OutputArrayOfArrays
rvecs
=
noArray
(),
OutputArrayOfArrays
tvecs
=
noArray
(),
int
flags
=
0
,
OutputArrayOfArrays
rvecs
=
noArray
(),
OutputArrayOfArrays
tvecs
=
noArray
(),
int
flags
=
0
,
TermCriteria
criteria
=
TermCriteria
(
TermCriteria
::
COUNT
+
TermCriteria
::
EPS
,
30
,
DBL_EPSILON
));
TermCriteria
criteria
=
TermCriteria
(
TermCriteria
::
COUNT
+
TermCriteria
::
EPS
,
30
,
DBL_EPSILON
));
...
@@ -261,7 +261,7 @@ CV_EXPORTS double calibrateCameraCharuco(
...
@@ -261,7 +261,7 @@ CV_EXPORTS double calibrateCameraCharuco(
* are provided, the diamond search is based on reprojection. If not, diamond search is based on
* are provided, the diamond search is based on reprojection. If not, diamond search is based on
* homography. Homography is faster than reprojection but can slightly reduce the detection rate.
* homography. Homography is faster than reprojection but can slightly reduce the detection rate.
*/
*/
CV_EXPORTS
void
detectCharucoDiamond
(
InputArray
image
,
InputArrayOfArrays
markerCorners
,
CV_EXPORTS
_W
void
detectCharucoDiamond
(
InputArray
image
,
InputArrayOfArrays
markerCorners
,
InputArray
markerIds
,
float
squareMarkerLengthRate
,
InputArray
markerIds
,
float
squareMarkerLengthRate
,
OutputArrayOfArrays
diamondCorners
,
OutputArray
diamondIds
,
OutputArrayOfArrays
diamondCorners
,
OutputArray
diamondIds
,
InputArray
cameraMatrix
=
noArray
(),
InputArray
cameraMatrix
=
noArray
(),
...
@@ -287,7 +287,7 @@ CV_EXPORTS void detectCharucoDiamond(InputArray image, InputArrayOfArrays marker
...
@@ -287,7 +287,7 @@ CV_EXPORTS void detectCharucoDiamond(InputArray image, InputArrayOfArrays marker
* are painted and the markers identifiers if provided.
* are painted and the markers identifiers if provided.
* Useful for debugging purposes.
* Useful for debugging purposes.
*/
*/
CV_EXPORTS
void
drawDetectedDiamonds
(
InputOutputArray
image
,
InputArrayOfArrays
diamondCorners
,
CV_EXPORTS
_W
void
drawDetectedDiamonds
(
InputOutputArray
image
,
InputArrayOfArrays
diamondCorners
,
InputArray
diamondIds
=
noArray
(),
InputArray
diamondIds
=
noArray
(),
Scalar
borderColor
=
Scalar
(
0
,
0
,
255
));
Scalar
borderColor
=
Scalar
(
0
,
0
,
255
));
...
@@ -308,7 +308,8 @@ CV_EXPORTS void drawDetectedDiamonds(InputOutputArray image, InputArrayOfArrays
...
@@ -308,7 +308,8 @@ CV_EXPORTS void drawDetectedDiamonds(InputOutputArray image, InputArrayOfArrays
*
*
* This function return the image of a ChArUco marker, ready to be printed.
* This function return the image of a ChArUco marker, ready to be printed.
*/
*/
CV_EXPORTS
void
drawCharucoDiamond
(
Dictionary
dictionary
,
Vec4i
ids
,
int
squareLength
,
// TODO cannot be exported yet; conversion from/to Vec4i is not wrapped in core
CV_EXPORTS
void
drawCharucoDiamond
(
Ptr
<
Dictionary
>
&
dictionary
,
Vec4i
ids
,
int
squareLength
,
int
markerLength
,
OutputArray
img
,
int
marginSize
=
0
,
int
markerLength
,
OutputArray
img
,
int
marginSize
=
0
,
int
borderBits
=
1
);
int
borderBits
=
1
);
...
...
modules/aruco/include/opencv2/aruco/dictionary.hpp
View file @
063c191d
...
@@ -58,12 +58,12 @@ namespace aruco {
...
@@ -58,12 +58,12 @@ namespace aruco {
*
*
* `bytesList.ptr(i)[k*nbytes + j]` is then the j-th byte of i-th marker, in its k-th rotation.
* `bytesList.ptr(i)[k*nbytes + j]` is then the j-th byte of i-th marker, in its k-th rotation.
*/
*/
class
CV_EXPORTS
Dictionary
{
class
CV_EXPORTS
_W
Dictionary
{
public
:
public
:
Mat
bytesList
;
// marker code information
CV_PROP_RW
Mat
bytesList
;
// marker code information
int
markerSize
;
// number of bits per dimension
CV_PROP_RW
int
markerSize
;
// number of bits per dimension
int
maxCorrectionBits
;
// maximum number of bits that can be corrected
CV_PROP_RW
int
maxCorrectionBits
;
// maximum number of bits that can be corrected
/**
/**
...
@@ -71,6 +71,32 @@ class CV_EXPORTS Dictionary {
...
@@ -71,6 +71,32 @@ class CV_EXPORTS Dictionary {
Dictionary
(
const
Mat
&
_bytesList
=
Mat
(),
int
_markerSize
=
0
,
int
_maxcorr
=
0
);
Dictionary
(
const
Mat
&
_bytesList
=
Mat
(),
int
_markerSize
=
0
,
int
_maxcorr
=
0
);
/**
Dictionary(const Dictionary &_dictionary);
*/
/**
*/
Dictionary
(
const
Ptr
<
Dictionary
>
&
_dictionary
);
/**
* @see generateCustomDictionary
*/
CV_WRAP_AS
(
create
)
static
Ptr
<
Dictionary
>
create
(
int
nMarkers
,
int
markerSize
);
/**
* @see generateCustomDictionary
*/
CV_WRAP_AS
(
create_from
)
static
Ptr
<
Dictionary
>
create
(
int
nMarkers
,
int
markerSize
,
Ptr
<
Dictionary
>
&
baseDictionary
);
/**
* @see getPredefinedDictionary
*/
CV_WRAP
static
Ptr
<
Dictionary
>
get
(
int
dict
);
/**
/**
* @brief Given a matrix of bits. Returns whether if marker is identified or not.
* @brief Given a matrix of bits. Returns whether if marker is identified or not.
...
@@ -109,9 +135,10 @@ class CV_EXPORTS Dictionary {
...
@@ -109,9 +135,10 @@ class CV_EXPORTS Dictionary {
/**
/**
* @brief Predefined markers dictionaries/sets
* @brief Predefined markers dictionaries/sets
* Each dictionary indicates the number of bits and the number of markers contained
* Each dictionary indicates the number of bits and the number of markers contained
* - DICT_ARUCO: standard ArUco Library Markers. 1024 markers, 5x5 bits, 0 minimum distance
* - DICT_ARUCO_ORIGINAL: standard ArUco Library Markers. 1024 markers, 5x5 bits, 0 minimum
distance
*/
*/
enum
PREDEFINED_DICTIONARY_NAME
{
enum
CV_EXPORTS_W_SIMPLE
PREDEFINED_DICTIONARY_NAME
{
DICT_4X4_50
=
0
,
DICT_4X4_50
=
0
,
DICT_4X4_100
,
DICT_4X4_100
,
DICT_4X4_250
,
DICT_4X4_250
,
...
@@ -135,7 +162,21 @@ enum PREDEFINED_DICTIONARY_NAME {
...
@@ -135,7 +162,21 @@ enum PREDEFINED_DICTIONARY_NAME {
/**
/**
* @brief Returns one of the predefined dictionaries defined in PREDEFINED_DICTIONARY_NAME
* @brief Returns one of the predefined dictionaries defined in PREDEFINED_DICTIONARY_NAME
*/
*/
CV_EXPORTS
const
Dictionary
&
getPredefinedDictionary
(
PREDEFINED_DICTIONARY_NAME
name
);
CV_EXPORTS
Ptr
<
Dictionary
>
getPredefinedDictionary
(
PREDEFINED_DICTIONARY_NAME
name
);
/**
* @brief Returns one of the predefined dictionaries referenced by DICT_*.
*/
CV_EXPORTS_W
Ptr
<
Dictionary
>
getPredefinedDictionary
(
int
dict
);
/**
* @see generateCustomDictionary
*/
CV_EXPORTS_AS
(
custom_dictionary
)
Ptr
<
Dictionary
>
generateCustomDictionary
(
int
nMarkers
,
int
markerSize
);
/**
/**
...
@@ -150,8 +191,10 @@ CV_EXPORTS const Dictionary &getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME
...
@@ -150,8 +191,10 @@ CV_EXPORTS const Dictionary &getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME
* included and the rest are generated based on them. If the size of baseDictionary is higher
* included and the rest are generated based on them. If the size of baseDictionary is higher
* than nMarkers, only the first nMarkers in baseDictionary are taken and no new marker is added.
* than nMarkers, only the first nMarkers in baseDictionary are taken and no new marker is added.
*/
*/
CV_EXPORTS
Dictionary
generateCustomDictionary
(
int
nMarkers
,
int
markerSize
,
CV_EXPORTS_AS
(
custom_dictionary_from
)
Ptr
<
Dictionary
>
generateCustomDictionary
(
const
Dictionary
&
baseDictionary
=
Dictionary
());
int
nMarkers
,
int
markerSize
,
Ptr
<
Dictionary
>
&
baseDictionary
);
...
...
modules/aruco/samples/calibrate_camera.cpp
View file @
063c191d
...
@@ -76,30 +76,30 @@ const char* keys =
...
@@ -76,30 +76,30 @@ const char* keys =
/**
/**
*/
*/
static
bool
readDetectorParameters
(
string
filename
,
aruco
::
DetectorParameters
&
params
)
{
static
bool
readDetectorParameters
(
string
filename
,
Ptr
<
aruco
::
DetectorParameters
>
&
params
)
{
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
if
(
!
fs
.
isOpened
())
if
(
!
fs
.
isOpened
())
return
false
;
return
false
;
fs
[
"adaptiveThreshWinSizeMin"
]
>>
params
.
adaptiveThreshWinSizeMin
;
fs
[
"adaptiveThreshWinSizeMin"
]
>>
params
->
adaptiveThreshWinSizeMin
;
fs
[
"adaptiveThreshWinSizeMax"
]
>>
params
.
adaptiveThreshWinSizeMax
;
fs
[
"adaptiveThreshWinSizeMax"
]
>>
params
->
adaptiveThreshWinSizeMax
;
fs
[
"adaptiveThreshWinSizeStep"
]
>>
params
.
adaptiveThreshWinSizeStep
;
fs
[
"adaptiveThreshWinSizeStep"
]
>>
params
->
adaptiveThreshWinSizeStep
;
fs
[
"adaptiveThreshConstant"
]
>>
params
.
adaptiveThreshConstant
;
fs
[
"adaptiveThreshConstant"
]
>>
params
->
adaptiveThreshConstant
;
fs
[
"minMarkerPerimeterRate"
]
>>
params
.
minMarkerPerimeterRate
;
fs
[
"minMarkerPerimeterRate"
]
>>
params
->
minMarkerPerimeterRate
;
fs
[
"maxMarkerPerimeterRate"
]
>>
params
.
maxMarkerPerimeterRate
;
fs
[
"maxMarkerPerimeterRate"
]
>>
params
->
maxMarkerPerimeterRate
;
fs
[
"polygonalApproxAccuracyRate"
]
>>
params
.
polygonalApproxAccuracyRate
;
fs
[
"polygonalApproxAccuracyRate"
]
>>
params
->
polygonalApproxAccuracyRate
;
fs
[
"minCornerDistanceRate"
]
>>
params
.
minCornerDistanceRate
;
fs
[
"minCornerDistanceRate"
]
>>
params
->
minCornerDistanceRate
;
fs
[
"minDistanceToBorder"
]
>>
params
.
minDistanceToBorder
;
fs
[
"minDistanceToBorder"
]
>>
params
->
minDistanceToBorder
;
fs
[
"minMarkerDistanceRate"
]
>>
params
.
minMarkerDistanceRate
;
fs
[
"minMarkerDistanceRate"
]
>>
params
->
minMarkerDistanceRate
;
fs
[
"doCornerRefinement"
]
>>
params
.
doCornerRefinement
;
fs
[
"doCornerRefinement"
]
>>
params
->
doCornerRefinement
;
fs
[
"cornerRefinementWinSize"
]
>>
params
.
cornerRefinementWinSize
;
fs
[
"cornerRefinementWinSize"
]
>>
params
->
cornerRefinementWinSize
;
fs
[
"cornerRefinementMaxIterations"
]
>>
params
.
cornerRefinementMaxIterations
;
fs
[
"cornerRefinementMaxIterations"
]
>>
params
->
cornerRefinementMaxIterations
;
fs
[
"cornerRefinementMinAccuracy"
]
>>
params
.
cornerRefinementMinAccuracy
;
fs
[
"cornerRefinementMinAccuracy"
]
>>
params
->
cornerRefinementMinAccuracy
;
fs
[
"markerBorderBits"
]
>>
params
.
markerBorderBits
;
fs
[
"markerBorderBits"
]
>>
params
->
markerBorderBits
;
fs
[
"perspectiveRemovePixelPerCell"
]
>>
params
.
perspectiveRemovePixelPerCell
;
fs
[
"perspectiveRemovePixelPerCell"
]
>>
params
->
perspectiveRemovePixelPerCell
;
fs
[
"perspectiveRemoveIgnoredMarginPerCell"
]
>>
params
.
perspectiveRemoveIgnoredMarginPerCell
;
fs
[
"perspectiveRemoveIgnoredMarginPerCell"
]
>>
params
->
perspectiveRemoveIgnoredMarginPerCell
;
fs
[
"maxErroneousBitsInBorderRate"
]
>>
params
.
maxErroneousBitsInBorderRate
;
fs
[
"maxErroneousBitsInBorderRate"
]
>>
params
->
maxErroneousBitsInBorderRate
;
fs
[
"minOtsuStdDev"
]
>>
params
.
minOtsuStdDev
;
fs
[
"minOtsuStdDev"
]
>>
params
->
minOtsuStdDev
;
fs
[
"errorCorrectionRate"
]
>>
params
.
errorCorrectionRate
;
fs
[
"errorCorrectionRate"
]
>>
params
->
errorCorrectionRate
;
return
true
;
return
true
;
}
}
...
@@ -173,7 +173,7 @@ int main(int argc, char *argv[]) {
...
@@ -173,7 +173,7 @@ int main(int argc, char *argv[]) {
if
(
parser
.
get
<
bool
>
(
"zt"
))
calibrationFlags
|=
CALIB_ZERO_TANGENT_DIST
;
if
(
parser
.
get
<
bool
>
(
"zt"
))
calibrationFlags
|=
CALIB_ZERO_TANGENT_DIST
;
if
(
parser
.
get
<
bool
>
(
"pc"
))
calibrationFlags
|=
CALIB_FIX_PRINCIPAL_POINT
;
if
(
parser
.
get
<
bool
>
(
"pc"
))
calibrationFlags
|=
CALIB_FIX_PRINCIPAL_POINT
;
aruco
::
DetectorParameters
detectorParams
;
Ptr
<
aruco
::
DetectorParameters
>
detectorParams
=
aruco
::
DetectorParameters
::
create
()
;
if
(
parser
.
has
(
"dp"
))
{
if
(
parser
.
has
(
"dp"
))
{
bool
readOk
=
readDetectorParameters
(
parser
.
get
<
string
>
(
"dp"
),
detectorParams
);
bool
readOk
=
readDetectorParameters
(
parser
.
get
<
string
>
(
"dp"
),
detectorParams
);
if
(
!
readOk
)
{
if
(
!
readOk
)
{
...
@@ -205,12 +205,13 @@ int main(int argc, char *argv[]) {
...
@@ -205,12 +205,13 @@ int main(int argc, char *argv[]) {
waitTime
=
10
;
waitTime
=
10
;
}
}
aruco
::
Dictionary
dictionary
=
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
// create board object
// create board object
aruco
::
GridBoard
board
=
Ptr
<
aruco
::
GridBoard
>
grid
board
=
aruco
::
GridBoard
::
create
(
markersX
,
markersY
,
markerLength
,
markerSeparation
,
dictionary
);
aruco
::
GridBoard
::
create
(
markersX
,
markersY
,
markerLength
,
markerSeparation
,
dictionary
);
Ptr
<
aruco
::
Board
>
board
=
gridboard
.
staticCast
<
aruco
::
Board
>
();
// collected frames for calibration
// collected frames for calibration
vector
<
vector
<
vector
<
Point2f
>
>
>
allCorners
;
vector
<
vector
<
vector
<
Point2f
>
>
>
allCorners
;
...
...
modules/aruco/samples/calibrate_camera_charuco.cpp
View file @
063c191d
...
@@ -76,30 +76,30 @@ const char* keys =
...
@@ -76,30 +76,30 @@ const char* keys =
/**
/**
*/
*/
static
bool
readDetectorParameters
(
string
filename
,
aruco
::
DetectorParameters
&
params
)
{
static
bool
readDetectorParameters
(
string
filename
,
Ptr
<
aruco
::
DetectorParameters
>
&
params
)
{
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
if
(
!
fs
.
isOpened
())
if
(
!
fs
.
isOpened
())
return
false
;
return
false
;
fs
[
"adaptiveThreshWinSizeMin"
]
>>
params
.
adaptiveThreshWinSizeMin
;
fs
[
"adaptiveThreshWinSizeMin"
]
>>
params
->
adaptiveThreshWinSizeMin
;
fs
[
"adaptiveThreshWinSizeMax"
]
>>
params
.
adaptiveThreshWinSizeMax
;
fs
[
"adaptiveThreshWinSizeMax"
]
>>
params
->
adaptiveThreshWinSizeMax
;
fs
[
"adaptiveThreshWinSizeStep"
]
>>
params
.
adaptiveThreshWinSizeStep
;
fs
[
"adaptiveThreshWinSizeStep"
]
>>
params
->
adaptiveThreshWinSizeStep
;
fs
[
"adaptiveThreshConstant"
]
>>
params
.
adaptiveThreshConstant
;
fs
[
"adaptiveThreshConstant"
]
>>
params
->
adaptiveThreshConstant
;
fs
[
"minMarkerPerimeterRate"
]
>>
params
.
minMarkerPerimeterRate
;
fs
[
"minMarkerPerimeterRate"
]
>>
params
->
minMarkerPerimeterRate
;
fs
[
"maxMarkerPerimeterRate"
]
>>
params
.
maxMarkerPerimeterRate
;
fs
[
"maxMarkerPerimeterRate"
]
>>
params
->
maxMarkerPerimeterRate
;
fs
[
"polygonalApproxAccuracyRate"
]
>>
params
.
polygonalApproxAccuracyRate
;
fs
[
"polygonalApproxAccuracyRate"
]
>>
params
->
polygonalApproxAccuracyRate
;
fs
[
"minCornerDistanceRate"
]
>>
params
.
minCornerDistanceRate
;
fs
[
"minCornerDistanceRate"
]
>>
params
->
minCornerDistanceRate
;
fs
[
"minDistanceToBorder"
]
>>
params
.
minDistanceToBorder
;
fs
[
"minDistanceToBorder"
]
>>
params
->
minDistanceToBorder
;
fs
[
"minMarkerDistanceRate"
]
>>
params
.
minMarkerDistanceRate
;
fs
[
"minMarkerDistanceRate"
]
>>
params
->
minMarkerDistanceRate
;
fs
[
"doCornerRefinement"
]
>>
params
.
doCornerRefinement
;
fs
[
"doCornerRefinement"
]
>>
params
->
doCornerRefinement
;
fs
[
"cornerRefinementWinSize"
]
>>
params
.
cornerRefinementWinSize
;
fs
[
"cornerRefinementWinSize"
]
>>
params
->
cornerRefinementWinSize
;
fs
[
"cornerRefinementMaxIterations"
]
>>
params
.
cornerRefinementMaxIterations
;
fs
[
"cornerRefinementMaxIterations"
]
>>
params
->
cornerRefinementMaxIterations
;
fs
[
"cornerRefinementMinAccuracy"
]
>>
params
.
cornerRefinementMinAccuracy
;
fs
[
"cornerRefinementMinAccuracy"
]
>>
params
->
cornerRefinementMinAccuracy
;
fs
[
"markerBorderBits"
]
>>
params
.
markerBorderBits
;
fs
[
"markerBorderBits"
]
>>
params
->
markerBorderBits
;
fs
[
"perspectiveRemovePixelPerCell"
]
>>
params
.
perspectiveRemovePixelPerCell
;
fs
[
"perspectiveRemovePixelPerCell"
]
>>
params
->
perspectiveRemovePixelPerCell
;
fs
[
"perspectiveRemoveIgnoredMarginPerCell"
]
>>
params
.
perspectiveRemoveIgnoredMarginPerCell
;
fs
[
"perspectiveRemoveIgnoredMarginPerCell"
]
>>
params
->
perspectiveRemoveIgnoredMarginPerCell
;
fs
[
"maxErroneousBitsInBorderRate"
]
>>
params
.
maxErroneousBitsInBorderRate
;
fs
[
"maxErroneousBitsInBorderRate"
]
>>
params
->
maxErroneousBitsInBorderRate
;
fs
[
"minOtsuStdDev"
]
>>
params
.
minOtsuStdDev
;
fs
[
"minOtsuStdDev"
]
>>
params
->
minOtsuStdDev
;
fs
[
"errorCorrectionRate"
]
>>
params
.
errorCorrectionRate
;
fs
[
"errorCorrectionRate"
]
>>
params
->
errorCorrectionRate
;
return
true
;
return
true
;
}
}
...
@@ -175,7 +175,7 @@ int main(int argc, char *argv[]) {
...
@@ -175,7 +175,7 @@ int main(int argc, char *argv[]) {
if
(
parser
.
get
<
bool
>
(
"zt"
))
calibrationFlags
|=
CALIB_ZERO_TANGENT_DIST
;
if
(
parser
.
get
<
bool
>
(
"zt"
))
calibrationFlags
|=
CALIB_ZERO_TANGENT_DIST
;
if
(
parser
.
get
<
bool
>
(
"pc"
))
calibrationFlags
|=
CALIB_FIX_PRINCIPAL_POINT
;
if
(
parser
.
get
<
bool
>
(
"pc"
))
calibrationFlags
|=
CALIB_FIX_PRINCIPAL_POINT
;
aruco
::
DetectorParameters
detectorParams
;
Ptr
<
aruco
::
DetectorParameters
>
detectorParams
=
aruco
::
DetectorParameters
::
create
()
;
if
(
parser
.
has
(
"dp"
))
{
if
(
parser
.
has
(
"dp"
))
{
bool
readOk
=
readDetectorParameters
(
parser
.
get
<
string
>
(
"dp"
),
detectorParams
);
bool
readOk
=
readDetectorParameters
(
parser
.
get
<
string
>
(
"dp"
),
detectorParams
);
if
(
!
readOk
)
{
if
(
!
readOk
)
{
...
@@ -207,12 +207,13 @@ int main(int argc, char *argv[]) {
...
@@ -207,12 +207,13 @@ int main(int argc, char *argv[]) {
waitTime
=
10
;
waitTime
=
10
;
}
}
aruco
::
Dictionary
dictionary
=
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
// create charuco board object
// create charuco board object
aruco
::
CharucoBoard
board
=
Ptr
<
aruco
::
CharucoBoard
>
charuco
board
=
aruco
::
CharucoBoard
::
create
(
squaresX
,
squaresY
,
squareLength
,
markerLength
,
dictionary
);
aruco
::
CharucoBoard
::
create
(
squaresX
,
squaresY
,
squareLength
,
markerLength
,
dictionary
);
Ptr
<
aruco
::
Board
>
board
=
charucoboard
.
staticCast
<
aruco
::
Board
>
();
// collect data from each frame
// collect data from each frame
vector
<
vector
<
vector
<
Point2f
>
>
>
allCorners
;
vector
<
vector
<
vector
<
Point2f
>
>
>
allCorners
;
...
@@ -236,7 +237,7 @@ int main(int argc, char *argv[]) {
...
@@ -236,7 +237,7 @@ int main(int argc, char *argv[]) {
// interpolate charuco corners
// interpolate charuco corners
Mat
currentCharucoCorners
,
currentCharucoIds
;
Mat
currentCharucoCorners
,
currentCharucoIds
;
if
(
ids
.
size
()
>
0
)
if
(
ids
.
size
()
>
0
)
aruco
::
interpolateCornersCharuco
(
corners
,
ids
,
image
,
board
,
currentCharucoCorners
,
aruco
::
interpolateCornersCharuco
(
corners
,
ids
,
image
,
charuco
board
,
currentCharucoCorners
,
currentCharucoIds
);
currentCharucoIds
);
// draw results
// draw results
...
@@ -305,7 +306,7 @@ int main(int argc, char *argv[]) {
...
@@ -305,7 +306,7 @@ int main(int argc, char *argv[]) {
for
(
int
i
=
0
;
i
<
nFrames
;
i
++
)
{
for
(
int
i
=
0
;
i
<
nFrames
;
i
++
)
{
// interpolate using camera parameters
// interpolate using camera parameters
Mat
currentCharucoCorners
,
currentCharucoIds
;
Mat
currentCharucoCorners
,
currentCharucoIds
;
aruco
::
interpolateCornersCharuco
(
allCorners
[
i
],
allIds
[
i
],
allImgs
[
i
],
board
,
aruco
::
interpolateCornersCharuco
(
allCorners
[
i
],
allIds
[
i
],
allImgs
[
i
],
charuco
board
,
currentCharucoCorners
,
currentCharucoIds
,
cameraMatrix
,
currentCharucoCorners
,
currentCharucoIds
,
cameraMatrix
,
distCoeffs
);
distCoeffs
);
...
@@ -321,7 +322,7 @@ int main(int argc, char *argv[]) {
...
@@ -321,7 +322,7 @@ int main(int argc, char *argv[]) {
// calibrate camera using charuco
// calibrate camera using charuco
repError
=
repError
=
aruco
::
calibrateCameraCharuco
(
allCharucoCorners
,
allCharucoIds
,
board
,
imgSize
,
aruco
::
calibrateCameraCharuco
(
allCharucoCorners
,
allCharucoIds
,
charuco
board
,
imgSize
,
cameraMatrix
,
distCoeffs
,
rvecs
,
tvecs
,
calibrationFlags
);
cameraMatrix
,
distCoeffs
,
rvecs
,
tvecs
,
calibrationFlags
);
bool
saveOk
=
saveCameraParams
(
outputFile
,
imgSize
,
aspectRatio
,
calibrationFlags
,
bool
saveOk
=
saveCameraParams
(
outputFile
,
imgSize
,
aspectRatio
,
calibrationFlags
,
...
...
modules/aruco/samples/create_board.cpp
View file @
063c191d
...
@@ -93,15 +93,15 @@ int main(int argc, char *argv[]) {
...
@@ -93,15 +93,15 @@ int main(int argc, char *argv[]) {
imageSize
.
height
=
imageSize
.
height
=
markersY
*
(
markerLength
+
markerSeparation
)
-
markerSeparation
+
2
*
margins
;
markersY
*
(
markerLength
+
markerSeparation
)
-
markerSeparation
+
2
*
margins
;
aruco
::
Dictionary
dictionary
=
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
aruco
::
GridBoard
board
=
aruco
::
GridBoard
::
create
(
markersX
,
markersY
,
float
(
markerLength
),
Ptr
<
aruco
::
GridBoard
>
board
=
aruco
::
GridBoard
::
create
(
markersX
,
markersY
,
float
(
markerLength
),
float
(
markerSeparation
),
dictionary
);
float
(
markerSeparation
),
dictionary
);
// show created board
// show created board
Mat
boardImage
;
Mat
boardImage
;
board
.
draw
(
imageSize
,
boardImage
,
margins
,
borderBits
);
board
->
draw
(
imageSize
,
boardImage
,
margins
,
borderBits
);
if
(
showImage
)
{
if
(
showImage
)
{
imshow
(
"board"
,
boardImage
);
imshow
(
"board"
,
boardImage
);
...
...
modules/aruco/samples/create_board_charuco.cpp
View file @
063c191d
...
@@ -88,19 +88,19 @@ int main(int argc, char *argv[]) {
...
@@ -88,19 +88,19 @@ int main(int argc, char *argv[]) {
return
0
;
return
0
;
}
}
aruco
::
Dictionary
dictionary
=
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
Size
imageSize
;
Size
imageSize
;
imageSize
.
width
=
squaresX
*
squareLength
+
2
*
margins
;
imageSize
.
width
=
squaresX
*
squareLength
+
2
*
margins
;
imageSize
.
height
=
squaresY
*
squareLength
+
2
*
margins
;
imageSize
.
height
=
squaresY
*
squareLength
+
2
*
margins
;
aruco
::
CharucoBoard
board
=
aruco
::
CharucoBoard
::
create
(
squaresX
,
squaresY
,
(
float
)
squareLength
,
Ptr
<
aruco
::
CharucoBoard
>
board
=
aruco
::
CharucoBoard
::
create
(
squaresX
,
squaresY
,
(
float
)
squareLength
,
(
float
)
markerLength
,
dictionary
);
(
float
)
markerLength
,
dictionary
);
// show created board
// show created board
Mat
boardImage
;
Mat
boardImage
;
board
.
draw
(
imageSize
,
boardImage
,
margins
,
borderBits
);
board
->
draw
(
imageSize
,
boardImage
,
margins
,
borderBits
);
if
(
showImage
)
{
if
(
showImage
)
{
imshow
(
"board"
,
boardImage
);
imshow
(
"board"
,
boardImage
);
...
...
modules/aruco/samples/create_diamond.cpp
View file @
063c191d
...
@@ -86,7 +86,7 @@ int main(int argc, char *argv[]) {
...
@@ -86,7 +86,7 @@ int main(int argc, char *argv[]) {
return
0
;
return
0
;
}
}
aruco
::
Dictionary
dictionary
=
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
istringstream
ss
(
idsString
);
istringstream
ss
(
idsString
);
...
...
modules/aruco/samples/create_marker.cpp
View file @
063c191d
...
@@ -79,7 +79,7 @@ int main(int argc, char *argv[]) {
...
@@ -79,7 +79,7 @@ int main(int argc, char *argv[]) {
return
0
;
return
0
;
}
}
aruco
::
Dictionary
dictionary
=
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
Mat
markerImg
;
Mat
markerImg
;
...
...
modules/aruco/samples/detect_board.cpp
View file @
063c191d
...
@@ -79,30 +79,30 @@ static bool readCameraParameters(string filename, Mat &camMatrix, Mat &distCoeff
...
@@ -79,30 +79,30 @@ static bool readCameraParameters(string filename, Mat &camMatrix, Mat &distCoeff
/**
/**
*/
*/
static
bool
readDetectorParameters
(
string
filename
,
aruco
::
DetectorParameters
&
params
)
{
static
bool
readDetectorParameters
(
string
filename
,
Ptr
<
aruco
::
DetectorParameters
>
&
params
)
{
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
if
(
!
fs
.
isOpened
())
if
(
!
fs
.
isOpened
())
return
false
;
return
false
;
fs
[
"adaptiveThreshWinSizeMin"
]
>>
params
.
adaptiveThreshWinSizeMin
;
fs
[
"adaptiveThreshWinSizeMin"
]
>>
params
->
adaptiveThreshWinSizeMin
;
fs
[
"adaptiveThreshWinSizeMax"
]
>>
params
.
adaptiveThreshWinSizeMax
;
fs
[
"adaptiveThreshWinSizeMax"
]
>>
params
->
adaptiveThreshWinSizeMax
;
fs
[
"adaptiveThreshWinSizeStep"
]
>>
params
.
adaptiveThreshWinSizeStep
;
fs
[
"adaptiveThreshWinSizeStep"
]
>>
params
->
adaptiveThreshWinSizeStep
;
fs
[
"adaptiveThreshConstant"
]
>>
params
.
adaptiveThreshConstant
;
fs
[
"adaptiveThreshConstant"
]
>>
params
->
adaptiveThreshConstant
;
fs
[
"minMarkerPerimeterRate"
]
>>
params
.
minMarkerPerimeterRate
;
fs
[
"minMarkerPerimeterRate"
]
>>
params
->
minMarkerPerimeterRate
;
fs
[
"maxMarkerPerimeterRate"
]
>>
params
.
maxMarkerPerimeterRate
;
fs
[
"maxMarkerPerimeterRate"
]
>>
params
->
maxMarkerPerimeterRate
;
fs
[
"polygonalApproxAccuracyRate"
]
>>
params
.
polygonalApproxAccuracyRate
;
fs
[
"polygonalApproxAccuracyRate"
]
>>
params
->
polygonalApproxAccuracyRate
;
fs
[
"minCornerDistanceRate"
]
>>
params
.
minCornerDistanceRate
;
fs
[
"minCornerDistanceRate"
]
>>
params
->
minCornerDistanceRate
;
fs
[
"minDistanceToBorder"
]
>>
params
.
minDistanceToBorder
;
fs
[
"minDistanceToBorder"
]
>>
params
->
minDistanceToBorder
;
fs
[
"minMarkerDistanceRate"
]
>>
params
.
minMarkerDistanceRate
;
fs
[
"minMarkerDistanceRate"
]
>>
params
->
minMarkerDistanceRate
;
fs
[
"doCornerRefinement"
]
>>
params
.
doCornerRefinement
;
fs
[
"doCornerRefinement"
]
>>
params
->
doCornerRefinement
;
fs
[
"cornerRefinementWinSize"
]
>>
params
.
cornerRefinementWinSize
;
fs
[
"cornerRefinementWinSize"
]
>>
params
->
cornerRefinementWinSize
;
fs
[
"cornerRefinementMaxIterations"
]
>>
params
.
cornerRefinementMaxIterations
;
fs
[
"cornerRefinementMaxIterations"
]
>>
params
->
cornerRefinementMaxIterations
;
fs
[
"cornerRefinementMinAccuracy"
]
>>
params
.
cornerRefinementMinAccuracy
;
fs
[
"cornerRefinementMinAccuracy"
]
>>
params
->
cornerRefinementMinAccuracy
;
fs
[
"markerBorderBits"
]
>>
params
.
markerBorderBits
;
fs
[
"markerBorderBits"
]
>>
params
->
markerBorderBits
;
fs
[
"perspectiveRemovePixelPerCell"
]
>>
params
.
perspectiveRemovePixelPerCell
;
fs
[
"perspectiveRemovePixelPerCell"
]
>>
params
->
perspectiveRemovePixelPerCell
;
fs
[
"perspectiveRemoveIgnoredMarginPerCell"
]
>>
params
.
perspectiveRemoveIgnoredMarginPerCell
;
fs
[
"perspectiveRemoveIgnoredMarginPerCell"
]
>>
params
->
perspectiveRemoveIgnoredMarginPerCell
;
fs
[
"maxErroneousBitsInBorderRate"
]
>>
params
.
maxErroneousBitsInBorderRate
;
fs
[
"maxErroneousBitsInBorderRate"
]
>>
params
->
maxErroneousBitsInBorderRate
;
fs
[
"minOtsuStdDev"
]
>>
params
.
minOtsuStdDev
;
fs
[
"minOtsuStdDev"
]
>>
params
->
minOtsuStdDev
;
fs
[
"errorCorrectionRate"
]
>>
params
.
errorCorrectionRate
;
fs
[
"errorCorrectionRate"
]
>>
params
->
errorCorrectionRate
;
return
true
;
return
true
;
}
}
...
@@ -137,7 +137,7 @@ int main(int argc, char *argv[]) {
...
@@ -137,7 +137,7 @@ int main(int argc, char *argv[]) {
}
}
}
}
aruco
::
DetectorParameters
detectorParams
;
Ptr
<
aruco
::
DetectorParameters
>
detectorParams
=
aruco
::
DetectorParameters
::
create
()
;
if
(
parser
.
has
(
"dp"
))
{
if
(
parser
.
has
(
"dp"
))
{
bool
readOk
=
readDetectorParameters
(
parser
.
get
<
string
>
(
"dp"
),
detectorParams
);
bool
readOk
=
readDetectorParameters
(
parser
.
get
<
string
>
(
"dp"
),
detectorParams
);
if
(
!
readOk
)
{
if
(
!
readOk
)
{
...
@@ -145,7 +145,7 @@ int main(int argc, char *argv[]) {
...
@@ -145,7 +145,7 @@ int main(int argc, char *argv[]) {
return
0
;
return
0
;
}
}
}
}
detectorParams
.
doCornerRefinement
=
true
;
// do corner refinement in markers
detectorParams
->
doCornerRefinement
=
true
;
// do corner refinement in markers
String
video
;
String
video
;
if
(
parser
.
has
(
"v"
))
{
if
(
parser
.
has
(
"v"
))
{
...
@@ -157,7 +157,7 @@ int main(int argc, char *argv[]) {
...
@@ -157,7 +157,7 @@ int main(int argc, char *argv[]) {
return
0
;
return
0
;
}
}
aruco
::
Dictionary
dictionary
=
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
VideoCapture
inputVideo
;
VideoCapture
inputVideo
;
...
@@ -174,8 +174,9 @@ int main(int argc, char *argv[]) {
...
@@ -174,8 +174,9 @@ int main(int argc, char *argv[]) {
markerSeparation
);
markerSeparation
);
// create board object
// create board object
aruco
::
GridBoard
board
=
Ptr
<
aruco
::
GridBoard
>
grid
board
=
aruco
::
GridBoard
::
create
(
markersX
,
markersY
,
markerLength
,
markerSeparation
,
dictionary
);
aruco
::
GridBoard
::
create
(
markersX
,
markersY
,
markerLength
,
markerSeparation
,
dictionary
);
Ptr
<
aruco
::
Board
>
board
=
gridboard
.
staticCast
<
aruco
::
Board
>
();
double
totalTime
=
0
;
double
totalTime
=
0
;
int
totalIterations
=
0
;
int
totalIterations
=
0
;
...
...
modules/aruco/samples/detect_board_charuco.cpp
View file @
063c191d
...
@@ -79,30 +79,30 @@ static bool readCameraParameters(string filename, Mat &camMatrix, Mat &distCoeff
...
@@ -79,30 +79,30 @@ static bool readCameraParameters(string filename, Mat &camMatrix, Mat &distCoeff
/**
/**
*/
*/
static
bool
readDetectorParameters
(
string
filename
,
aruco
::
DetectorParameters
&
params
)
{
static
bool
readDetectorParameters
(
string
filename
,
Ptr
<
aruco
::
DetectorParameters
>
&
params
)
{
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
if
(
!
fs
.
isOpened
())
if
(
!
fs
.
isOpened
())
return
false
;
return
false
;
fs
[
"adaptiveThreshWinSizeMin"
]
>>
params
.
adaptiveThreshWinSizeMin
;
fs
[
"adaptiveThreshWinSizeMin"
]
>>
params
->
adaptiveThreshWinSizeMin
;
fs
[
"adaptiveThreshWinSizeMax"
]
>>
params
.
adaptiveThreshWinSizeMax
;
fs
[
"adaptiveThreshWinSizeMax"
]
>>
params
->
adaptiveThreshWinSizeMax
;
fs
[
"adaptiveThreshWinSizeStep"
]
>>
params
.
adaptiveThreshWinSizeStep
;
fs
[
"adaptiveThreshWinSizeStep"
]
>>
params
->
adaptiveThreshWinSizeStep
;
fs
[
"adaptiveThreshConstant"
]
>>
params
.
adaptiveThreshConstant
;
fs
[
"adaptiveThreshConstant"
]
>>
params
->
adaptiveThreshConstant
;
fs
[
"minMarkerPerimeterRate"
]
>>
params
.
minMarkerPerimeterRate
;
fs
[
"minMarkerPerimeterRate"
]
>>
params
->
minMarkerPerimeterRate
;
fs
[
"maxMarkerPerimeterRate"
]
>>
params
.
maxMarkerPerimeterRate
;
fs
[
"maxMarkerPerimeterRate"
]
>>
params
->
maxMarkerPerimeterRate
;
fs
[
"polygonalApproxAccuracyRate"
]
>>
params
.
polygonalApproxAccuracyRate
;
fs
[
"polygonalApproxAccuracyRate"
]
>>
params
->
polygonalApproxAccuracyRate
;
fs
[
"minCornerDistanceRate"
]
>>
params
.
minCornerDistanceRate
;
fs
[
"minCornerDistanceRate"
]
>>
params
->
minCornerDistanceRate
;
fs
[
"minDistanceToBorder"
]
>>
params
.
minDistanceToBorder
;
fs
[
"minDistanceToBorder"
]
>>
params
->
minDistanceToBorder
;
fs
[
"minMarkerDistanceRate"
]
>>
params
.
minMarkerDistanceRate
;
fs
[
"minMarkerDistanceRate"
]
>>
params
->
minMarkerDistanceRate
;
fs
[
"doCornerRefinement"
]
>>
params
.
doCornerRefinement
;
fs
[
"doCornerRefinement"
]
>>
params
->
doCornerRefinement
;
fs
[
"cornerRefinementWinSize"
]
>>
params
.
cornerRefinementWinSize
;
fs
[
"cornerRefinementWinSize"
]
>>
params
->
cornerRefinementWinSize
;
fs
[
"cornerRefinementMaxIterations"
]
>>
params
.
cornerRefinementMaxIterations
;
fs
[
"cornerRefinementMaxIterations"
]
>>
params
->
cornerRefinementMaxIterations
;
fs
[
"cornerRefinementMinAccuracy"
]
>>
params
.
cornerRefinementMinAccuracy
;
fs
[
"cornerRefinementMinAccuracy"
]
>>
params
->
cornerRefinementMinAccuracy
;
fs
[
"markerBorderBits"
]
>>
params
.
markerBorderBits
;
fs
[
"markerBorderBits"
]
>>
params
->
markerBorderBits
;
fs
[
"perspectiveRemovePixelPerCell"
]
>>
params
.
perspectiveRemovePixelPerCell
;
fs
[
"perspectiveRemovePixelPerCell"
]
>>
params
->
perspectiveRemovePixelPerCell
;
fs
[
"perspectiveRemoveIgnoredMarginPerCell"
]
>>
params
.
perspectiveRemoveIgnoredMarginPerCell
;
fs
[
"perspectiveRemoveIgnoredMarginPerCell"
]
>>
params
->
perspectiveRemoveIgnoredMarginPerCell
;
fs
[
"maxErroneousBitsInBorderRate"
]
>>
params
.
maxErroneousBitsInBorderRate
;
fs
[
"maxErroneousBitsInBorderRate"
]
>>
params
->
maxErroneousBitsInBorderRate
;
fs
[
"minOtsuStdDev"
]
>>
params
.
minOtsuStdDev
;
fs
[
"minOtsuStdDev"
]
>>
params
->
minOtsuStdDev
;
fs
[
"errorCorrectionRate"
]
>>
params
.
errorCorrectionRate
;
fs
[
"errorCorrectionRate"
]
>>
params
->
errorCorrectionRate
;
return
true
;
return
true
;
}
}
...
@@ -141,7 +141,7 @@ int main(int argc, char *argv[]) {
...
@@ -141,7 +141,7 @@ int main(int argc, char *argv[]) {
}
}
}
}
aruco
::
DetectorParameters
detectorParams
;
Ptr
<
aruco
::
DetectorParameters
>
detectorParams
=
aruco
::
DetectorParameters
::
create
()
;
if
(
parser
.
has
(
"dp"
))
{
if
(
parser
.
has
(
"dp"
))
{
bool
readOk
=
readDetectorParameters
(
parser
.
get
<
string
>
(
"dp"
),
detectorParams
);
bool
readOk
=
readDetectorParameters
(
parser
.
get
<
string
>
(
"dp"
),
detectorParams
);
if
(
!
readOk
)
{
if
(
!
readOk
)
{
...
@@ -155,7 +155,7 @@ int main(int argc, char *argv[]) {
...
@@ -155,7 +155,7 @@ int main(int argc, char *argv[]) {
return
0
;
return
0
;
}
}
aruco
::
Dictionary
dictionary
=
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
VideoCapture
inputVideo
;
VideoCapture
inputVideo
;
...
@@ -171,8 +171,9 @@ int main(int argc, char *argv[]) {
...
@@ -171,8 +171,9 @@ int main(int argc, char *argv[]) {
float
axisLength
=
0.5
f
*
((
float
)
min
(
squaresX
,
squaresY
)
*
(
squareLength
));
float
axisLength
=
0.5
f
*
((
float
)
min
(
squaresX
,
squaresY
)
*
(
squareLength
));
// create charuco board object
// create charuco board object
aruco
::
CharucoBoard
board
=
Ptr
<
aruco
::
CharucoBoard
>
charuco
board
=
aruco
::
CharucoBoard
::
create
(
squaresX
,
squaresY
,
squareLength
,
markerLength
,
dictionary
);
aruco
::
CharucoBoard
::
create
(
squaresX
,
squaresY
,
squareLength
,
markerLength
,
dictionary
);
Ptr
<
aruco
::
Board
>
board
=
charucoboard
.
staticCast
<
aruco
::
Board
>
();
double
totalTime
=
0
;
double
totalTime
=
0
;
int
totalIterations
=
0
;
int
totalIterations
=
0
;
...
@@ -201,13 +202,13 @@ int main(int argc, char *argv[]) {
...
@@ -201,13 +202,13 @@ int main(int argc, char *argv[]) {
int
interpolatedCorners
=
0
;
int
interpolatedCorners
=
0
;
if
(
markerIds
.
size
()
>
0
)
if
(
markerIds
.
size
()
>
0
)
interpolatedCorners
=
interpolatedCorners
=
aruco
::
interpolateCornersCharuco
(
markerCorners
,
markerIds
,
image
,
board
,
aruco
::
interpolateCornersCharuco
(
markerCorners
,
markerIds
,
image
,
charuco
board
,
charucoCorners
,
charucoIds
,
camMatrix
,
distCoeffs
);
charucoCorners
,
charucoIds
,
camMatrix
,
distCoeffs
);
// estimate charuco board pose
// estimate charuco board pose
bool
validPose
=
false
;
bool
validPose
=
false
;
if
(
camMatrix
.
total
()
!=
0
)
if
(
camMatrix
.
total
()
!=
0
)
validPose
=
aruco
::
estimatePoseCharucoBoard
(
charucoCorners
,
charucoIds
,
board
,
validPose
=
aruco
::
estimatePoseCharucoBoard
(
charucoCorners
,
charucoIds
,
charuco
board
,
camMatrix
,
distCoeffs
,
rvec
,
tvec
);
camMatrix
,
distCoeffs
,
rvec
,
tvec
);
...
...
modules/aruco/samples/detect_diamonds.cpp
View file @
063c191d
...
@@ -80,30 +80,30 @@ static bool readCameraParameters(string filename, Mat &camMatrix, Mat &distCoeff
...
@@ -80,30 +80,30 @@ static bool readCameraParameters(string filename, Mat &camMatrix, Mat &distCoeff
/**
/**
*/
*/
static
bool
readDetectorParameters
(
string
filename
,
aruco
::
DetectorParameters
&
params
)
{
static
bool
readDetectorParameters
(
string
filename
,
Ptr
<
aruco
::
DetectorParameters
>
&
params
)
{
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
if
(
!
fs
.
isOpened
())
if
(
!
fs
.
isOpened
())
return
false
;
return
false
;
fs
[
"adaptiveThreshWinSizeMin"
]
>>
params
.
adaptiveThreshWinSizeMin
;
fs
[
"adaptiveThreshWinSizeMin"
]
>>
params
->
adaptiveThreshWinSizeMin
;
fs
[
"adaptiveThreshWinSizeMax"
]
>>
params
.
adaptiveThreshWinSizeMax
;
fs
[
"adaptiveThreshWinSizeMax"
]
>>
params
->
adaptiveThreshWinSizeMax
;
fs
[
"adaptiveThreshWinSizeStep"
]
>>
params
.
adaptiveThreshWinSizeStep
;
fs
[
"adaptiveThreshWinSizeStep"
]
>>
params
->
adaptiveThreshWinSizeStep
;
fs
[
"adaptiveThreshConstant"
]
>>
params
.
adaptiveThreshConstant
;
fs
[
"adaptiveThreshConstant"
]
>>
params
->
adaptiveThreshConstant
;
fs
[
"minMarkerPerimeterRate"
]
>>
params
.
minMarkerPerimeterRate
;
fs
[
"minMarkerPerimeterRate"
]
>>
params
->
minMarkerPerimeterRate
;
fs
[
"maxMarkerPerimeterRate"
]
>>
params
.
maxMarkerPerimeterRate
;
fs
[
"maxMarkerPerimeterRate"
]
>>
params
->
maxMarkerPerimeterRate
;
fs
[
"polygonalApproxAccuracyRate"
]
>>
params
.
polygonalApproxAccuracyRate
;
fs
[
"polygonalApproxAccuracyRate"
]
>>
params
->
polygonalApproxAccuracyRate
;
fs
[
"minCornerDistanceRate"
]
>>
params
.
minCornerDistanceRate
;
fs
[
"minCornerDistanceRate"
]
>>
params
->
minCornerDistanceRate
;
fs
[
"minDistanceToBorder"
]
>>
params
.
minDistanceToBorder
;
fs
[
"minDistanceToBorder"
]
>>
params
->
minDistanceToBorder
;
fs
[
"minMarkerDistanceRate"
]
>>
params
.
minMarkerDistanceRate
;
fs
[
"minMarkerDistanceRate"
]
>>
params
->
minMarkerDistanceRate
;
fs
[
"doCornerRefinement"
]
>>
params
.
doCornerRefinement
;
fs
[
"doCornerRefinement"
]
>>
params
->
doCornerRefinement
;
fs
[
"cornerRefinementWinSize"
]
>>
params
.
cornerRefinementWinSize
;
fs
[
"cornerRefinementWinSize"
]
>>
params
->
cornerRefinementWinSize
;
fs
[
"cornerRefinementMaxIterations"
]
>>
params
.
cornerRefinementMaxIterations
;
fs
[
"cornerRefinementMaxIterations"
]
>>
params
->
cornerRefinementMaxIterations
;
fs
[
"cornerRefinementMinAccuracy"
]
>>
params
.
cornerRefinementMinAccuracy
;
fs
[
"cornerRefinementMinAccuracy"
]
>>
params
->
cornerRefinementMinAccuracy
;
fs
[
"markerBorderBits"
]
>>
params
.
markerBorderBits
;
fs
[
"markerBorderBits"
]
>>
params
->
markerBorderBits
;
fs
[
"perspectiveRemovePixelPerCell"
]
>>
params
.
perspectiveRemovePixelPerCell
;
fs
[
"perspectiveRemovePixelPerCell"
]
>>
params
->
perspectiveRemovePixelPerCell
;
fs
[
"perspectiveRemoveIgnoredMarginPerCell"
]
>>
params
.
perspectiveRemoveIgnoredMarginPerCell
;
fs
[
"perspectiveRemoveIgnoredMarginPerCell"
]
>>
params
->
perspectiveRemoveIgnoredMarginPerCell
;
fs
[
"maxErroneousBitsInBorderRate"
]
>>
params
.
maxErroneousBitsInBorderRate
;
fs
[
"maxErroneousBitsInBorderRate"
]
>>
params
->
maxErroneousBitsInBorderRate
;
fs
[
"minOtsuStdDev"
]
>>
params
.
minOtsuStdDev
;
fs
[
"minOtsuStdDev"
]
>>
params
->
minOtsuStdDev
;
fs
[
"errorCorrectionRate"
]
>>
params
.
errorCorrectionRate
;
fs
[
"errorCorrectionRate"
]
>>
params
->
errorCorrectionRate
;
return
true
;
return
true
;
}
}
...
@@ -127,7 +127,7 @@ int main(int argc, char *argv[]) {
...
@@ -127,7 +127,7 @@ int main(int argc, char *argv[]) {
bool
autoScale
=
parser
.
has
(
"as"
);
bool
autoScale
=
parser
.
has
(
"as"
);
float
autoScaleFactor
=
autoScale
?
parser
.
get
<
float
>
(
"as"
)
:
1.
f
;
float
autoScaleFactor
=
autoScale
?
parser
.
get
<
float
>
(
"as"
)
:
1.
f
;
aruco
::
DetectorParameters
detectorParams
;
Ptr
<
aruco
::
DetectorParameters
>
detectorParams
=
aruco
::
DetectorParameters
::
create
()
;
if
(
parser
.
has
(
"dp"
))
{
if
(
parser
.
has
(
"dp"
))
{
bool
readOk
=
readDetectorParameters
(
parser
.
get
<
string
>
(
"dp"
),
detectorParams
);
bool
readOk
=
readDetectorParameters
(
parser
.
get
<
string
>
(
"dp"
),
detectorParams
);
if
(
!
readOk
)
{
if
(
!
readOk
)
{
...
@@ -148,7 +148,7 @@ int main(int argc, char *argv[]) {
...
@@ -148,7 +148,7 @@ int main(int argc, char *argv[]) {
return
0
;
return
0
;
}
}
aruco
::
Dictionary
dictionary
=
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
Mat
camMatrix
,
distCoeffs
;
Mat
camMatrix
,
distCoeffs
;
...
...
modules/aruco/samples/detect_markers.cpp
View file @
063c191d
...
@@ -74,30 +74,30 @@ static bool readCameraParameters(string filename, Mat &camMatrix, Mat &distCoeff
...
@@ -74,30 +74,30 @@ static bool readCameraParameters(string filename, Mat &camMatrix, Mat &distCoeff
/**
/**
*/
*/
static
bool
readDetectorParameters
(
string
filename
,
aruco
::
DetectorParameters
&
params
)
{
static
bool
readDetectorParameters
(
string
filename
,
Ptr
<
aruco
::
DetectorParameters
>
&
params
)
{
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
if
(
!
fs
.
isOpened
())
if
(
!
fs
.
isOpened
())
return
false
;
return
false
;
fs
[
"adaptiveThreshWinSizeMin"
]
>>
params
.
adaptiveThreshWinSizeMin
;
fs
[
"adaptiveThreshWinSizeMin"
]
>>
params
->
adaptiveThreshWinSizeMin
;
fs
[
"adaptiveThreshWinSizeMax"
]
>>
params
.
adaptiveThreshWinSizeMax
;
fs
[
"adaptiveThreshWinSizeMax"
]
>>
params
->
adaptiveThreshWinSizeMax
;
fs
[
"adaptiveThreshWinSizeStep"
]
>>
params
.
adaptiveThreshWinSizeStep
;
fs
[
"adaptiveThreshWinSizeStep"
]
>>
params
->
adaptiveThreshWinSizeStep
;
fs
[
"adaptiveThreshConstant"
]
>>
params
.
adaptiveThreshConstant
;
fs
[
"adaptiveThreshConstant"
]
>>
params
->
adaptiveThreshConstant
;
fs
[
"minMarkerPerimeterRate"
]
>>
params
.
minMarkerPerimeterRate
;
fs
[
"minMarkerPerimeterRate"
]
>>
params
->
minMarkerPerimeterRate
;
fs
[
"maxMarkerPerimeterRate"
]
>>
params
.
maxMarkerPerimeterRate
;
fs
[
"maxMarkerPerimeterRate"
]
>>
params
->
maxMarkerPerimeterRate
;
fs
[
"polygonalApproxAccuracyRate"
]
>>
params
.
polygonalApproxAccuracyRate
;
fs
[
"polygonalApproxAccuracyRate"
]
>>
params
->
polygonalApproxAccuracyRate
;
fs
[
"minCornerDistanceRate"
]
>>
params
.
minCornerDistanceRate
;
fs
[
"minCornerDistanceRate"
]
>>
params
->
minCornerDistanceRate
;
fs
[
"minDistanceToBorder"
]
>>
params
.
minDistanceToBorder
;
fs
[
"minDistanceToBorder"
]
>>
params
->
minDistanceToBorder
;
fs
[
"minMarkerDistanceRate"
]
>>
params
.
minMarkerDistanceRate
;
fs
[
"minMarkerDistanceRate"
]
>>
params
->
minMarkerDistanceRate
;
fs
[
"doCornerRefinement"
]
>>
params
.
doCornerRefinement
;
fs
[
"doCornerRefinement"
]
>>
params
->
doCornerRefinement
;
fs
[
"cornerRefinementWinSize"
]
>>
params
.
cornerRefinementWinSize
;
fs
[
"cornerRefinementWinSize"
]
>>
params
->
cornerRefinementWinSize
;
fs
[
"cornerRefinementMaxIterations"
]
>>
params
.
cornerRefinementMaxIterations
;
fs
[
"cornerRefinementMaxIterations"
]
>>
params
->
cornerRefinementMaxIterations
;
fs
[
"cornerRefinementMinAccuracy"
]
>>
params
.
cornerRefinementMinAccuracy
;
fs
[
"cornerRefinementMinAccuracy"
]
>>
params
->
cornerRefinementMinAccuracy
;
fs
[
"markerBorderBits"
]
>>
params
.
markerBorderBits
;
fs
[
"markerBorderBits"
]
>>
params
->
markerBorderBits
;
fs
[
"perspectiveRemovePixelPerCell"
]
>>
params
.
perspectiveRemovePixelPerCell
;
fs
[
"perspectiveRemovePixelPerCell"
]
>>
params
->
perspectiveRemovePixelPerCell
;
fs
[
"perspectiveRemoveIgnoredMarginPerCell"
]
>>
params
.
perspectiveRemoveIgnoredMarginPerCell
;
fs
[
"perspectiveRemoveIgnoredMarginPerCell"
]
>>
params
->
perspectiveRemoveIgnoredMarginPerCell
;
fs
[
"maxErroneousBitsInBorderRate"
]
>>
params
.
maxErroneousBitsInBorderRate
;
fs
[
"maxErroneousBitsInBorderRate"
]
>>
params
->
maxErroneousBitsInBorderRate
;
fs
[
"minOtsuStdDev"
]
>>
params
.
minOtsuStdDev
;
fs
[
"minOtsuStdDev"
]
>>
params
->
minOtsuStdDev
;
fs
[
"errorCorrectionRate"
]
>>
params
.
errorCorrectionRate
;
fs
[
"errorCorrectionRate"
]
>>
params
->
errorCorrectionRate
;
return
true
;
return
true
;
}
}
...
@@ -119,7 +119,7 @@ int main(int argc, char *argv[]) {
...
@@ -119,7 +119,7 @@ int main(int argc, char *argv[]) {
bool
estimatePose
=
parser
.
has
(
"c"
);
bool
estimatePose
=
parser
.
has
(
"c"
);
float
markerLength
=
parser
.
get
<
float
>
(
"l"
);
float
markerLength
=
parser
.
get
<
float
>
(
"l"
);
aruco
::
DetectorParameters
detectorParams
;
Ptr
<
aruco
::
DetectorParameters
>
detectorParams
=
aruco
::
DetectorParameters
::
create
()
;
if
(
parser
.
has
(
"dp"
))
{
if
(
parser
.
has
(
"dp"
))
{
bool
readOk
=
readDetectorParameters
(
parser
.
get
<
string
>
(
"dp"
),
detectorParams
);
bool
readOk
=
readDetectorParameters
(
parser
.
get
<
string
>
(
"dp"
),
detectorParams
);
if
(
!
readOk
)
{
if
(
!
readOk
)
{
...
@@ -127,7 +127,7 @@ int main(int argc, char *argv[]) {
...
@@ -127,7 +127,7 @@ int main(int argc, char *argv[]) {
return
0
;
return
0
;
}
}
}
}
detectorParams
.
doCornerRefinement
=
true
;
// do corner refinement in markers
detectorParams
->
doCornerRefinement
=
true
;
// do corner refinement in markers
int
camId
=
parser
.
get
<
int
>
(
"ci"
);
int
camId
=
parser
.
get
<
int
>
(
"ci"
);
...
@@ -141,7 +141,7 @@ int main(int argc, char *argv[]) {
...
@@ -141,7 +141,7 @@ int main(int argc, char *argv[]) {
return
0
;
return
0
;
}
}
aruco
::
Dictionary
dictionary
=
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
aruco
::
getPredefinedDictionary
(
aruco
::
PREDEFINED_DICTIONARY_NAME
(
dictionaryId
));
Mat
camMatrix
,
distCoeffs
;
Mat
camMatrix
,
distCoeffs
;
...
...
modules/aruco/src/aruco.cpp
View file @
063c191d
This diff is collapsed.
Click to expand it.
modules/aruco/src/charuco.cpp
View file @
063c191d
This diff is collapsed.
Click to expand it.
modules/aruco/src/dictionary.cpp
View file @
063c191d
...
@@ -48,6 +48,16 @@ namespace aruco {
...
@@ -48,6 +48,16 @@ namespace aruco {
using
namespace
std
;
using
namespace
std
;
/**
*/
Dictionary
::
Dictionary
(
const
Ptr
<
Dictionary
>
&
_dictionary
)
{
markerSize
=
_dictionary
->
markerSize
;
maxCorrectionBits
=
_dictionary
->
maxCorrectionBits
;
bytesList
=
_dictionary
->
bytesList
.
clone
();
}
/**
/**
*/
*/
Dictionary
::
Dictionary
(
const
Mat
&
_bytesList
,
int
_markerSize
,
int
_maxcorr
)
{
Dictionary
::
Dictionary
(
const
Mat
&
_bytesList
,
int
_markerSize
,
int
_maxcorr
)
{
...
@@ -57,6 +67,28 @@ Dictionary::Dictionary(const Mat &_bytesList, int _markerSize, int _maxcorr) {
...
@@ -57,6 +67,28 @@ Dictionary::Dictionary(const Mat &_bytesList, int _markerSize, int _maxcorr) {
}
}
/**
*/
Ptr
<
Dictionary
>
Dictionary
::
create
(
int
nMarkers
,
int
markerSize
)
{
Ptr
<
Dictionary
>
baseDictionary
=
makePtr
<
Dictionary
>
();
return
create
(
nMarkers
,
markerSize
,
baseDictionary
);
}
/**
*/
Ptr
<
Dictionary
>
Dictionary
::
create
(
int
nMarkers
,
int
markerSize
,
Ptr
<
Dictionary
>
&
baseDictionary
)
{
return
generateCustomDictionary
(
nMarkers
,
markerSize
,
baseDictionary
);
}
/**
*/
Ptr
<
Dictionary
>
Dictionary
::
get
(
int
dict
)
{
return
getPredefinedDictionary
(
dict
);
}
/**
/**
*/
*/
...
@@ -259,50 +291,55 @@ const Dictionary DICT_7X7_250_DATA = Dictionary(Mat(250, (7*7 + 7)/8 ,CV_8UC4, (
...
@@ -259,50 +291,55 @@ const Dictionary DICT_7X7_250_DATA = Dictionary(Mat(250, (7*7 + 7)/8 ,CV_8UC4, (
const
Dictionary
DICT_7X7_1000_DATA
=
Dictionary
(
Mat
(
1000
,
(
7
*
7
+
7
)
/
8
,
CV_8UC4
,
(
uchar
*
)
DICT_7X7_1000_BYTES
),
7
,
6
);
const
Dictionary
DICT_7X7_1000_DATA
=
Dictionary
(
Mat
(
1000
,
(
7
*
7
+
7
)
/
8
,
CV_8UC4
,
(
uchar
*
)
DICT_7X7_1000_BYTES
),
7
,
6
);
const
Dictionary
&
getPredefinedDictionary
(
PREDEFINED_DICTIONARY_NAME
name
)
{
Ptr
<
Dictionary
>
getPredefinedDictionary
(
PREDEFINED_DICTIONARY_NAME
name
)
{
switch
(
name
)
{
switch
(
name
)
{
case
DICT_ARUCO_ORIGINAL
:
case
DICT_ARUCO_ORIGINAL
:
return
DICT_ARUCO_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_ARUCO_DATA
)
;
case
DICT_4X4_50
:
case
DICT_4X4_50
:
return
DICT_4X4_50_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_4X4_50_DATA
)
;
case
DICT_4X4_100
:
case
DICT_4X4_100
:
return
DICT_4X4_100_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_4X4_100_DATA
)
;
case
DICT_4X4_250
:
case
DICT_4X4_250
:
return
DICT_4X4_250_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_4X4_250_DATA
)
;
case
DICT_4X4_1000
:
case
DICT_4X4_1000
:
return
DICT_4X4_1000_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_4X4_1000_DATA
)
;
case
DICT_5X5_50
:
case
DICT_5X5_50
:
return
DICT_5X5_50_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_5X5_50_DATA
)
;
case
DICT_5X5_100
:
case
DICT_5X5_100
:
return
DICT_5X5_100_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_5X5_100_DATA
)
;
case
DICT_5X5_250
:
case
DICT_5X5_250
:
return
DICT_5X5_250_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_5X5_250_DATA
)
;
case
DICT_5X5_1000
:
case
DICT_5X5_1000
:
return
DICT_5X5_1000_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_5X5_1000_DATA
)
;
case
DICT_6X6_50
:
case
DICT_6X6_50
:
return
DICT_6X6_50_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_6X6_50_DATA
)
;
case
DICT_6X6_100
:
case
DICT_6X6_100
:
return
DICT_6X6_100_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_6X6_100_DATA
)
;
case
DICT_6X6_250
:
case
DICT_6X6_250
:
return
DICT_6X6_250_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_6X6_250_DATA
)
;
case
DICT_6X6_1000
:
case
DICT_6X6_1000
:
return
DICT_6X6_1000_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_6X6_1000_DATA
)
;
case
DICT_7X7_50
:
case
DICT_7X7_50
:
return
DICT_7X7_50_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_7X7_50_DATA
)
;
case
DICT_7X7_100
:
case
DICT_7X7_100
:
return
DICT_7X7_100_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_7X7_100_DATA
)
;
case
DICT_7X7_250
:
case
DICT_7X7_250
:
return
DICT_7X7_250_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_7X7_250_DATA
)
;
case
DICT_7X7_1000
:
case
DICT_7X7_1000
:
return
DICT_7X7_1000_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_7X7_1000_DATA
)
;
}
}
return
DICT_4X4_50_DATA
;
return
makePtr
<
Dictionary
>
(
DICT_4X4_50_DATA
);
}
Ptr
<
Dictionary
>
getPredefinedDictionary
(
int
dict
)
{
return
getPredefinedDictionary
(
PREDEFINED_DICTIONARY_NAME
(
dict
));
}
}
...
@@ -339,11 +376,11 @@ static int _getSelfDistance(const Mat &marker) {
...
@@ -339,11 +376,11 @@ static int _getSelfDistance(const Mat &marker) {
/**
/**
*/
*/
Dictionary
generateCustomDictionary
(
int
nMarkers
,
int
markerSize
,
Ptr
<
Dictionary
>
generateCustomDictionary
(
int
nMarkers
,
int
markerSize
,
const
Dictionary
&
baseDictionary
)
{
Ptr
<
Dictionary
>
&
baseDictionary
)
{
Dictionary
out
;
Ptr
<
Dictionary
>
out
=
makePtr
<
Dictionary
>
()
;
out
.
markerSize
=
markerSize
;
out
->
markerSize
=
markerSize
;
// theoretical maximum intermarker distance
// theoretical maximum intermarker distance
// See S. Garrido-Jurado, R. Muñoz-Salinas, F. J. Madrid-Cuevas, and M. J. Marín-Jiménez. 2014.
// See S. Garrido-Jurado, R. Muñoz-Salinas, F. J. Madrid-Cuevas, and M. J. Marín-Jiménez. 2014.
...
@@ -353,17 +390,17 @@ Dictionary generateCustomDictionary(int nMarkers, int markerSize,
...
@@ -353,17 +390,17 @@ Dictionary generateCustomDictionary(int nMarkers, int markerSize,
int
tau
=
2
*
(
int
)
std
::
floor
(
float
(
C
)
*
4.
f
/
3.
f
);
int
tau
=
2
*
(
int
)
std
::
floor
(
float
(
C
)
*
4.
f
/
3.
f
);
// if baseDictionary is provided, calculate its intermarker distance
// if baseDictionary is provided, calculate its intermarker distance
if
(
baseDictionary
.
bytesList
.
rows
>
0
)
{
if
(
baseDictionary
->
bytesList
.
rows
>
0
)
{
CV_Assert
(
baseDictionary
.
markerSize
==
markerSize
);
CV_Assert
(
baseDictionary
->
markerSize
==
markerSize
);
out
.
bytesList
=
baseDictionary
.
bytesList
.
clone
();
out
->
bytesList
=
baseDictionary
->
bytesList
.
clone
();
int
minDistance
=
markerSize
*
markerSize
+
1
;
int
minDistance
=
markerSize
*
markerSize
+
1
;
for
(
int
i
=
0
;
i
<
out
.
bytesList
.
rows
;
i
++
)
{
for
(
int
i
=
0
;
i
<
out
->
bytesList
.
rows
;
i
++
)
{
Mat
markerBytes
=
out
.
bytesList
.
rowRange
(
i
,
i
+
1
);
Mat
markerBytes
=
out
->
bytesList
.
rowRange
(
i
,
i
+
1
);
Mat
markerBits
=
Dictionary
::
getBitsFromByteList
(
markerBytes
,
markerSize
);
Mat
markerBits
=
Dictionary
::
getBitsFromByteList
(
markerBytes
,
markerSize
);
minDistance
=
min
(
minDistance
,
_getSelfDistance
(
markerBits
));
minDistance
=
min
(
minDistance
,
_getSelfDistance
(
markerBits
));
for
(
int
j
=
i
+
1
;
j
<
out
.
bytesList
.
rows
;
j
++
)
{
for
(
int
j
=
i
+
1
;
j
<
out
->
bytesList
.
rows
;
j
++
)
{
minDistance
=
min
(
minDistance
,
out
.
getDistanceToId
(
markerBits
,
j
));
minDistance
=
min
(
minDistance
,
out
->
getDistanceToId
(
markerBits
,
j
));
}
}
}
}
tau
=
minDistance
;
tau
=
minDistance
;
...
@@ -377,7 +414,7 @@ Dictionary generateCustomDictionary(int nMarkers, int markerSize,
...
@@ -377,7 +414,7 @@ Dictionary generateCustomDictionary(int nMarkers, int markerSize,
const
int
maxUnproductiveIterations
=
5000
;
const
int
maxUnproductiveIterations
=
5000
;
int
unproductiveIterations
=
0
;
int
unproductiveIterations
=
0
;
while
(
out
.
bytesList
.
rows
<
nMarkers
)
{
while
(
out
->
bytesList
.
rows
<
nMarkers
)
{
Mat
currentMarker
=
_generateRandomMarker
(
markerSize
);
Mat
currentMarker
=
_generateRandomMarker
(
markerSize
);
int
selfDistance
=
_getSelfDistance
(
currentMarker
);
int
selfDistance
=
_getSelfDistance
(
currentMarker
);
...
@@ -386,8 +423,8 @@ Dictionary generateCustomDictionary(int nMarkers, int markerSize,
...
@@ -386,8 +423,8 @@ Dictionary generateCustomDictionary(int nMarkers, int markerSize,
// if self distance is better or equal than current best option, calculate distance
// if self distance is better or equal than current best option, calculate distance
// to previous accepted markers
// to previous accepted markers
if
(
selfDistance
>=
bestTau
)
{
if
(
selfDistance
>=
bestTau
)
{
for
(
int
i
=
0
;
i
<
out
.
bytesList
.
rows
;
i
++
)
{
for
(
int
i
=
0
;
i
<
out
->
bytesList
.
rows
;
i
++
)
{
int
currentDistance
=
out
.
getDistanceToId
(
currentMarker
,
i
);
int
currentDistance
=
out
->
getDistanceToId
(
currentMarker
,
i
);
minDistance
=
min
(
currentDistance
,
minDistance
);
minDistance
=
min
(
currentDistance
,
minDistance
);
if
(
minDistance
<=
bestTau
)
{
if
(
minDistance
<=
bestTau
)
{
break
;
break
;
...
@@ -400,7 +437,7 @@ Dictionary generateCustomDictionary(int nMarkers, int markerSize,
...
@@ -400,7 +437,7 @@ Dictionary generateCustomDictionary(int nMarkers, int markerSize,
unproductiveIterations
=
0
;
unproductiveIterations
=
0
;
bestTau
=
0
;
bestTau
=
0
;
Mat
bytes
=
Dictionary
::
getByteListFromBits
(
currentMarker
);
Mat
bytes
=
Dictionary
::
getByteListFromBits
(
currentMarker
);
out
.
bytesList
.
push_back
(
bytes
);
out
->
bytesList
.
push_back
(
bytes
);
}
else
{
}
else
{
unproductiveIterations
++
;
unproductiveIterations
++
;
...
@@ -416,15 +453,25 @@ Dictionary generateCustomDictionary(int nMarkers, int markerSize,
...
@@ -416,15 +453,25 @@ Dictionary generateCustomDictionary(int nMarkers, int markerSize,
tau
=
bestTau
;
tau
=
bestTau
;
bestTau
=
0
;
bestTau
=
0
;
Mat
bytes
=
Dictionary
::
getByteListFromBits
(
bestMarker
);
Mat
bytes
=
Dictionary
::
getByteListFromBits
(
bestMarker
);
out
.
bytesList
.
push_back
(
bytes
);
out
->
bytesList
.
push_back
(
bytes
);
}
}
}
}
}
}
// update the maximum number of correction bits for the generated dictionary
// update the maximum number of correction bits for the generated dictionary
out
.
maxCorrectionBits
=
(
tau
-
1
)
/
2
;
out
->
maxCorrectionBits
=
(
tau
-
1
)
/
2
;
return
out
;
return
out
;
}
}
/**
*/
Ptr
<
Dictionary
>
generateCustomDictionary
(
int
nMarkers
,
int
markerSize
)
{
Ptr
<
Dictionary
>
baseDictionary
=
makePtr
<
Dictionary
>
();
return
generateCustomDictionary
(
nMarkers
,
markerSize
,
baseDictionary
);
}
}
}
}
}
modules/aruco/test/test_arucodetection.cpp
View file @
063c191d
...
@@ -62,7 +62,7 @@ CV_ArucoDetectionSimple::CV_ArucoDetectionSimple() {}
...
@@ -62,7 +62,7 @@ CV_ArucoDetectionSimple::CV_ArucoDetectionSimple() {}
void
CV_ArucoDetectionSimple
::
run
(
int
)
{
void
CV_ArucoDetectionSimple
::
run
(
int
)
{
aruco
::
Dictionary
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
// 20 images
// 20 images
for
(
int
i
=
0
;
i
<
20
;
i
++
)
{
for
(
int
i
=
0
;
i
<
20
;
i
++
)
{
...
@@ -99,7 +99,7 @@ void CV_ArucoDetectionSimple::run(int) {
...
@@ -99,7 +99,7 @@ void CV_ArucoDetectionSimple::run(int) {
// detect markers
// detect markers
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
int
>
ids
;
vector
<
int
>
ids
;
aruco
::
DetectorParameters
params
;
Ptr
<
aruco
::
DetectorParameters
>
params
=
aruco
::
DetectorParameters
::
create
()
;
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
// check detection results
// check detection results
...
@@ -183,7 +183,7 @@ static void getSyntheticRT(double yaw, double pitch, double distance, Mat &rvec,
...
@@ -183,7 +183,7 @@ static void getSyntheticRT(double yaw, double pitch, double distance, Mat &rvec,
/**
/**
* @brief Create a synthetic image of a marker with perspective
* @brief Create a synthetic image of a marker with perspective
*/
*/
static
Mat
projectMarker
(
aruco
::
Dictionary
dictionary
,
int
id
,
Mat
cameraMatrix
,
double
yaw
,
static
Mat
projectMarker
(
Ptr
<
aruco
::
Dictionary
>
&
dictionary
,
int
id
,
Mat
cameraMatrix
,
double
yaw
,
double
pitch
,
double
distance
,
Size
imageSize
,
int
markerBorder
,
double
pitch
,
double
distance
,
Size
imageSize
,
int
markerBorder
,
vector
<
Point2f
>
&
corners
)
{
vector
<
Point2f
>
&
corners
)
{
...
@@ -257,7 +257,7 @@ void CV_ArucoDetectionPerspective::run(int) {
...
@@ -257,7 +257,7 @@ void CV_ArucoDetectionPerspective::run(int) {
cameraMatrix
.
at
<
double
>
(
0
,
0
)
=
cameraMatrix
.
at
<
double
>
(
1
,
1
)
=
650
;
cameraMatrix
.
at
<
double
>
(
0
,
0
)
=
cameraMatrix
.
at
<
double
>
(
1
,
1
)
=
650
;
cameraMatrix
.
at
<
double
>
(
0
,
2
)
=
imgSize
.
width
/
2
;
cameraMatrix
.
at
<
double
>
(
0
,
2
)
=
imgSize
.
width
/
2
;
cameraMatrix
.
at
<
double
>
(
1
,
2
)
=
imgSize
.
height
/
2
;
cameraMatrix
.
at
<
double
>
(
1
,
2
)
=
imgSize
.
height
/
2
;
aruco
::
Dictionary
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
// detect from different positions
// detect from different positions
for
(
double
distance
=
0.1
;
distance
<=
0.5
;
distance
+=
0.2
)
{
for
(
double
distance
=
0.1
;
distance
<=
0.5
;
distance
+=
0.2
)
{
...
@@ -275,9 +275,9 @@ void CV_ArucoDetectionPerspective::run(int) {
...
@@ -275,9 +275,9 @@ void CV_ArucoDetectionPerspective::run(int) {
// detect markers
// detect markers
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
int
>
ids
;
vector
<
int
>
ids
;
aruco
::
DetectorParameters
params
;
Ptr
<
aruco
::
DetectorParameters
>
params
=
aruco
::
DetectorParameters
::
create
()
;
params
.
minDistanceToBorder
=
1
;
params
->
minDistanceToBorder
=
1
;
params
.
markerBorderBits
=
markerBorder
;
params
->
markerBorderBits
=
markerBorder
;
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
// check results
// check results
...
@@ -320,7 +320,7 @@ CV_ArucoDetectionMarkerSize::CV_ArucoDetectionMarkerSize() {}
...
@@ -320,7 +320,7 @@ CV_ArucoDetectionMarkerSize::CV_ArucoDetectionMarkerSize() {}
void
CV_ArucoDetectionMarkerSize
::
run
(
int
)
{
void
CV_ArucoDetectionMarkerSize
::
run
(
int
)
{
aruco
::
Dictionary
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
int
markerSide
=
20
;
int
markerSide
=
20
;
int
imageSize
=
200
;
int
imageSize
=
200
;
...
@@ -337,10 +337,10 @@ void CV_ArucoDetectionMarkerSize::run(int) {
...
@@ -337,10 +337,10 @@ void CV_ArucoDetectionMarkerSize::run(int) {
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
int
>
ids
;
vector
<
int
>
ids
;
aruco
::
DetectorParameters
params
;
Ptr
<
aruco
::
DetectorParameters
>
params
=
aruco
::
DetectorParameters
::
create
()
;
// set a invalid minMarkerPerimeterRate
// set a invalid minMarkerPerimeterRate
params
.
minMarkerPerimeterRate
=
min
(
4.
,
(
4.
*
markerSide
)
/
float
(
imageSize
)
+
0.1
);
params
->
minMarkerPerimeterRate
=
min
(
4.
,
(
4.
*
markerSide
)
/
float
(
imageSize
)
+
0.1
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
if
(
corners
.
size
()
!=
0
)
{
if
(
corners
.
size
()
!=
0
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error in DetectorParameters::minMarkerPerimeterRate"
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error in DetectorParameters::minMarkerPerimeterRate"
);
...
@@ -349,7 +349,7 @@ void CV_ArucoDetectionMarkerSize::run(int) {
...
@@ -349,7 +349,7 @@ void CV_ArucoDetectionMarkerSize::run(int) {
}
}
// set an valid minMarkerPerimeterRate
// set an valid minMarkerPerimeterRate
params
.
minMarkerPerimeterRate
=
max
(
0.
,
(
4.
*
markerSide
)
/
float
(
imageSize
)
-
0.1
);
params
->
minMarkerPerimeterRate
=
max
(
0.
,
(
4.
*
markerSide
)
/
float
(
imageSize
)
-
0.1
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
if
(
corners
.
size
()
!=
1
||
(
corners
.
size
()
==
1
&&
ids
[
0
]
!=
id
))
{
if
(
corners
.
size
()
!=
1
||
(
corners
.
size
()
==
1
&&
ids
[
0
]
!=
id
))
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error in DetectorParameters::minMarkerPerimeterRate"
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error in DetectorParameters::minMarkerPerimeterRate"
);
...
@@ -358,7 +358,7 @@ void CV_ArucoDetectionMarkerSize::run(int) {
...
@@ -358,7 +358,7 @@ void CV_ArucoDetectionMarkerSize::run(int) {
}
}
// set a invalid maxMarkerPerimeterRate
// set a invalid maxMarkerPerimeterRate
params
.
maxMarkerPerimeterRate
=
min
(
4.
,
(
4.
*
markerSide
)
/
float
(
imageSize
)
-
0.1
);
params
->
maxMarkerPerimeterRate
=
min
(
4.
,
(
4.
*
markerSide
)
/
float
(
imageSize
)
-
0.1
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
if
(
corners
.
size
()
!=
0
)
{
if
(
corners
.
size
()
!=
0
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error in DetectorParameters::maxMarkerPerimeterRate"
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error in DetectorParameters::maxMarkerPerimeterRate"
);
...
@@ -367,7 +367,7 @@ void CV_ArucoDetectionMarkerSize::run(int) {
...
@@ -367,7 +367,7 @@ void CV_ArucoDetectionMarkerSize::run(int) {
}
}
// set an valid maxMarkerPerimeterRate
// set an valid maxMarkerPerimeterRate
params
.
maxMarkerPerimeterRate
=
max
(
0.
,
(
4.
*
markerSide
)
/
float
(
imageSize
)
+
0.1
);
params
->
maxMarkerPerimeterRate
=
max
(
0.
,
(
4.
*
markerSide
)
/
float
(
imageSize
)
+
0.1
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
if
(
corners
.
size
()
!=
1
||
(
corners
.
size
()
==
1
&&
ids
[
0
]
!=
id
))
{
if
(
corners
.
size
()
!=
1
||
(
corners
.
size
()
==
1
&&
ids
[
0
]
!=
id
))
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error in DetectorParameters::maxMarkerPerimeterRate"
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error in DetectorParameters::maxMarkerPerimeterRate"
);
...
@@ -395,11 +395,12 @@ CV_ArucoBitCorrection::CV_ArucoBitCorrection() {}
...
@@ -395,11 +395,12 @@ CV_ArucoBitCorrection::CV_ArucoBitCorrection() {}
void
CV_ArucoBitCorrection
::
run
(
int
)
{
void
CV_ArucoBitCorrection
::
run
(
int
)
{
aruco
::
Dictionary
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
Ptr
<
aruco
::
Dictionary
>
_dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
aruco
::
Dictionary
dictionary2
=
dictionary
;
aruco
::
Dictionary
&
dictionary
=
*
_dictionary
;
aruco
::
Dictionary
dictionary2
=
*
_dictionary
;
int
markerSide
=
50
;
int
markerSide
=
50
;
int
imageSize
=
150
;
int
imageSize
=
150
;
aruco
::
DetectorParameters
params
;
Ptr
<
aruco
::
DetectorParameters
>
params
=
aruco
::
DetectorParameters
::
create
()
;
// 10 markers
// 10 markers
for
(
int
l
=
0
;
l
<
10
;
l
++
)
{
for
(
int
l
=
0
;
l
<
10
;
l
++
)
{
...
@@ -411,9 +412,9 @@ void CV_ArucoBitCorrection::run(int) {
...
@@ -411,9 +412,9 @@ void CV_ArucoBitCorrection::run(int) {
// 5 valid cases
// 5 valid cases
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
// how many bit errors (the error is low enough so it can be corrected)
// how many bit errors (the error is low enough so it can be corrected)
params
.
errorCorrectionRate
=
0.2
+
i
*
0.1
;
params
->
errorCorrectionRate
=
0.2
+
i
*
0.1
;
int
errors
=
int
errors
=
(
int
)
std
::
floor
(
dictionary
.
maxCorrectionBits
*
params
.
errorCorrectionRate
-
1.
);
(
int
)
std
::
floor
(
dictionary
.
maxCorrectionBits
*
params
->
errorCorrectionRate
-
1.
);
// create erroneous marker in currentCodeBits
// create erroneous marker in currentCodeBits
Mat
currentCodeBits
=
Mat
currentCodeBits
=
...
@@ -427,14 +428,14 @@ void CV_ArucoBitCorrection::run(int) {
...
@@ -427,14 +428,14 @@ void CV_ArucoBitCorrection::run(int) {
Mat
currentCodeBytesError
=
aruco
::
Dictionary
::
getByteListFromBits
(
currentCodeBits
);
Mat
currentCodeBytesError
=
aruco
::
Dictionary
::
getByteListFromBits
(
currentCodeBits
);
currentCodeBytesError
.
copyTo
(
dictionary2
.
bytesList
.
rowRange
(
id
,
id
+
1
));
currentCodeBytesError
.
copyTo
(
dictionary2
.
bytesList
.
rowRange
(
id
,
id
+
1
));
Mat
img
=
Mat
(
imageSize
,
imageSize
,
CV_8UC1
,
Scalar
::
all
(
255
));
Mat
img
=
Mat
(
imageSize
,
imageSize
,
CV_8UC1
,
Scalar
::
all
(
255
));
aruco
::
drawMarker
(
dictionary2
,
id
,
markerSide
,
marker
);
dictionary2
.
drawMarker
(
id
,
markerSide
,
marker
);
Mat
aux
=
img
.
colRange
(
30
,
30
+
markerSide
).
rowRange
(
50
,
50
+
markerSide
);
Mat
aux
=
img
.
colRange
(
30
,
30
+
markerSide
).
rowRange
(
50
,
50
+
markerSide
);
marker
.
copyTo
(
aux
);
marker
.
copyTo
(
aux
);
// try to detect using original dictionary
// try to detect using original dictionary
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
int
>
ids
;
vector
<
int
>
ids
;
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
aruco
::
detectMarkers
(
img
,
_
dictionary
,
corners
,
ids
,
params
);
if
(
corners
.
size
()
!=
1
||
(
corners
.
size
()
==
1
&&
ids
[
0
]
!=
id
))
{
if
(
corners
.
size
()
!=
1
||
(
corners
.
size
()
==
1
&&
ids
[
0
]
!=
id
))
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error in bit correction"
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error in bit correction"
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_BAD_ACCURACY
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_BAD_ACCURACY
);
...
@@ -445,9 +446,9 @@ void CV_ArucoBitCorrection::run(int) {
...
@@ -445,9 +446,9 @@ void CV_ArucoBitCorrection::run(int) {
// 5 invalid cases
// 5 invalid cases
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
// how many bit errors (the error is too high to be corrected)
// how many bit errors (the error is too high to be corrected)
params
.
errorCorrectionRate
=
0.2
+
i
*
0.1
;
params
->
errorCorrectionRate
=
0.2
+
i
*
0.1
;
int
errors
=
int
errors
=
(
int
)
std
::
floor
(
dictionary
.
maxCorrectionBits
*
params
.
errorCorrectionRate
+
1.
);
(
int
)
std
::
floor
(
dictionary
.
maxCorrectionBits
*
params
->
errorCorrectionRate
+
1.
);
// create erroneous marker in currentCodeBits
// create erroneous marker in currentCodeBits
Mat
currentCodeBits
=
Mat
currentCodeBits
=
...
@@ -458,21 +459,23 @@ void CV_ArucoBitCorrection::run(int) {
...
@@ -458,21 +459,23 @@ void CV_ArucoBitCorrection::run(int) {
}
}
// dictionary3 is only composed by the modified marker (in its original form)
// dictionary3 is only composed by the modified marker (in its original form)
aruco
::
Dictionary
dictionary3
=
dictionary
;
Ptr
<
aruco
::
Dictionary
>
_dictionary3
=
makePtr
<
aruco
::
Dictionary
>
(
dictionary3
.
bytesList
=
dictionary2
.
bytesList
.
rowRange
(
id
,
id
+
1
).
clone
();
dictionary2
.
bytesList
.
rowRange
(
id
,
id
+
1
).
clone
(),
dictionary
.
markerSize
,
dictionary
.
maxCorrectionBits
);
// add erroneous marker to dictionary2 in order to create the erroneous marker image
// add erroneous marker to dictionary2 in order to create the erroneous marker image
Mat
currentCodeBytesError
=
aruco
::
Dictionary
::
getByteListFromBits
(
currentCodeBits
);
Mat
currentCodeBytesError
=
aruco
::
Dictionary
::
getByteListFromBits
(
currentCodeBits
);
currentCodeBytesError
.
copyTo
(
dictionary2
.
bytesList
.
rowRange
(
id
,
id
+
1
));
currentCodeBytesError
.
copyTo
(
dictionary2
.
bytesList
.
rowRange
(
id
,
id
+
1
));
Mat
img
=
Mat
(
imageSize
,
imageSize
,
CV_8UC1
,
Scalar
::
all
(
255
));
Mat
img
=
Mat
(
imageSize
,
imageSize
,
CV_8UC1
,
Scalar
::
all
(
255
));
aruco
::
drawMarker
(
dictionary2
,
id
,
markerSide
,
marker
);
dictionary2
.
drawMarker
(
id
,
markerSide
,
marker
);
Mat
aux
=
img
.
colRange
(
30
,
30
+
markerSide
).
rowRange
(
50
,
50
+
markerSide
);
Mat
aux
=
img
.
colRange
(
30
,
30
+
markerSide
).
rowRange
(
50
,
50
+
markerSide
);
marker
.
copyTo
(
aux
);
marker
.
copyTo
(
aux
);
// try to detect using dictionary3, it should fail
// try to detect using dictionary3, it should fail
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
int
>
ids
;
vector
<
int
>
ids
;
aruco
::
detectMarkers
(
img
,
dictionary3
,
corners
,
ids
,
params
);
aruco
::
detectMarkers
(
img
,
_
dictionary3
,
corners
,
ids
,
params
);
if
(
corners
.
size
()
!=
0
)
{
if
(
corners
.
size
()
!=
0
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error in DetectorParameters::errorCorrectionRate"
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Error in DetectorParameters::errorCorrectionRate"
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_BAD_ACCURACY
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_BAD_ACCURACY
);
...
...
modules/aruco/test/test_boarddetection.cpp
View file @
063c191d
...
@@ -98,7 +98,7 @@ static void getSyntheticRT(double yaw, double pitch, double distance, Mat &rvec,
...
@@ -98,7 +98,7 @@ static void getSyntheticRT(double yaw, double pitch, double distance, Mat &rvec,
/**
/**
* @brief Project a synthetic marker
* @brief Project a synthetic marker
*/
*/
static
void
projectMarker
(
Mat
&
img
,
aruco
::
Dictionary
dictionary
,
int
id
,
static
void
projectMarker
(
Mat
&
img
,
Ptr
<
aruco
::
Dictionary
>
&
dictionary
,
int
id
,
vector
<
Point3f
>
markerObjPoints
,
Mat
cameraMatrix
,
Mat
rvec
,
Mat
tvec
,
vector
<
Point3f
>
markerObjPoints
,
Mat
cameraMatrix
,
Mat
rvec
,
Mat
tvec
,
int
markerBorder
)
{
int
markerBorder
)
{
...
@@ -140,15 +140,15 @@ static void projectMarker(Mat &img, aruco::Dictionary dictionary, int id,
...
@@ -140,15 +140,15 @@ static void projectMarker(Mat &img, aruco::Dictionary dictionary, int id,
/**
/**
* @brief Get a synthetic image of GridBoard in perspective
* @brief Get a synthetic image of GridBoard in perspective
*/
*/
static
Mat
projectBoard
(
aruco
::
GridBoard
board
,
Mat
cameraMatrix
,
double
yaw
,
double
pitch
,
static
Mat
projectBoard
(
Ptr
<
aruco
::
GridBoard
>
&
board
,
Mat
cameraMatrix
,
double
yaw
,
double
pitch
,
double
distance
,
Size
imageSize
,
int
markerBorder
)
{
double
distance
,
Size
imageSize
,
int
markerBorder
)
{
Mat
rvec
,
tvec
;
Mat
rvec
,
tvec
;
getSyntheticRT
(
yaw
,
pitch
,
distance
,
rvec
,
tvec
);
getSyntheticRT
(
yaw
,
pitch
,
distance
,
rvec
,
tvec
);
Mat
img
=
Mat
(
imageSize
,
CV_8UC1
,
Scalar
::
all
(
255
));
Mat
img
=
Mat
(
imageSize
,
CV_8UC1
,
Scalar
::
all
(
255
));
for
(
unsigned
int
m
=
0
;
m
<
board
.
ids
.
size
();
m
++
)
{
for
(
unsigned
int
m
=
0
;
m
<
board
->
ids
.
size
();
m
++
)
{
projectMarker
(
img
,
board
.
dictionary
,
board
.
ids
[
m
],
board
.
objPoints
[
m
],
cameraMatrix
,
rvec
,
projectMarker
(
img
,
board
->
dictionary
,
board
->
ids
[
m
],
board
->
objPoints
[
m
],
cameraMatrix
,
rvec
,
tvec
,
markerBorder
);
tvec
,
markerBorder
);
}
}
...
@@ -177,8 +177,9 @@ void CV_ArucoBoardPose::run(int) {
...
@@ -177,8 +177,9 @@ void CV_ArucoBoardPose::run(int) {
int
iter
=
0
;
int
iter
=
0
;
Mat
cameraMatrix
=
Mat
::
eye
(
3
,
3
,
CV_64FC1
);
Mat
cameraMatrix
=
Mat
::
eye
(
3
,
3
,
CV_64FC1
);
Size
imgSize
(
500
,
500
);
Size
imgSize
(
500
,
500
);
aruco
::
Dictionary
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
aruco
::
GridBoard
board
=
aruco
::
GridBoard
::
create
(
3
,
3
,
0.02
f
,
0.005
f
,
dictionary
);
Ptr
<
aruco
::
GridBoard
>
gridboard
=
aruco
::
GridBoard
::
create
(
3
,
3
,
0.02
f
,
0.005
f
,
dictionary
);
Ptr
<
aruco
::
Board
>
board
=
gridboard
.
staticCast
<
aruco
::
Board
>
();
cameraMatrix
.
at
<
double
>
(
0
,
0
)
=
cameraMatrix
.
at
<
double
>
(
1
,
1
)
=
650
;
cameraMatrix
.
at
<
double
>
(
0
,
0
)
=
cameraMatrix
.
at
<
double
>
(
1
,
1
)
=
650
;
cameraMatrix
.
at
<
double
>
(
0
,
2
)
=
imgSize
.
width
/
2
;
cameraMatrix
.
at
<
double
>
(
0
,
2
)
=
imgSize
.
width
/
2
;
cameraMatrix
.
at
<
double
>
(
1
,
2
)
=
imgSize
.
height
/
2
;
cameraMatrix
.
at
<
double
>
(
1
,
2
)
=
imgSize
.
height
/
2
;
...
@@ -188,21 +189,21 @@ void CV_ArucoBoardPose::run(int) {
...
@@ -188,21 +189,21 @@ void CV_ArucoBoardPose::run(int) {
for
(
double
distance
=
0.2
;
distance
<=
0.4
;
distance
+=
0.2
)
{
for
(
double
distance
=
0.2
;
distance
<=
0.4
;
distance
+=
0.2
)
{
for
(
int
yaw
=
0
;
yaw
<
360
;
yaw
+=
100
)
{
for
(
int
yaw
=
0
;
yaw
<
360
;
yaw
+=
100
)
{
for
(
int
pitch
=
30
;
pitch
<=
90
;
pitch
+=
50
)
{
for
(
int
pitch
=
30
;
pitch
<=
90
;
pitch
+=
50
)
{
for
(
unsigned
int
i
=
0
;
i
<
board
.
ids
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
gridboard
->
ids
.
size
();
i
++
)
board
.
ids
[
i
]
=
(
iter
+
int
(
i
))
%
250
;
gridboard
->
ids
[
i
]
=
(
iter
+
int
(
i
))
%
250
;
int
markerBorder
=
iter
%
2
+
1
;
int
markerBorder
=
iter
%
2
+
1
;
iter
++
;
iter
++
;
// create synthetic image
// create synthetic image
Mat
img
=
projectBoard
(
board
,
cameraMatrix
,
deg2rad
(
pitch
),
deg2rad
(
yaw
),
distance
,
Mat
img
=
projectBoard
(
grid
board
,
cameraMatrix
,
deg2rad
(
pitch
),
deg2rad
(
yaw
),
distance
,
imgSize
,
markerBorder
);
imgSize
,
markerBorder
);
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
int
>
ids
;
vector
<
int
>
ids
;
aruco
::
DetectorParameters
params
;
Ptr
<
aruco
::
DetectorParameters
>
params
=
aruco
::
DetectorParameters
::
create
()
;
params
.
minDistanceToBorder
=
3
;
params
->
minDistanceToBorder
=
3
;
params
.
markerBorderBits
=
markerBorder
;
params
->
markerBorderBits
=
markerBorder
;
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
if
(
ids
.
size
()
==
0
)
{
if
(
ids
.
size
()
==
0
)
{
...
@@ -218,8 +219,8 @@ void CV_ArucoBoardPose::run(int) {
...
@@ -218,8 +219,8 @@ void CV_ArucoBoardPose::run(int) {
// check result
// check result
for
(
unsigned
int
i
=
0
;
i
<
ids
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
ids
.
size
();
i
++
)
{
int
foundIdx
=
-
1
;
int
foundIdx
=
-
1
;
for
(
unsigned
int
j
=
0
;
j
<
board
.
ids
.
size
();
j
++
)
{
for
(
unsigned
int
j
=
0
;
j
<
gridboard
->
ids
.
size
();
j
++
)
{
if
(
board
.
ids
[
j
]
==
ids
[
i
])
{
if
(
gridboard
->
ids
[
j
]
==
ids
[
i
])
{
foundIdx
=
int
(
j
);
foundIdx
=
int
(
j
);
break
;
break
;
}
}
...
@@ -232,7 +233,7 @@ void CV_ArucoBoardPose::run(int) {
...
@@ -232,7 +233,7 @@ void CV_ArucoBoardPose::run(int) {
}
}
vector
<
Point2f
>
projectedCorners
;
vector
<
Point2f
>
projectedCorners
;
projectPoints
(
board
.
objPoints
[
foundIdx
],
rvec
,
tvec
,
cameraMatrix
,
distCoeffs
,
projectPoints
(
gridboard
->
objPoints
[
foundIdx
],
rvec
,
tvec
,
cameraMatrix
,
distCoeffs
,
projectedCorners
);
projectedCorners
);
for
(
int
c
=
0
;
c
<
4
;
c
++
)
{
for
(
int
c
=
0
;
c
<
4
;
c
++
)
{
...
@@ -271,8 +272,9 @@ void CV_ArucoRefine::run(int) {
...
@@ -271,8 +272,9 @@ void CV_ArucoRefine::run(int) {
int
iter
=
0
;
int
iter
=
0
;
Mat
cameraMatrix
=
Mat
::
eye
(
3
,
3
,
CV_64FC1
);
Mat
cameraMatrix
=
Mat
::
eye
(
3
,
3
,
CV_64FC1
);
Size
imgSize
(
500
,
500
);
Size
imgSize
(
500
,
500
);
aruco
::
Dictionary
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
aruco
::
GridBoard
board
=
aruco
::
GridBoard
::
create
(
3
,
3
,
0.02
f
,
0.005
f
,
dictionary
);
Ptr
<
aruco
::
GridBoard
>
gridboard
=
aruco
::
GridBoard
::
create
(
3
,
3
,
0.02
f
,
0.005
f
,
dictionary
);
Ptr
<
aruco
::
Board
>
board
=
gridboard
.
staticCast
<
aruco
::
Board
>
();
cameraMatrix
.
at
<
double
>
(
0
,
0
)
=
cameraMatrix
.
at
<
double
>
(
1
,
1
)
=
650
;
cameraMatrix
.
at
<
double
>
(
0
,
0
)
=
cameraMatrix
.
at
<
double
>
(
1
,
1
)
=
650
;
cameraMatrix
.
at
<
double
>
(
0
,
2
)
=
imgSize
.
width
/
2
;
cameraMatrix
.
at
<
double
>
(
0
,
2
)
=
imgSize
.
width
/
2
;
cameraMatrix
.
at
<
double
>
(
1
,
2
)
=
imgSize
.
height
/
2
;
cameraMatrix
.
at
<
double
>
(
1
,
2
)
=
imgSize
.
height
/
2
;
...
@@ -282,23 +284,23 @@ void CV_ArucoRefine::run(int) {
...
@@ -282,23 +284,23 @@ void CV_ArucoRefine::run(int) {
for
(
double
distance
=
0.2
;
distance
<=
0.4
;
distance
+=
0.2
)
{
for
(
double
distance
=
0.2
;
distance
<=
0.4
;
distance
+=
0.2
)
{
for
(
int
yaw
=
0
;
yaw
<
360
;
yaw
+=
100
)
{
for
(
int
yaw
=
0
;
yaw
<
360
;
yaw
+=
100
)
{
for
(
int
pitch
=
30
;
pitch
<=
90
;
pitch
+=
50
)
{
for
(
int
pitch
=
30
;
pitch
<=
90
;
pitch
+=
50
)
{
for
(
unsigned
int
i
=
0
;
i
<
board
.
ids
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
gridboard
->
ids
.
size
();
i
++
)
board
.
ids
[
i
]
=
(
iter
+
int
(
i
))
%
250
;
gridboard
->
ids
[
i
]
=
(
iter
+
int
(
i
))
%
250
;
int
markerBorder
=
iter
%
2
+
1
;
int
markerBorder
=
iter
%
2
+
1
;
iter
++
;
iter
++
;
// create synthetic image
// create synthetic image
Mat
img
=
projectBoard
(
board
,
cameraMatrix
,
deg2rad
(
pitch
),
deg2rad
(
yaw
),
distance
,
Mat
img
=
projectBoard
(
grid
board
,
cameraMatrix
,
deg2rad
(
pitch
),
deg2rad
(
yaw
),
distance
,
imgSize
,
markerBorder
);
imgSize
,
markerBorder
);
// detect markers
// detect markers
vector
<
vector
<
Point2f
>
>
corners
,
rejected
;
vector
<
vector
<
Point2f
>
>
corners
,
rejected
;
vector
<
int
>
ids
;
vector
<
int
>
ids
;
aruco
::
DetectorParameters
params
;
Ptr
<
aruco
::
DetectorParameters
>
params
=
aruco
::
DetectorParameters
::
create
()
;
params
.
minDistanceToBorder
=
3
;
params
->
minDistanceToBorder
=
3
;
params
.
doCornerRefinement
=
true
;
params
->
doCornerRefinement
=
true
;
params
.
markerBorderBits
=
markerBorder
;
params
->
markerBorderBits
=
markerBorder
;
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
,
rejected
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
,
rejected
);
// remove a marker from detection
// remove a marker from detection
...
...
modules/aruco/test/test_charucodetection.cpp
View file @
063c191d
...
@@ -98,7 +98,7 @@ static void getSyntheticRT(double yaw, double pitch, double distance, Mat &rvec,
...
@@ -98,7 +98,7 @@ static void getSyntheticRT(double yaw, double pitch, double distance, Mat &rvec,
/**
/**
* @brief Project a synthetic marker
* @brief Project a synthetic marker
*/
*/
static
void
projectMarker
(
Mat
&
img
,
aruco
::
Dictionary
dictionary
,
int
id
,
static
void
projectMarker
(
Mat
&
img
,
Ptr
<
aruco
::
Dictionary
>
dictionary
,
int
id
,
vector
<
Point3f
>
markerObjPoints
,
Mat
cameraMatrix
,
Mat
rvec
,
Mat
tvec
,
vector
<
Point3f
>
markerObjPoints
,
Mat
cameraMatrix
,
Mat
rvec
,
Mat
tvec
,
int
markerBorder
)
{
int
markerBorder
)
{
...
@@ -176,7 +176,7 @@ static Mat projectChessboard(int squaresX, int squaresY, float squareSize, Size
...
@@ -176,7 +176,7 @@ static Mat projectChessboard(int squaresX, int squaresY, float squareSize, Size
/**
/**
* @brief Check pose estimation of charuco board
* @brief Check pose estimation of charuco board
*/
*/
static
Mat
projectCharucoBoard
(
aruco
::
CharucoBoard
board
,
Mat
cameraMatrix
,
double
yaw
,
static
Mat
projectCharucoBoard
(
Ptr
<
aruco
::
CharucoBoard
>
&
board
,
Mat
cameraMatrix
,
double
yaw
,
double
pitch
,
double
distance
,
Size
imageSize
,
int
markerBorder
,
double
pitch
,
double
distance
,
Size
imageSize
,
int
markerBorder
,
Mat
&
rvec
,
Mat
&
tvec
)
{
Mat
&
rvec
,
Mat
&
tvec
)
{
...
@@ -184,15 +184,15 @@ static Mat projectCharucoBoard(aruco::CharucoBoard board, Mat cameraMatrix, doub
...
@@ -184,15 +184,15 @@ static Mat projectCharucoBoard(aruco::CharucoBoard board, Mat cameraMatrix, doub
// project markers
// project markers
Mat
img
=
Mat
(
imageSize
,
CV_8UC1
,
Scalar
::
all
(
255
));
Mat
img
=
Mat
(
imageSize
,
CV_8UC1
,
Scalar
::
all
(
255
));
for
(
unsigned
int
m
=
0
;
m
<
board
.
ids
.
size
();
m
++
)
{
for
(
unsigned
int
m
=
0
;
m
<
board
->
ids
.
size
();
m
++
)
{
projectMarker
(
img
,
board
.
dictionary
,
board
.
ids
[
m
],
board
.
objPoints
[
m
],
cameraMatrix
,
rvec
,
projectMarker
(
img
,
board
->
dictionary
,
board
->
ids
[
m
],
board
->
objPoints
[
m
],
cameraMatrix
,
rvec
,
tvec
,
markerBorder
);
tvec
,
markerBorder
);
}
}
// project chessboard
// project chessboard
Mat
chessboard
=
Mat
chessboard
=
projectChessboard
(
board
.
getChessboardSize
().
width
,
board
.
getChessboardSize
().
height
,
projectChessboard
(
board
->
getChessboardSize
().
width
,
board
->
getChessboardSize
().
height
,
board
.
getSquareLength
(),
imageSize
,
cameraMatrix
,
rvec
,
tvec
);
board
->
getSquareLength
(),
imageSize
,
cameraMatrix
,
rvec
,
tvec
);
for
(
unsigned
int
i
=
0
;
i
<
chessboard
.
total
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
chessboard
.
total
();
i
++
)
{
if
(
chessboard
.
ptr
<
unsigned
char
>
()[
i
]
==
0
)
{
if
(
chessboard
.
ptr
<
unsigned
char
>
()[
i
]
==
0
)
{
...
@@ -226,8 +226,8 @@ void CV_CharucoDetection::run(int) {
...
@@ -226,8 +226,8 @@ void CV_CharucoDetection::run(int) {
int
iter
=
0
;
int
iter
=
0
;
Mat
cameraMatrix
=
Mat
::
eye
(
3
,
3
,
CV_64FC1
);
Mat
cameraMatrix
=
Mat
::
eye
(
3
,
3
,
CV_64FC1
);
Size
imgSize
(
500
,
500
);
Size
imgSize
(
500
,
500
);
aruco
::
Dictionary
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
aruco
::
CharucoBoard
board
=
aruco
::
CharucoBoard
::
create
(
4
,
4
,
0.03
f
,
0.015
f
,
dictionary
);
Ptr
<
aruco
::
CharucoBoard
>
board
=
aruco
::
CharucoBoard
::
create
(
4
,
4
,
0.03
f
,
0.015
f
,
dictionary
);
cameraMatrix
.
at
<
double
>
(
0
,
0
)
=
cameraMatrix
.
at
<
double
>
(
1
,
1
)
=
650
;
cameraMatrix
.
at
<
double
>
(
0
,
0
)
=
cameraMatrix
.
at
<
double
>
(
1
,
1
)
=
650
;
cameraMatrix
.
at
<
double
>
(
0
,
2
)
=
imgSize
.
width
/
2
;
cameraMatrix
.
at
<
double
>
(
0
,
2
)
=
imgSize
.
width
/
2
;
...
@@ -251,9 +251,9 @@ void CV_CharucoDetection::run(int) {
...
@@ -251,9 +251,9 @@ void CV_CharucoDetection::run(int) {
// detect markers
// detect markers
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
int
>
ids
;
vector
<
int
>
ids
;
aruco
::
DetectorParameters
params
;
Ptr
<
aruco
::
DetectorParameters
>
params
=
aruco
::
DetectorParameters
::
create
()
;
params
.
minDistanceToBorder
=
3
;
params
->
minDistanceToBorder
=
3
;
params
.
markerBorderBits
=
markerBorder
;
params
->
markerBorderBits
=
markerBorder
;
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
if
(
ids
.
size
()
==
0
)
{
if
(
ids
.
size
()
==
0
)
{
...
@@ -276,14 +276,14 @@ void CV_CharucoDetection::run(int) {
...
@@ -276,14 +276,14 @@ void CV_CharucoDetection::run(int) {
// check results
// check results
vector
<
Point2f
>
projectedCharucoCorners
;
vector
<
Point2f
>
projectedCharucoCorners
;
projectPoints
(
board
.
chessboardCorners
,
rvec
,
tvec
,
cameraMatrix
,
distCoeffs
,
projectPoints
(
board
->
chessboardCorners
,
rvec
,
tvec
,
cameraMatrix
,
distCoeffs
,
projectedCharucoCorners
);
projectedCharucoCorners
);
for
(
unsigned
int
i
=
0
;
i
<
charucoIds
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
charucoIds
.
size
();
i
++
)
{
int
currentId
=
charucoIds
[
i
];
int
currentId
=
charucoIds
[
i
];
if
(
currentId
>=
(
int
)
board
.
chessboardCorners
.
size
())
{
if
(
currentId
>=
(
int
)
board
->
chessboardCorners
.
size
())
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Invalid Charuco corner id"
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Invalid Charuco corner id"
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_MISMATCH
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_MISMATCH
);
return
;
return
;
...
@@ -325,8 +325,8 @@ void CV_CharucoPoseEstimation::run(int) {
...
@@ -325,8 +325,8 @@ void CV_CharucoPoseEstimation::run(int) {
int
iter
=
0
;
int
iter
=
0
;
Mat
cameraMatrix
=
Mat
::
eye
(
3
,
3
,
CV_64FC1
);
Mat
cameraMatrix
=
Mat
::
eye
(
3
,
3
,
CV_64FC1
);
Size
imgSize
(
500
,
500
);
Size
imgSize
(
500
,
500
);
aruco
::
Dictionary
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
aruco
::
CharucoBoard
board
=
aruco
::
CharucoBoard
::
create
(
4
,
4
,
0.03
f
,
0.015
f
,
dictionary
);
Ptr
<
aruco
::
CharucoBoard
>
board
=
aruco
::
CharucoBoard
::
create
(
4
,
4
,
0.03
f
,
0.015
f
,
dictionary
);
cameraMatrix
.
at
<
double
>
(
0
,
0
)
=
cameraMatrix
.
at
<
double
>
(
1
,
1
)
=
650
;
cameraMatrix
.
at
<
double
>
(
0
,
0
)
=
cameraMatrix
.
at
<
double
>
(
1
,
1
)
=
650
;
cameraMatrix
.
at
<
double
>
(
0
,
2
)
=
imgSize
.
width
/
2
;
cameraMatrix
.
at
<
double
>
(
0
,
2
)
=
imgSize
.
width
/
2
;
...
@@ -349,9 +349,9 @@ void CV_CharucoPoseEstimation::run(int) {
...
@@ -349,9 +349,9 @@ void CV_CharucoPoseEstimation::run(int) {
// detect markers
// detect markers
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
int
>
ids
;
vector
<
int
>
ids
;
aruco
::
DetectorParameters
params
;
Ptr
<
aruco
::
DetectorParameters
>
params
=
aruco
::
DetectorParameters
::
create
()
;
params
.
minDistanceToBorder
=
3
;
params
->
minDistanceToBorder
=
3
;
params
.
markerBorderBits
=
markerBorder
;
params
->
markerBorderBits
=
markerBorder
;
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
if
(
ids
.
size
()
==
0
)
{
if
(
ids
.
size
()
==
0
)
{
...
@@ -381,14 +381,14 @@ void CV_CharucoPoseEstimation::run(int) {
...
@@ -381,14 +381,14 @@ void CV_CharucoPoseEstimation::run(int) {
// check result
// check result
vector
<
Point2f
>
projectedCharucoCorners
;
vector
<
Point2f
>
projectedCharucoCorners
;
projectPoints
(
board
.
chessboardCorners
,
rvec
,
tvec
,
cameraMatrix
,
distCoeffs
,
projectPoints
(
board
->
chessboardCorners
,
rvec
,
tvec
,
cameraMatrix
,
distCoeffs
,
projectedCharucoCorners
);
projectedCharucoCorners
);
for
(
unsigned
int
i
=
0
;
i
<
charucoIds
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
charucoIds
.
size
();
i
++
)
{
int
currentId
=
charucoIds
[
i
];
int
currentId
=
charucoIds
[
i
];
if
(
currentId
>=
(
int
)
board
.
chessboardCorners
.
size
())
{
if
(
currentId
>=
(
int
)
board
->
chessboardCorners
.
size
())
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Invalid Charuco corner id"
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Invalid Charuco corner id"
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_MISMATCH
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_MISMATCH
);
return
;
return
;
...
@@ -429,10 +429,10 @@ void CV_CharucoDiamondDetection::run(int) {
...
@@ -429,10 +429,10 @@ void CV_CharucoDiamondDetection::run(int) {
int
iter
=
0
;
int
iter
=
0
;
Mat
cameraMatrix
=
Mat
::
eye
(
3
,
3
,
CV_64FC1
);
Mat
cameraMatrix
=
Mat
::
eye
(
3
,
3
,
CV_64FC1
);
Size
imgSize
(
500
,
500
);
Size
imgSize
(
500
,
500
);
aruco
::
Dictionary
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
Ptr
<
aruco
::
Dictionary
>
dictionary
=
aruco
::
getPredefinedDictionary
(
aruco
::
DICT_6X6_250
);
float
squareLength
=
0.03
f
;
float
squareLength
=
0.03
f
;
float
markerLength
=
0.015
f
;
float
markerLength
=
0.015
f
;
aruco
::
CharucoBoard
board
=
Ptr
<
aruco
::
CharucoBoard
>
board
=
aruco
::
CharucoBoard
::
create
(
3
,
3
,
squareLength
,
markerLength
,
dictionary
);
aruco
::
CharucoBoard
::
create
(
3
,
3
,
squareLength
,
markerLength
,
dictionary
);
cameraMatrix
.
at
<
double
>
(
0
,
0
)
=
cameraMatrix
.
at
<
double
>
(
1
,
1
)
=
650
;
cameraMatrix
.
at
<
double
>
(
0
,
0
)
=
cameraMatrix
.
at
<
double
>
(
1
,
1
)
=
650
;
...
@@ -447,7 +447,7 @@ void CV_CharucoDiamondDetection::run(int) {
...
@@ -447,7 +447,7 @@ void CV_CharucoDiamondDetection::run(int) {
int
markerBorder
=
iter
%
2
+
1
;
int
markerBorder
=
iter
%
2
+
1
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
i
=
0
;
i
<
4
;
i
++
)
board
.
ids
[
i
]
=
4
*
iter
+
i
;
board
->
ids
[
i
]
=
4
*
iter
+
i
;
iter
++
;
iter
++
;
// get synthetic image
// get synthetic image
...
@@ -458,9 +458,9 @@ void CV_CharucoDiamondDetection::run(int) {
...
@@ -458,9 +458,9 @@ void CV_CharucoDiamondDetection::run(int) {
// detect markers
// detect markers
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
vector
<
Point2f
>
>
corners
;
vector
<
int
>
ids
;
vector
<
int
>
ids
;
aruco
::
DetectorParameters
params
;
Ptr
<
aruco
::
DetectorParameters
>
params
=
aruco
::
DetectorParameters
::
create
()
;
params
.
minDistanceToBorder
=
0
;
params
->
minDistanceToBorder
=
0
;
params
.
markerBorderBits
=
markerBorder
;
params
->
markerBorderBits
=
markerBorder
;
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
aruco
::
detectMarkers
(
img
,
dictionary
,
corners
,
ids
,
params
);
if
(
ids
.
size
()
!=
4
)
{
if
(
ids
.
size
()
!=
4
)
{
...
@@ -483,7 +483,7 @@ void CV_CharucoDiamondDetection::run(int) {
...
@@ -483,7 +483,7 @@ void CV_CharucoDiamondDetection::run(int) {
}
}
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
if
(
diamondIds
[
0
][
i
]
!=
board
.
ids
[
i
])
{
if
(
diamondIds
[
0
][
i
]
!=
board
->
ids
[
i
])
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Incorrect diamond ids"
);
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Incorrect diamond ids"
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_MISMATCH
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_MISMATCH
);
return
;
return
;
...
@@ -492,7 +492,7 @@ void CV_CharucoDiamondDetection::run(int) {
...
@@ -492,7 +492,7 @@ void CV_CharucoDiamondDetection::run(int) {
vector
<
Point2f
>
projectedDiamondCorners
;
vector
<
Point2f
>
projectedDiamondCorners
;
projectPoints
(
board
.
chessboardCorners
,
rvec
,
tvec
,
cameraMatrix
,
distCoeffs
,
projectPoints
(
board
->
chessboardCorners
,
rvec
,
tvec
,
cameraMatrix
,
distCoeffs
,
projectedDiamondCorners
);
projectedDiamondCorners
);
vector
<
Point2f
>
projectedDiamondCornersReorder
(
4
);
vector
<
Point2f
>
projectedDiamondCornersReorder
(
4
);
...
...
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