Commit a1b3c84c authored by atinfinity's avatar atinfinity Committed by Vadim Pisarevsky

updated aruco tutorial (#1263)

parent 68736a2c
......@@ -26,14 +26,14 @@ corners) are employed.
The aruco module allows the use of Boards. The main class is the ```cv::aruco::Board``` class which defines the Board layout:
``` c++
@code{.cpp}
class Board {
public:
std::vector<std::vector<cv::Point3f> > objPoints;
cv::Ptr<cv::aruco::Dictionary> dictionary;
std::vector<int> ids;
};
```
@endcode
A object of type ```Board``` has three parameters:
- The ```objPoints``` structure is the list of corner positions in the 3d Board reference system, i.e. its layout.
......@@ -51,7 +51,7 @@ In fact, to use marker boards, a standard marker detection should be done before
The aruco module provides a specific function, ```estimatePoseBoard()```, to perform pose estimation for boards:
``` c++
@code{.cpp}
cv::Mat inputImage;
// camera parameters are read from somewhere
cv::Mat cameraMatrix, distCoeffs;
......@@ -67,7 +67,7 @@ The aruco module provides a specific function, ```estimatePoseBoard()```, to per
cv::Vec3d rvec, tvec;
int valid = cv::aruco::estimatePoseBoard(markerCorners, markerIds, board, cameraMatrix, distCoeffs, rvec, tvec);
}
```
@endcode
The parameters of estimatePoseBoard are:
......@@ -120,9 +120,9 @@ A ```GridBoard``` object can be defined using the following parameters:
This object can be easily created from these parameters using the ```cv::aruco::GridBoard::create()``` static function:
``` c++
@code{.cpp}
cv::aruco::GridBoard board = cv::aruco::GridBoard::create(5, 7, 0.04, 0.01, dictionary);
```
@endcode
- The first and second parameters are the number of markers in the X and Y direction respectively.
- The third and fourth parameters are the marker length and the marker separation respectively. They can be provided
......@@ -136,11 +136,11 @@ through ```board.ids```, like in the ```Board``` parent class.
After creating a Grid Board, we probably want to print it and use it. A function to generate the image
of a ```GridBoard``` is provided in ```cv::aruco::GridBoard::draw()```. For example:
``` c++
@code{.cpp}
cv::Ptr<cv::aruco::GridBoard> board = cv::aruco::GridBoard::create(5, 7, 0.04, 0.01, dictionary);
cv::Mat boardImage;
board->draw( cv::Size(600, 500), boardImage, 10, 1 );
```
@endcode
- The first parameter is the size of the output image in pixels. In this case 600x500 pixels. If this is not proportional
to the board dimensions, it will be centered on the image.
......@@ -156,13 +156,13 @@ The output image will be something like this:
A full working example of board creation is included in the ```create_board.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
@code{.cpp}
"_output path_/aboard.png" -w=5 -h=7 -l=100 -s=10 -d=10
```
@endcode
Finally, a full example of board detection:
``` c++
@code{.cpp}
cv::VideoCapture inputVideo;
inputVideo.open(0);
......@@ -199,7 +199,7 @@ Finally, a full example of board detection:
if (key == 27)
break;
}
```
@endcode
Sample video:
......@@ -210,9 +210,9 @@ Sample video:
A full working example is included in the ```detect_board.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
@code{.cpp}
-c="_path_"/calib.txt" "_path_/aboard.png" -w=5 -h=7 -l=100 -s=10 -d=10
```
@endcode
......@@ -255,7 +255,7 @@ internal bits are not analyzed at all and only the corner distances are evaluate
This is an example of using the ```refineDetectedMarkers()``` function:
``` c++
@code{.cpp}
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::Ptr<cv::aruco::GridBoard> board = cv::aruco::GridBoard::create(5, 7, 0.04, 0.01, dictionary);
std::vector<int> markerIds;
......@@ -265,7 +265,7 @@ This is an example of using the ```refineDetectedMarkers()``` function:
cv::aruco::refineDetectedMarkersinputImage, board, markerCorners, markerIds, rejectedCandidates);
// After calling this function, if any new marker has been detected it will be removed from rejectedCandidates and included
// at the end of markerCorners and markerIds
```
@endcode
It must also be noted that, in some cases, if the number of detected markers in the first place is too low (for instance only
1 or 2 markers), the projections of the missing markers can be of bad quality, producing erroneous correspondences.
......
......@@ -32,7 +32,7 @@ visible in all the viewpoints.
The function to calibrate is ```calibrateCameraCharuco()```. Example:
``` c++
@code{.cpp}
cv::Ptr<aruco::CharucoBoard> board = ... // create charuco board
cv::Size imgSize = ... // camera image size
......@@ -48,7 +48,7 @@ The function to calibrate is ```calibrateCameraCharuco()```. Example:
int calibrationFlags = ... // Set calibration flags (same than in calibrateCamera() function)
double repError = cv::aruco::calibrateCameraCharuco(allCharucoCorners, allCharucoIds, board, imgSize, cameraMatrix, distCoeffs, rvecs, tvecs, calibrationFlags);
```
@endcode
The ChArUco corners and ChArUco identifiers captured on each viewpoint are stored in the vectors ```allCharucoCorners``` and ```allCharucoIds```, one element per viewpoint.
......@@ -62,9 +62,9 @@ Finally, the ```calibrationFlags``` parameter determines some of the options for
A full working example is included in the ```calibrate_camera_charuco.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
@code{.cpp}
_output path_" -dp="_path_/detector_params.yml" -w=5 -h=7 -sl=0.04 -ml=0.02 -d=10
```
@endcode
......@@ -80,7 +80,7 @@ requires the detections of an ArUco board from different viewpoints.
Example of ```calibrateCameraAruco()``` use:
``` c++
@code{.cpp}
cv::Ptr<aruco::Board> board = ... // create aruco board
cv::Size imgSize = ... // camera image size
......@@ -97,7 +97,7 @@ Example of ```calibrateCameraAruco()``` use:
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);
```
@endcode
In this case, and contrary to the ```calibrateCameraCharuco()``` function, the detected markers on each viewpoint are concatenated in the arrays ```allCornersConcatenated``` and
```allCornersConcatenated``` (the first two parameters). The third parameter, the array ```markerCounterPerFrame```, indicates the number of marker detected on each viewpoint.
......@@ -107,6 +107,6 @@ any ```Board``` object.
A full working example is included in the ```calibrate_camera.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
@code{.cpp}
"_path_/calib.txt" -w=5 -h=7 -l=100 -s=10 -d=10
```
@endcode
......@@ -19,9 +19,9 @@ a popular library for detection of square fiducial markers developed by Rafael M
> Pattern Recogn. 47, 6 (June 2014), 2280-2292. DOI=10.1016/j.patcog.2014.01.005
The aruco functionalities are included in:
``` c++
@code{.cpp}
#include <opencv2/aruco.hpp>
```
@endcode
Markers and Dictionaries
......@@ -69,11 +69,11 @@ Marker images can be generated using the ```drawMarker()``` function.
For example, lets analyze the following call:
``` c++
@code{.cpp}
cv::Mat markerImage;
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::aruco::drawMarker(dictionary, 23, 200, markerImage, 1);
```
@endcode
First, the ```Dictionary``` object is created by choosing one of the predefined dictionaries in the aruco module.
Concretely, this dictionary is composed by 250 markers and a marker size of 6x6 bits (```DICT_6X6_250```).
......@@ -104,9 +104,9 @@ The generated image is:
A full working example is included in the ```create_marker.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
@code{.cpp}
"/Users/Sarthak/Dropbox/OpenCV_GSoC/marker.png" -d=10 -id=1
```
@endcode
Marker Detection
------
......@@ -153,7 +153,7 @@ previous detected markers returned by ```detectMarkers()```.
An example of marker detection:
``` c++
@code{.cpp}
cv::Mat inputImage;
...
std::vector<int> markerIds;
......@@ -161,7 +161,7 @@ An example of marker detection:
cv::Ptr<cv::aruco::DetectorParameters> parameters;
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::aruco::detectMarkers(inputImage, dictionary, markerCorners, markerIds, parameters, rejectedCandidates);
```
@endcode
The parameters of ```detectMarkers``` are:
......@@ -185,10 +185,10 @@ The next thing you probably want to do after ```detectMarkers()``` is checking t
been correctly detected. Fortunately, the aruco module provides a function to draw the detected
markers in the input image, this function is ```drawDetectedMarkers()```. For example:
``` c++
@code{.cpp}
cv::Mat outputImage
cv::aruco::drawDetectedMarkers(image, markerCorners, markerIds);
```
@endcode
- ```image``` is the input/output image where the markers will be drawn (it will normally be the same image where the markers were detected).
- ```markerCorners``` and ```markerIds``` are the structures of the detected markers in the same format
......@@ -201,7 +201,7 @@ Note that this function is only provided for visualization and its use can be pe
With these two functions we can create a basic marker detection loop to detect markers from our
camera:
``` c++
@code{.cpp}
cv::VideoCapture inputVideo;
inputVideo.open(0);
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
......@@ -223,7 +223,7 @@ camera:
if (key == 27)
break;
}
```
@endcode
Note that some of the optional parameters have been omitted, like the detection parameter object or the
output vector of rejected candidates.
......@@ -231,9 +231,9 @@ output vector of rejected candidates.
A full working example is included in the ```detect_markers.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
@code{.cpp}
-c="_path_/calib.txt" -d=10
```
@endcode
......@@ -262,12 +262,12 @@ information).
The aruco module provides a function to estimate the poses of all the detected markers:
``` c++
@code{.cpp}
cv::Mat cameraMatrix, distCoeffs;
...
std::vector<cv::Vec3d> rvecs, tvecs;
cv::aruco::estimatePoseSingleMarkers(corners, 0.05, cameraMatrix, distCoeffs, rvecs, tvecs);
```
@endcode
- The ```corners``` parameter is the vector of marker corners returned by the ```detectMarkers()``` function.
- The second parameter is the size of the marker side in meters or in any other unit. Note that the
......@@ -284,9 +284,9 @@ with the Z axis pointing out, as in the following image. Axis-color corresponden
The aruco module provides a function to draw the axis as in the image above, so pose estimation can be
checked:
``` c++
@code{.cpp}
cv::aruco::drawAxis(image, cameraMatrix, distCoeffs, rvec, tvec, 0.1);
```
@endcode
- ```image``` is the input/output image where the axis will be drawn (it will normally be the same image where the markers were detected).
- ```cameraMatrix``` and ```distCoeffs``` are the camera calibration parameters.
......@@ -295,7 +295,7 @@ checked:
A basic full example for pose estimation from single markers:
``` c++
@code{.cpp}
cv::VideoCapture inputVideo;
inputVideo.open(0);
......@@ -330,7 +330,7 @@ A basic full example for pose estimation from single markers:
if (key == 27)
break;
}
```
@endcode
Sample video:
......@@ -341,9 +341,9 @@ Sample video:
A full working example is included in the ```detect_markers.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
@code{.cpp}
-c="_path_/calib.txt" -d=10
```
@endcode
......@@ -373,9 +373,9 @@ you can increase your system robustness:
This is the easiest way to select a dictionary. The aruco module includes a set of predefined dictionaries
of a variety of marker sizes and number of markers. For instance:
``` c++
@code{.cpp}
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
```
@endcode
DICT_6X6_250 is an example of predefined dictionary of markers with 6x6 bits and a total of 250
markers.
......@@ -389,9 +389,9 @@ The smaller the dictionary, the higher the inter-marker distance.
The dictionary can be generated automatically to adjust to the desired number of markers and bits, so that
the inter-marker distance is optimized:
``` c++
@code{.cpp}
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::generateCustomDictionary(36, 5);
```
@endcode
This will generate a customized dictionary composed by 36 markers of 5x5 bits. The process can take several
seconds, depending on the parameters (it is slower for larger dictionaries and higher number of bits).
......@@ -405,7 +405,7 @@ the ```Dictionary``` object parameters need to be assigned manually. It must be
The ```Dictionary``` parameters are:
``` c++
@code{.cpp}
class Dictionary {
public:
......@@ -416,10 +416,9 @@ The ```Dictionary``` parameters are:
...
}
@endcode
```
```bytesList``` is the array that contains all the information about the marker codes. ```markerSize``` is the size
<code>bytesList</code> is the array that contains all the information about the marker codes. ```markerSize``` is the size
of each marker dimension (for instance, 5 for markers with 5x5 bits). Finally, ```maxCorrectionBits``` is
the maximum number of erroneous bits that can be corrected during the marker detection. If this value is too
high, it can lead to a high amount of false positives.
......@@ -431,7 +430,7 @@ Fortunately, a marker can be easily transformed to this form using the static me
For example:
``` c++
@code{.cpp}
cv::aruco::Dictionary dictionary;
// markers of 6x6 bits
dictionary.markerSize = 6;
......@@ -448,8 +447,7 @@ For example:
// add the marker as a new row
dictionary.bytesList.push_back(markerCompressed);
}
```
@endcode
......
......@@ -28,9 +28,9 @@ The aruco module provides the ```cv::aruco::CharucoBoard``` class that represent
This class, as the rest of ChArUco functionalities, are defined in:
``` c++
@code{.cpp}
#include <opencv2/aruco/charuco.hpp>
```
@endcode
To define a ```CharucoBoard```, it is necesary:
......@@ -44,9 +44,9 @@ To define a ```CharucoBoard```, it is necesary:
As for the ```GridBoard``` objects, the aruco module provides a function to create ```CharucoBoard```s easily. This function
is the static function ```cv::aruco::CharucoBoard::create()``` :
``` c++
@code{.cpp}
cv::aruco::CharucoBoard board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
```
@endcode
- The first and second parameters are the number of squares in X and Y direction respectively.
- The third and fourth parameters are the length of the squares and the markers respectively. They can be provided
......@@ -57,13 +57,13 @@ The ids of each of the markers are assigned by default in ascending order and st
This can be easily customized by accessing to the ids vector through ```board.ids```, like in the ```Board``` parent class.
Once we have our ```CharucoBoard``` object, we can create an image to print it. This can be done with the
```CharucoBoard::draw()``` method:
<code>CharucoBoard::draw()</code> method:
``` c++
@code{.cpp}
cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
cv::Mat boardImage;
board->draw( cv::Size(600, 500), boardImage, 10, 1 );
```
@endcode
- The first parameter is the size of the output image in pixels. In this case 600x500 pixels. If this is not proportional
to the board dimensions, it will be centered on the image.
......@@ -79,9 +79,9 @@ The output image will be something like this:
A full working example is included in the ```create_board_charuco.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
@code{.cpp}
"_ output path_/chboard.png" -w=5 -h=7 -sl=200 -ml=120 -d=10
```
@endcode
ChArUco Board Detection
......@@ -102,7 +102,7 @@ ChArUco corners are interpolated from markers.
The function that detect the ChArUco corners is ```cv::aruco::interpolateCornersCharuco()``` . This example shows the whole process. First, markers are detected, and then the ChArUco corners are interpolated from these markers.
``` c++
@code{.cpp}
cv::Mat inputImage;
cv::Mat cameraMatrix, distCoeffs;
// camera parameters are read from somewhere
......@@ -120,7 +120,7 @@ The function that detect the ChArUco corners is ```cv::aruco::interpolateCorners
std::vector<int> charucoIds;
cv::aruco::interpolateCornersCharuco(markerCorners, markerIds, inputImage, board, charucoCorners, charucoIds, cameraMatrix, distCoeffs);
}
```
@endcode
The parameters of the ```interpolateCornersCharuco()``` function are:
- ```markerCorners``` and ```markerIds```: the detected markers from ```detectMarkers()``` function.
......@@ -134,7 +134,7 @@ in the ChArUco corners.
In this case, we have call ```interpolateCornersCharuco()``` providing the camera calibration parameters. However these parameters
are optional. A similar example without these parameters would be:
``` c++
@code{.cpp}
cv::Mat inputImage;
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
......@@ -151,7 +151,7 @@ are optional. A similar example without these parameters would be:
std::vector<int> charucoIds;
cv::aruco::interpolateCornersCharuco(markerCorners, markerIds, inputImage, board, charucoCorners, charucoIds);
}
```
@endcode
If calibration parameters are provided, the ChArUco corners are interpolated by, first, estimating a rough pose from the ArUco markers
and, then, reprojecting the ChArUco corners back to the image.
......@@ -176,9 +176,9 @@ After the ChArUco corners have been interpolated, a subpixel refinement is perfo
Once we have interpolated the ChArUco corners, we would probably want to draw them to see if their detections are correct.
This can be easily done using the ```drawDetectedCornersCharuco()``` function:
``` c++
@code{.cpp}
cv::aruco::drawDetectedCornersCharuco(image, charucoCorners, charucoIds, color);
```
@endcode
- ```image``` is the image where the corners will be drawn (it will normally be the same image where the corners were detected).
- The ```outputImage``` will be a clone of ```inputImage``` with the corners drawn.
......@@ -199,7 +199,7 @@ In the presence of occlusion. like in the following image, although some corners
Finally, this is a full example of ChArUco detection (without using calibration parameters):
``` c++
@code{.cpp}
cv::VideoCapture inputVideo;
inputVideo.open(0);
......@@ -235,7 +235,7 @@ Finally, this is a full example of ChArUco detection (without using calibration
if (key == 27)
break;
}
```
@endcode
Sample video:
......@@ -246,9 +246,9 @@ Sample video:
A full working example is included in the ```detect_board_charuco.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
@code{.cpp}
-c="_path_/calib.txt" -dp="_path_/detector_params.yml" -w=5 -h=7 -sl=0.04 -ml=0.02 -d=10
```
@endcode
ChArUco Pose Estimation
------
......@@ -260,9 +260,9 @@ of the ```CharucoBoard``` is placed in the board plane with the Z axis pointing
The function for pose estimation is ```estimatePoseCharucoBoard()```:
``` c++
@code{.cpp}
cv::aruco::estimatePoseCharucoBoard(charucoCorners, charucoIds, board, cameraMatrix, distCoeffs, rvec, tvec);
```
@endcode
- The ```charucoCorners``` and ```charucoIds``` parameters are the detected charuco corners from the ```interpolateCornersCharuco()```
function.
......@@ -278,7 +278,7 @@ The axis can be drawn using ```drawAxis()``` to check the pose is correctly esti
A full example of ChArUco detection with pose estimation:
``` c++
@code{.cpp}
cv::VideoCapture inputVideo;
inputVideo.open(0);
......@@ -319,11 +319,11 @@ A full example of ChArUco detection with pose estimation:
if (key == 27)
break;
}
```
@endcode
A full working example is included in the ```detect_board_charuco.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
@code{.cpp}
"_path_/calib.txt" -dp="_path_/detector_params.yml" -w=5 -h=7 -sl=0.04 -ml=0.02 -d=10
```
@endcode
......@@ -44,11 +44,11 @@ ChArUco Diamond Creation
The image of a diamond marker can be easily created using the ```drawCharucoDiamond()``` function.
For instance:
``` c++
@code{.cpp}
cv::Mat diamondImage;
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);
```
@endcode
This will create a diamond marker image with a square size of 200 pixels and a marker size of 120 pixels.
The marker ids are given in the second parameter as a ```Vec4i``` object. The order of the marker ids
......@@ -61,9 +61,9 @@ The image produced will be:
A full working example is included in the ```create_diamond.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
@code{.cpp}
"_path_/mydiamond.png" -sl=200 -ml=120 -d=10 -ids=45,68,28,74
```
@endcode
ChArUco Diamond Detection
------
......@@ -71,7 +71,7 @@ ChArUco Diamond Detection
As in most cases, the detection of diamond markers requires a previous detection of ArUco markers.
After detecting markers, diamond are detected using the ```detectCharucoDiamond()``` function:
``` c++
@code{.cpp}
cv::Mat inputImage;
float squareLength = 0.40;
float markerLength = 0.25;
......@@ -89,7 +89,7 @@ After detecting markers, diamond are detected using the ```detectCharucoDiamond(
// detect diamon diamonds
cv::aruco::detectCharucoDiamond(inputImage, markerCorners, markerIds, squareLength / markerLength, diamondCorners, diamondIds);
```
@endcode
The ```detectCharucoDiamond()``` function receives the original image and the previous detected marker corners and ids.
The input image is necessary to perform subpixel refinement in the ChArUco corners.
......@@ -105,14 +105,14 @@ diamond corners in ```diamondCorners```. Each id is actually an array of 4 integ
The detected diamond can be visualized using the function ```drawDetectedDiamonds()``` which simply recieves the image and the diamond
corners and ids:
``` c++
@code{.cpp}
...
std::vector<cv::Vec4i> diamondIds;
std::vector<std::vector<cv::Point2f>> diamondCorners;
cv::aruco::detectCharucoDiamond(inputImage, markerCorners, markerIds, squareLength / markerLength, diamondCorners, diamondIds);
cv::aruco::drawDetectedDiamonds(inputImage, diamondCorners, diamondIds);
```
@endcode
The result is the same that the one produced by ```drawDetectedMarkers()```, but printing the four ids of the diamond:
......@@ -121,9 +121,9 @@ The result is the same that the one produced by ```drawDetectedMarkers()```, but
A full working example is included in the ```detect_diamonds.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
@code{.cpp}
-c="_path_/calib.txt" -dp="_path_/detector_params.yml" -sl=0.04 -ml=0.02 -d=10
```
@endcode
ChArUco Diamond Pose Estimation
------
......@@ -131,7 +131,7 @@ ChArUco Diamond Pose Estimation
Since a ChArUco diamond is represented by its four corners, its pose can be estimated in the same way than in a single ArUco marker,
i.e. using the ```estimatePoseSingleMarkers()``` function. For instance:
``` c++
@code{.cpp}
...
std::vector<cv::Vec4i> diamondIds;
......@@ -147,7 +147,7 @@ i.e. using the ```estimatePoseSingleMarkers()``` function. For instance:
// draw axis
for(unsigned int i=0; i<rvecs.size(); i++)
cv::aruco::drawAxis(inputImage, camMatrix, distCoeffs, rvecs[i], tvecs[i], axisLength);
```
@endcode
The function will obtain the rotation and translation vector for each of the diamond marker and store them
in ```rvecs``` and ```tvecs```. Note that the diamond corners are a chessboard square corners and thus, the square length
......@@ -169,6 +169,6 @@ Sample video:
A full working example is included in the ```detect_diamonds.cpp``` inside the module samples folder.
Note: The samples now take input via commandline via the [OpenCV Commandline Parser](http://docs.opencv.org/trunk/d0/d2e/classcv_1_1CommandLineParser.html#gsc.tab=0). For this file the example parameters will look like
``` c++
@code{.cpp}
-c="_output path_/calib.txt" -dp="_path_/detector_params.yml" -sl=0.04 -ml=0.02 -d=10
```
@endcode
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment