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
fa94c160
Commit
fa94c160
authored
May 11, 2017
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1153 from atinfinity:fixed_aruco_tutorial
parents
6bca9e84
ebc255b0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
69 deletions
+70
-69
aruco_board_detection.markdown
...ials/aruco_board_detection/aruco_board_detection.markdown
+12
-12
aruco_calibration.markdown
...co/tutorials/aruco_calibration/aruco_calibration.markdown
+9
-9
aruco_detection.markdown
.../aruco/tutorials/aruco_detection/aruco_detection.markdown
+17
-16
charuco_detection.markdown
...co/tutorials/charuco_detection/charuco_detection.markdown
+23
-23
charuco_diamond_detection.markdown
...ruco_diamond_detection/charuco_diamond_detection.markdown
+9
-9
No files found.
modules/aruco/tutorials/aruco_board_detection/aruco_board_detection.markdown
View file @
fa94c160
...
@@ -30,7 +30,7 @@ The aruco module allows the use of Boards. The main class is the ```cv::aruco::B
...
@@ -30,7 +30,7 @@ The aruco module allows the use of Boards. The main class is the ```cv::aruco::B
class
Board
{
class
Board
{
public
:
public
:
std
::
vector
<
std
::
vector
<
cv
::
Point3f
>
>
objPoints
;
std
::
vector
<
std
::
vector
<
cv
::
Point3f
>
>
objPoints
;
cv
::
aruco
::
Dictionary
dictionary
;
cv
::
Ptr
<
cv
::
aruco
::
Dictionary
>
dictionary
;
std
::
vector
<
int
>
ids
;
std
::
vector
<
int
>
ids
;
};
};
```
```
...
@@ -57,10 +57,10 @@ The aruco module provides a specific function, ```estimatePoseBoard()```, to per
...
@@ -57,10 +57,10 @@ The aruco module provides a specific function, ```estimatePoseBoard()```, to per
cv
::
Mat
cameraMatrix
,
distCoeffs
;
cv
::
Mat
cameraMatrix
,
distCoeffs
;
readCameraParameters
(
cameraMatrix
,
distCoeffs
);
readCameraParameters
(
cameraMatrix
,
distCoeffs
);
// assume we have a function to create the board object
// assume we have a function to create the board object
cv
::
aruco
::
Board
board
=
createBoard
();
cv
::
Ptr
<
cv
::
aruco
::
Board
>
board
=
cv
::
aruco
::
Board
::
create
();
...
...
vector
<
int
>
markerIds
;
std
::
vector
<
int
>
markerIds
;
vector
<
vector
<
Point2f
>
>
markerCorners
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
markerCorners
;
cv
::
aruco
::
detectMarkers
(
inputImage
,
board
.
dictionary
,
markerCorners
,
markerIds
);
cv
::
aruco
::
detectMarkers
(
inputImage
,
board
.
dictionary
,
markerCorners
,
markerIds
);
// if at least one marker detected
// if at least one marker detected
if
(
markerIds
.
size
()
>
0
)
{
if
(
markerIds
.
size
()
>
0
)
{
...
@@ -137,9 +137,9 @@ After creating a Grid Board, we probably want to print it and use it. A function
...
@@ -137,9 +137,9 @@ After creating a Grid Board, we probably want to print it and use it. A function
of a
```GridBoard```
is provided in
```cv::aruco::GridBoard::draw()```
. For example:
of a
```GridBoard```
is provided in
```cv::aruco::GridBoard::draw()```
. For example:
```
c++
```
c++
cv
::
aruco
::
GridBoard
board
=
cv
::
aruco
::
GridBoard
::
create
(
5
,
7
,
0.04
,
0.01
,
dictionary
);
cv
::
Ptr
<
cv
::
aruco
::
GridBoard
>
board
=
cv
::
aruco
::
GridBoard
::
create
(
5
,
7
,
0.04
,
0.01
,
dictionary
);
cv
::
Mat
boardImage
;
cv
::
Mat
boardImage
;
board
.
draw
(
cv
::
Size
(
600
,
500
),
boardImage
,
10
,
1
);
board
->
draw
(
cv
::
Size
(
600
,
500
),
boardImage
,
10
,
1
);
```
```
-
The first parameter is the size of the output image in pixels. In this case 600x500 pixels. If this is not proportional
-
The first parameter is the size of the output image in pixels. In this case 600x500 pixels. If this is not proportional
...
@@ -170,8 +170,8 @@ Finally, a full example of board detection:
...
@@ -170,8 +170,8 @@ Finally, a full example of board detection:
// camera parameters are read from somewhere
// camera parameters are read from somewhere
readCameraParameters
(
cameraMatrix
,
distCoeffs
);
readCameraParameters
(
cameraMatrix
,
distCoeffs
);
cv
::
aruco
::
Dictionary
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
cv
::
Ptr
<
cv
::
aruco
::
Dictionary
>
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
cv
::
aruco
::
GridBoard
board
=
cv
::
aruco
::
GridBoard
::
create
(
5
,
7
,
0.04
,
0.01
,
dictionary
);
cv
::
Ptr
<
cv
::
aruco
::
GridBoard
>
board
=
cv
::
aruco
::
GridBoard
::
create
(
5
,
7
,
0.04
,
0.01
,
dictionary
);
while
(
inputVideo
.
grab
())
{
while
(
inputVideo
.
grab
())
{
cv
::
Mat
image
,
imageCopy
;
cv
::
Mat
image
,
imageCopy
;
...
@@ -256,10 +256,10 @@ internal bits are not analyzed at all and only the corner distances are evaluate
...
@@ -256,10 +256,10 @@ internal bits are not analyzed at all and only the corner distances are evaluate
This is an example of using the
```refineDetectedMarkers()```
function:
This is an example of using the
```refineDetectedMarkers()```
function:
```
c++
```
c++
cv
::
aruco
::
Dictionary
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
cv
::
Ptr
<
cv
::
aruco
::
Dictionary
>
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
cv
::
aruco
::
GridBoard
board
=
cv
::
aruco
::
GridBoard
::
create
(
5
,
7
,
0.04
,
0.01
,
dictionary
);
cv
::
Ptr
<
cv
::
aruco
::
GridBoard
>
board
=
cv
::
aruco
::
GridBoard
::
create
(
5
,
7
,
0.04
,
0.01
,
dictionary
);
vector
<
int
>
markerIds
;
std
::
vector
<
int
>
markerIds
;
vector
<
vector
<
Point2f
>
>
markerCorners
,
rejectedCandidates
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
markerCorners
,
rejectedCandidates
;
cv
::
aruco
::
detectMarkers
(
inputImage
,
dictionary
,
markerCorners
,
markerIds
,
cv
::
aruco
::
DetectorParameters
(),
rejectedCandidates
);
cv
::
aruco
::
detectMarkers
(
inputImage
,
dictionary
,
markerCorners
,
markerIds
,
cv
::
aruco
::
DetectorParameters
(),
rejectedCandidates
);
cv
::
aruco
::
refineDetectedMarkersinputImage
,
board
,
markerCorners
,
markerIds
,
rejectedCandidates
);
cv
::
aruco
::
refineDetectedMarkersinputImage
,
board
,
markerCorners
,
markerIds
,
rejectedCandidates
);
...
...
modules/aruco/tutorials/aruco_calibration/aruco_calibration.markdown
View file @
fa94c160
...
@@ -33,18 +33,18 @@ visible in all the viewpoints.
...
@@ -33,18 +33,18 @@ visible in all the viewpoints.
The function to calibrate is
```calibrateCameraCharuco()```
. Example:
The function to calibrate is
```calibrateCameraCharuco()```
. Example:
```
c++
```
c++
aruco
::
CharucoBoard
board
=
...
// create charuco board
cv
::
Ptr
<
aruco
::
CharucoBoard
>
board
=
...
// create charuco board
cv
::
Size
imgSize
=
...
// camera image size
cv
::
Size
imgSize
=
...
// camera image size
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
allCharucoCorners
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
allCharucoCorners
;
std
::
vector
<
std
::
vector
<
int
>
>
allCharucoIds
;
std
::
vector
<
std
::
vector
<
int
>
>
allCharucoIds
;
// Detect charuco board from several viewpoints and fill allCharucoCorners and allCharucoIds
// Detect charuco board from several viewpoints and fill allCharucoCorners and allCharucoIds
...
...
...
...
// After capturing in several viewpoints, start calibration
// After capturing in several viewpoints, start calibration
cv
::
Mat
cameraMatrix
,
distCoeffs
;
cv
::
Mat
cameraMatrix
,
distCoeffs
;
std
::
vector
<
Mat
>
rvecs
,
tvecs
;
std
::
vector
<
cv
::
Mat
>
rvecs
,
tvecs
;
int
calibrationFlags
=
...
// Set calibration flags (same than in calibrateCamera() function)
int
calibrationFlags
=
...
// Set calibration flags (same than in calibrateCamera() function)
double
repError
=
cv
::
aruco
::
calibrateCameraCharuco
(
allCharucoCorners
,
allCharucoIds
,
board
,
imgSize
,
cameraMatrix
,
distCoeffs
,
rvecs
,
tvecs
,
calibrationFlags
);
double
repError
=
cv
::
aruco
::
calibrateCameraCharuco
(
allCharucoCorners
,
allCharucoIds
,
board
,
imgSize
,
cameraMatrix
,
distCoeffs
,
rvecs
,
tvecs
,
calibrationFlags
);
...
@@ -81,19 +81,19 @@ requires the detections of an ArUco board from different viewpoints.
...
@@ -81,19 +81,19 @@ requires the detections of an ArUco board from different viewpoints.
Example of ```calibrateCameraAruco()``` use:
Example of ```calibrateCameraAruco()``` use:
```
c++
```
c++
aruco::Board
board = ... // create aruco board
cv::Ptr
<aruco::Board>
board = ... // create aruco board
cv::Size imgSize = ... // camera image size
cv::Size imgSize = ... // camera image size
std::vector<
std::vector< cv::Point2f >
> allCornersConcatenated;
std::vector<
std::vector<cv::Point2f>
> allCornersConcatenated;
std::vector<
int
> allIdsConcatenated;
std::vector<
int
> allIdsConcatenated;
std::vector<
int
> markerCounterPerFrame;
std::vector<
int
> markerCounterPerFrame;
// Detect aruco board from several viewpoints and fill allCornersConcatenated, allIdsConcatenated and markerCounterPerFrame
// Detect aruco board from several viewpoints and fill allCornersConcatenated, allIdsConcatenated and markerCounterPerFrame
...
...
...
...
// After capturing in several viewpoints, start calibration
// After capturing in several viewpoints, start calibration
cv::Mat cameraMatrix, distCoeffs;
cv::Mat cameraMatrix, distCoeffs;
std::vector<
Mat
> rvecs, tvecs;
std::vector<
cv::Mat
> rvecs, tvecs;
int calibrationFlags = ... // Set calibration flags (same than in calibrateCamera() function)
int calibrationFlags = ... // Set calibration flags (same than in calibrateCamera() function)
double repError = cv::aruco::calibrateCameraAruco(allCornersConcatenated, allIdsConcatenated, markerCounterPerFrame, board, imgSize, cameraMatrix, distCoeffs, rvecs, tvecs, calibrationFlags);
double repError = cv::aruco::calibrateCameraAruco(allCornersConcatenated, allIdsConcatenated, markerCounterPerFrame, board, imgSize, cameraMatrix, distCoeffs, rvecs, tvecs, calibrationFlags);
...
...
modules/aruco/tutorials/aruco_detection/aruco_detection.markdown
View file @
fa94c160
...
@@ -20,7 +20,7 @@ a popular library for detection of square fiducial markers developed by Rafael M
...
@@ -20,7 +20,7 @@ a popular library for detection of square fiducial markers developed by Rafael M
The aruco functionalities are included in:
The aruco functionalities are included in:
```
c++
```
c++
\
#
include
<
opencv2
/
aruco
.
hpp
>
#include <opencv2/aruco.hpp>
```
```
...
@@ -71,7 +71,7 @@ For example, lets analyze the following call:
...
@@ -71,7 +71,7 @@ For example, lets analyze the following call:
```
c++
```
c++
cv
::
Mat
markerImage
;
cv
::
Mat
markerImage
;
cv
::
aruco
::
Dictionary
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
cv
::
Ptr
<
cv
::
aruco
::
Dictionary
>
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
cv
::
aruco
::
drawMarker
(
dictionary
,
23
,
200
,
markerImage
,
1
);
cv
::
aruco
::
drawMarker
(
dictionary
,
23
,
200
,
markerImage
,
1
);
```
```
...
@@ -156,10 +156,10 @@ An example of marker detection:
...
@@ -156,10 +156,10 @@ An example of marker detection:
```
c++
```
c++
cv
::
Mat
inputImage
;
cv
::
Mat
inputImage
;
...
...
vector
<
int
>
markerIds
;
std
::
vector
<
int
>
markerIds
;
vector
<
vector
<
Point2f
>
>
markerCorners
,
rejectedCandidates
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
markerCorners
,
rejectedCandidates
;
cv
::
aruco
::
DetectorParameters
parameters
;
cv
::
Ptr
<
cv
::
aruco
::
DetectorParameters
>
parameters
;
cv
::
aruco
::
Dictionary
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
cv
::
Ptr
<
cv
::
aruco
::
Dictionary
>
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
cv
::
aruco
::
detectMarkers
(
inputImage
,
dictionary
,
markerCorners
,
markerIds
,
parameters
,
rejectedCandidates
);
cv
::
aruco
::
detectMarkers
(
inputImage
,
dictionary
,
markerCorners
,
markerIds
,
parameters
,
rejectedCandidates
);
```
```
...
@@ -204,7 +204,7 @@ camera:
...
@@ -204,7 +204,7 @@ camera:
```
c++
```
c++
cv
::
VideoCapture
inputVideo
;
cv
::
VideoCapture
inputVideo
;
inputVideo
.
open
(
0
);
inputVideo
.
open
(
0
);
cv
::
aruco
::
Dictionary
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
cv
::
Ptr
<
cv
::
aruco
::
Dictionary
>
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
while
(
inputVideo
.
grab
())
{
while
(
inputVideo
.
grab
())
{
cv
::
Mat
image
,
imageCopy
;
cv
::
Mat
image
,
imageCopy
;
inputVideo
.
retrieve
(
image
);
inputVideo
.
retrieve
(
image
);
...
@@ -263,9 +263,9 @@ information).
...
@@ -263,9 +263,9 @@ information).
The aruco module provides a function to estimate the poses of all the detected markers:
The aruco module provides a function to estimate the poses of all the detected markers:
```
c++
```
c++
Mat
cameraMatrix
,
distCoeffs
;
cv
::
Mat
cameraMatrix
,
distCoeffs
;
...
...
vector
<
Vec3d
>
rvecs
,
tvecs
;
std
::
vector
<
cv
::
Vec3d
>
rvecs
,
tvecs
;
cv
::
aruco
::
estimatePoseSingleMarkers
(
corners
,
0.05
,
cameraMatrix
,
distCoeffs
,
rvecs
,
tvecs
);
cv
::
aruco
::
estimatePoseSingleMarkers
(
corners
,
0.05
,
cameraMatrix
,
distCoeffs
,
rvecs
,
tvecs
);
```
```
...
@@ -303,7 +303,7 @@ A basic full example for pose estimation from single markers:
...
@@ -303,7 +303,7 @@ A basic full example for pose estimation from single markers:
// camera parameters are read from somewhere
// camera parameters are read from somewhere
readCameraParameters
(
cameraMatrix
,
distCoeffs
);
readCameraParameters
(
cameraMatrix
,
distCoeffs
);
cv
::
aruco
::
Dictionary
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
cv
::
Ptr
<
cv
::
aruco
::
Dictionary
>
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
while
(
inputVideo
.
grab
())
{
while
(
inputVideo
.
grab
())
{
cv
::
Mat
image
,
imageCopy
;
cv
::
Mat
image
,
imageCopy
;
...
@@ -311,14 +311,14 @@ A basic full example for pose estimation from single markers:
...
@@ -311,14 +311,14 @@ A basic full example for pose estimation from single markers:
image
.
copyTo
(
imageCopy
);
image
.
copyTo
(
imageCopy
);
std
::
vector
<
int
>
ids
;
std
::
vector
<
int
>
ids
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
corners
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>>
corners
;
cv
::
aruco
::
detectMarkers
(
image
,
dictionary
,
corners
,
ids
);
cv
::
aruco
::
detectMarkers
(
image
,
dictionary
,
corners
,
ids
);
// if at least one marker detected
// if at least one marker detected
if
(
ids
.
size
()
>
0
)
{
if
(
ids
.
size
()
>
0
)
{
cv
::
aruco
::
drawDetectedMarkers
(
imageCopy
,
corners
,
ids
);
cv
::
aruco
::
drawDetectedMarkers
(
imageCopy
,
corners
,
ids
);
vector
<
Mat
>
rvecs
,
tvecs
;
std
::
vector
<
cv
::
Mat
>
rvecs
,
tvecs
;
cv
::
aruco
::
estimatePoseSingleMarkers
(
corners
,
0.05
,
cameraMatrix
,
distCoeffs
,
rvecs
,
tvecs
);
cv
::
aruco
::
estimatePoseSingleMarkers
(
corners
,
0.05
,
cameraMatrix
,
distCoeffs
,
rvecs
,
tvecs
);
// draw axis for each marker
// draw axis for each marker
for
(
int
i
=
0
;
i
<
ids
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
ids
.
size
();
i
++
)
...
@@ -374,7 +374,7 @@ This is the easiest way to select a dictionary. The aruco module includes a set
...
@@ -374,7 +374,7 @@ This is the easiest way to select a dictionary. The aruco module includes a set
of a variety of marker sizes and number of markers. For instance:
of a variety of marker sizes and number of markers. For instance:
```
c++
```
c++
cv
::
aruco
::
Dictionary
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
cv
::
Ptr
<
cv
::
aruco
::
Dictionary
>
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
```
```
DICT_6X6_250 is an example of predefined dictionary of markers with 6x6 bits and a total of 250
DICT_6X6_250 is an example of predefined dictionary of markers with 6x6 bits and a total of 250
...
@@ -390,7 +390,7 @@ The dictionary can be generated automatically to adjust to the desired number of
...
@@ -390,7 +390,7 @@ The dictionary can be generated automatically to adjust to the desired number of
the inter-marker distance is optimized:
the inter-marker distance is optimized:
```
c++
```
c++
cv
::
aruco
::
Dictionary
dictionary
=
cv
::
aruco
::
generateCustomDictionary
(
36
,
5
);
cv
::
Ptr
<
cv
::
aruco
::
Dictionary
>
dictionary
=
cv
::
aruco
::
generateCustomDictionary
(
36
,
5
);
```
```
This will generate a customized dictionary composed by 36 markers of 5x5 bits. The process can take several
This will generate a customized dictionary composed by 36 markers of 5x5 bits. The process can take several
...
@@ -432,7 +432,7 @@ Fortunately, a marker can be easily transformed to this form using the static me
...
@@ -432,7 +432,7 @@ Fortunately, a marker can be easily transformed to this form using the static me
For example:
For example:
```
c++
```
c++
Dictionary dictionary;
cv::aruco::
Dictionary dictionary;
// markers of 6x6 bits
// markers of 6x6 bits
dictionary.markerSize = 6;
dictionary.markerSize = 6;
// maximum number of bit corrections
// maximum number of bit corrections
...
@@ -440,10 +440,11 @@ For example:
...
@@ -440,10 +440,11 @@ For example:
// lets create a dictionary of 100 markers
// lets create a dictionary of 100 markers
for(int i=0; i<100; i++)
for(int i=0; i<100; i++)
{
// assume generateMarkerBits() generate a new marker in binary format, so that
// assume generateMarkerBits() generate a new marker in binary format, so that
// markerBits is a 6x6 matrix of CV_8UC1 type, only containing 0s and 1s
// markerBits is a 6x6 matrix of CV_8UC1 type, only containing 0s and 1s
cv::Mat markerBits = generateMarkerBits();
cv::Mat markerBits = generateMarkerBits();
cv::Mat markerCompressed = getByteListFromBits(markerBits);
cv::Mat markerCompressed =
cv::aruco::Dictionary::
getByteListFromBits(markerBits);
// add the marker as a new row
// add the marker as a new row
dictionary.bytesList.push_back(markerCompressed);
dictionary.bytesList.push_back(markerCompressed);
}
}
...
...
modules/aruco/tutorials/charuco_detection/charuco_detection.markdown
View file @
fa94c160
...
@@ -29,7 +29,7 @@ The aruco module provides the ```cv::aruco::CharucoBoard``` class that represent
...
@@ -29,7 +29,7 @@ The aruco module provides the ```cv::aruco::CharucoBoard``` class that represent
This class, as the rest of ChArUco functionalities, are defined in:
This class, as the rest of ChArUco functionalities, are defined in:
```
c++
```
c++
\
#
include
<
opencv2
/
aruco
/
charuco
.
hpp
>
#include <opencv2/aruco/charuco.hpp>
```
```
To define a
```CharucoBoard```
, it is necesary:
To define a
```CharucoBoard```
, it is necesary:
...
@@ -60,9 +60,9 @@ Once we have our ```CharucoBoard``` object, we can create an image to print it.
...
@@ -60,9 +60,9 @@ Once we have our ```CharucoBoard``` object, we can create an image to print it.
```
CharucoBoard::draw()``` method:
```
CharucoBoard::draw()``` method:
```
c++
```
c++
cv::
aruco::CharucoBoard
board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
cv::
Ptr
<cv::aruco::CharucoBoard>
board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
cv::Mat boardImage;
cv::Mat boardImage;
board
.
draw( cv::Size(600, 500), boardImage, 10, 1 );
board
->
draw( cv::Size(600, 500), boardImage, 10, 1 );
```
```
- The first parameter is the size of the output image in pixels. In this case 600x500 pixels. If this is not proportional
- The first parameter is the size of the output image in pixels. In this case 600x500 pixels. If this is not proportional
...
@@ -94,8 +94,8 @@ in the board.
...
@@ -94,8 +94,8 @@ in the board.
So, a detected ChArUco board consists in:
So, a detected ChArUco board consists in:
- ```
vector<
Point2f> charucoCorners``` : list of image positions of the detected corners.
- ```
std::vector<cv::
Point2f> charucoCorners``` : list of image positions of the detected corners.
- ```
vector
<int> charucoIds``` : ids for each of the detected corners in ```charucoCorners```.
- ```
std::vector
<int> charucoIds``` : ids for each of the detected corners in ```charucoCorners```.
The detection of the ChArUco corners is based on the previous detected markers. So that, first markers are detected, and then
The detection of the ChArUco corners is based on the previous detected markers. So that, first markers are detected, and then
ChArUco corners are interpolated from markers.
ChArUco corners are interpolated from markers.
...
@@ -107,11 +107,11 @@ The function that detect the ChArUco corners is ```cv::aruco::interpolateCorners
...
@@ -107,11 +107,11 @@ The function that detect the ChArUco corners is ```cv::aruco::interpolateCorners
cv::Mat cameraMatrix, distCoeffs;
cv::Mat cameraMatrix, distCoeffs;
// camera parameters are read from somewhere
// camera parameters are read from somewhere
readCameraParameters(cameraMatrix, distCoeffs);
readCameraParameters(cameraMatrix, distCoeffs);
cv::
aruco::Dictionary
dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::
Ptr
<cv::aruco::Dictionary>
dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::
aruco::CharucoBoard
board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
cv::
Ptr
<cv::aruco::CharucoBoard>
board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
...
...
vector
<
int
>
markerIds;
std::vector
<int
>
markerIds;
vector
<
vector
<
Point2f
>
> markerCorners;
std::vector
<std::vector
<
cv::Point2f
>
> markerCorners;
cv::aruco::detectMarkers(inputImage, board.dictionary, markerCorners, markerIds);
cv::aruco::detectMarkers(inputImage, board.dictionary, markerCorners, markerIds);
// if at least one marker detected
// if at least one marker detected
...
@@ -136,13 +136,13 @@ are optional. A similar example without these parameters would be:
...
@@ -136,13 +136,13 @@ are optional. A similar example without these parameters would be:
```
c++
```
c++
cv::Mat inputImage;
cv::Mat inputImage;
cv::
aruco::Dictionary
dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::
Ptr
<cv::aruco::Dictionary>
dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::
aruco::CharucoBoard
board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
cv::
Ptr
<cv::aruco::CharucoBoard>
board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
...
...
vector
<
int
>
markerIds;
std::vector
<int
>
markerIds;
vector
<
vector
<
Point2f
>
> markerCorners;
std::vector
<std::vector
<
cv::Point2f
>
> markerCorners;
DetectorParameters
params;
cv::Ptr
<cv::aruco::DetectorParameters>
params;
params
.
doCornerRefinement = false;
params
->
doCornerRefinement = false;
cv::aruco::detectMarkers(inputImage, board.dictionary, markerCorners, markerIds, params);
cv::aruco::detectMarkers(inputImage, board.dictionary, markerCorners, markerIds, params);
// if at least one marker detected
// if at least one marker detected
...
@@ -203,11 +203,11 @@ Finally, this is a full example of ChArUco detection (without using calibration
...
@@ -203,11 +203,11 @@ Finally, this is a full example of ChArUco detection (without using calibration
cv::VideoCapture inputVideo;
cv::VideoCapture inputVideo;
inputVideo.open(0);
inputVideo.open(0);
cv::
aruco::Dictionary
dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::
Ptr<cv::aruco::Dictionary>
dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::
aruco::CharucoBoard
board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
cv::
Ptr<cv::aruco::CharucoBoard>
board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
DetectorParameters
params;
cv::Ptr<cv::aruco::DetectorParameters>
params;
params
.
doCornerRefinement = false;
params
->
doCornerRefinement = false;
while (inputVideo.grab()) {
while (inputVideo.grab()) {
cv::Mat image, imageCopy;
cv::Mat image, imageCopy;
...
@@ -215,7 +215,7 @@ Finally, this is a full example of ChArUco detection (without using calibration
...
@@ -215,7 +215,7 @@ Finally, this is a full example of ChArUco detection (without using calibration
image.copyTo(imageCopy);
image.copyTo(imageCopy);
std::vector<int> ids;
std::vector<int> ids;
std::vector<std::vector<cv::Point2f>
> corners;
std::vector<std::vector<cv::Point2f>> corners;
cv::aruco::detectMarkers(image, dictionary, corners, ids, params);
cv::aruco::detectMarkers(image, dictionary, corners, ids, params);
// if at least one marker detected
// if at least one marker detected
...
@@ -286,8 +286,8 @@ A full example of ChArUco detection with pose estimation:
...
@@ -286,8 +286,8 @@ A full example of ChArUco detection with pose estimation:
// camera parameters are read from somewhere
// camera parameters are read from somewhere
readCameraParameters(cameraMatrix, distCoeffs);
readCameraParameters(cameraMatrix, distCoeffs);
cv::
aruco::Dictionary
dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::
Ptr<cv::aruco::Dictionary>
dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::
aruco::CharucoBoard
board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
cv::
Ptr<cv::aruco::CharucoBoard>
board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
while (inputVideo.grab()) {
while (inputVideo.grab()) {
cv::Mat image, imageCopy;
cv::Mat image, imageCopy;
...
@@ -295,7 +295,7 @@ A full example of ChArUco detection with pose estimation:
...
@@ -295,7 +295,7 @@ A full example of ChArUco detection with pose estimation:
image.copyTo(imageCopy);
image.copyTo(imageCopy);
std::vector<int> ids;
std::vector<int> ids;
std::vector<std::vector<cv::Point2f>
> corners;
std::vector<std::vector<cv::Point2f>> corners;
cv::aruco::detectMarkers(image, dictionary, corners, ids);
cv::aruco::detectMarkers(image, dictionary, corners, ids);
// if at least one marker detected
// if at least one marker detected
...
...
modules/aruco/tutorials/charuco_diamond_detection/charuco_diamond_detection.markdown
View file @
fa94c160
...
@@ -46,7 +46,7 @@ For instance:
...
@@ -46,7 +46,7 @@ For instance:
```
c++
```
c++
cv
::
Mat
diamondImage
;
cv
::
Mat
diamondImage
;
cv
::
aruco
::
Dictionary
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
cv
::
Ptr
<
cv
::
aruco
::
Dictionary
>
dictionary
=
cv
::
aruco
::
getPredefinedDictionary
(
cv
::
aruco
::
DICT_6X6_250
);
cv
::
aruco
::
drawCharucoDiamond
(
dictionary
,
cv
::
Vec4i
(
45
,
68
,
28
,
74
),
200
,
120
,
markerImage
);
cv
::
aruco
::
drawCharucoDiamond
(
dictionary
,
cv
::
Vec4i
(
45
,
68
,
28
,
74
),
200
,
120
,
markerImage
);
```
```
...
@@ -78,14 +78,14 @@ After detecting markers, diamond are detected using the ```detectCharucoDiamond(
...
@@ -78,14 +78,14 @@ After detecting markers, diamond are detected using the ```detectCharucoDiamond(
...
...
std
::
vector
<
int
>
markerIds
;
std
::
vector
<
int
>
markerIds
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
markerCorners
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
markerCorners
;
// detect ArUco markers
// detect ArUco markers
cv
::
aruco
::
detectMarkers
(
inputImage
,
dictionary
,
markerCorners
,
markerIds
);
cv
::
aruco
::
detectMarkers
(
inputImage
,
dictionary
,
markerCorners
,
markerIds
);
std
::
vector
<
cv
::
Vec4i
>
diamondIds
;
std
::
vector
<
cv
::
Vec4i
>
diamondIds
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
diamondCorners
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
diamondCorners
;
// detect diamon diamonds
// detect diamon diamonds
cv
::
aruco
::
detectCharucoDiamond
(
inputImage
,
markerCorners
,
markerIds
,
squareLength
/
markerLength
,
diamondCorners
,
diamondIds
);
cv
::
aruco
::
detectCharucoDiamond
(
inputImage
,
markerCorners
,
markerIds
,
squareLength
/
markerLength
,
diamondCorners
,
diamondIds
);
...
@@ -107,8 +107,8 @@ corners and ids:
...
@@ -107,8 +107,8 @@ corners and ids:
```
c++
```
c++
...
...
std
::
vector
<
cv
::
Vec4i
>
diamondIds
;
std
::
vector
<
cv
::
Vec4i
>
diamondIds
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
diamondCorners
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
diamondCorners
;
cv
::
aruco
::
detectCharucoDiamond
(
inputImage
,
markerCorners
,
markerIds
,
squareLength
/
markerLength
,
diamondCorners
,
diamondIds
);
cv
::
aruco
::
detectCharucoDiamond
(
inputImage
,
markerCorners
,
markerIds
,
squareLength
/
markerLength
,
diamondCorners
,
diamondIds
);
cv
::
aruco
::
drawDetectedDiamonds
(
inputImage
,
diamondCorners
,
diamondIds
);
cv
::
aruco
::
drawDetectedDiamonds
(
inputImage
,
diamondCorners
,
diamondIds
);
...
@@ -134,8 +134,8 @@ i.e. using the ```estimatePoseSingleMarkers()``` function. For instance:
...
@@ -134,8 +134,8 @@ i.e. using the ```estimatePoseSingleMarkers()``` function. For instance:
```
c++
```
c++
...
...
std
::
vector
<
cv
::
Vec4i
>
diamondIds
;
std
::
vector
<
cv
::
Vec4i
>
diamondIds
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
diamondCorners
;
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>
>
diamondCorners
;
// detect diamon diamonds
// detect diamon diamonds
cv
::
aruco
::
detectCharucoDiamond
(
inputImage
,
markerCorners
,
markerIds
,
squareLength
/
markerLength
,
diamondCorners
,
diamondIds
);
cv
::
aruco
::
detectCharucoDiamond
(
inputImage
,
markerCorners
,
markerIds
,
squareLength
/
markerLength
,
diamondCorners
,
diamondIds
);
...
...
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