24 : _calibIniPath(calibIniPath),
31 "CVTrackedAruco::track: Failed to load Aruco parameters.",
41 if (!
trackAll(imageGray, imageBgr, calib))
49 for (
size_t i = 0; i <
arucoIDs.size(); ++i)
69 assert(!imageGray.empty() &&
"ImageGray is empty");
70 assert(!imageBgr.empty() &&
"ImageBGR is empty");
71 assert(!calib->
cameraMat().empty() &&
"Calibration is empty");
73 #if CV_MAJOR_VERSION < 4 || CV_MINOR_VERSION < 7
77 "CVTrackedAruco::track: Aruco paramters are empty.",
88 CVMat croppedImageGray = roi.empty() ? imageGray : imageGray(roi);
96 #if CV_MAJOR_VERSION < 4 || CV_MINOR_VERSION < 7
97 cv::aruco::detectMarkers(croppedImageGray,
106 detector.detectMarkers(croppedImageGray,
112 for (
auto& corner : corners)
114 for (
auto& j : corner)
126 cv::aruco::drawDetectedMarkers(imageBgr,
129 cv::Scalar(0, 0, 255));
139 cv::aruco::estimatePoseSingleMarkers(corners,
149 for (
size_t i = 0; i <
arucoIDs.size(); ++i)
156 #if CV_MAJOR_VERSION < 4 || CV_MINOR_VERSION < 6
158 cv::drawFrameAxes(imageBgr,
189 const string& imgName,
193 #if CV_MAJOR_VERSION < 4 || CV_MINOR_VERSION < 7
194 cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::PREDEFINED_DICTIONARY_NAME(dictionaryId));
195 cv::Ptr<cv::aruco::GridBoard> board = cv::aruco::GridBoard::create(numMarkersX,
201 imageSize.width = (int)((markerEdgeM + markerSepaM) * 100.0f / 2.54f *
dpi * (float)numMarkersX);
202 imageSize.height = (int)((markerEdgeM + markerSepaM) * 100.0f / 2.54f *
dpi * (float)numMarkersY);
204 imageSize.width -= (imageSize.width % 4);
205 imageSize.height -= (imageSize.height % 4);
209 board->draw(imageSize, boardImage, 0, 1);
213 imshow(
"board", boardImage);
217 cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::PredefinedDictionaryType(dictionaryId));
218 cv::aruco::GridBoard board = cv::aruco::GridBoard(cv::Size(numMarkersX, numMarkersY),
224 imageSize.width = (int)((markerEdgeM + markerSepaM) * 100.0f / 2.54f *
dpi * (float)numMarkersX);
225 imageSize.height = (int)((markerEdgeM + markerSepaM) * 100.0f / 2.54f *
dpi * (float)numMarkersY);
227 imageSize.width -= (imageSize.width % 4);
228 imageSize.height -= (imageSize.height % 4);
232 cv::aruco::drawPlanarBoard(&board,
237 # ifndef __EMSCRIPTEN__
240 imshow(
"board", boardImage);
246 #ifndef __EMSCRIPTEN__
247 imwrite(imgName, boardImage);
256 assert(dictionaryId > 0);
257 assert(minMarkerId > 0);
258 assert(minMarkerId < maxMarkerId);
260 #if CV_MAJOR_VERSION < 4 || CV_MINOR_VERSION < 7
261 cv::Ptr<cv::aruco::Dictionary> dict = getPredefinedDictionary(cv::aruco::PREDEFINED_DICTIONARY_NAME(dictionaryId));
262 if (maxMarkerId > dict->bytesList.rows)
263 maxMarkerId = dict->bytesList.rows;
267 for (
int i = minMarkerId; i < maxMarkerId; ++i)
269 cv::aruco::drawMarker(dict, i, markerSizePX, markerImg, 1);
270 # ifndef __EMSCRIPTEN__
279 cv::aruco::Dictionary dict = getPredefinedDictionary(cv::aruco::PredefinedDictionaryType(dictionaryId));
280 if (maxMarkerId > dict.bytesList.rows)
281 maxMarkerId = dict.bytesList.rows;
285 for (
int i = minMarkerId; i < maxMarkerId; ++i)
287 cv::aruco::generateImageMarker(dict,
292 # ifndef __EMSCRIPTEN__
static SLint dpi
Dot per inch resolution of screen.
vector< cv::Point3d > CVVPoint3d
vector< vector< cv::Point2f > > CVVVPoint2f
#define PROFILE_FUNCTION()
bool loadFromFile(string calibIniPath)
cv::Ptr< cv::aruco::DetectorParameters > arucoParams
detector parameter structure for aruco detection function
float edgeLength
marker edge length
cv::Ptr< cv::aruco::Dictionary > dictionary
predefined dictionary
Live video camera calibration class with OpenCV an OpenCV calibration.
const CVMat & cameraMat() const
const CVMat & distortion() const
bool track(CVMat imageGray, CVMat imageBgr, CVCalibration *calib)
Tracks the all Aruco markers in the given image for the first sceneview.
static void drawArucoMarkerBoard(int dictionaryId, int numMarkersX, int numMarkersY, float markerEdgeLengthM, float markerSepaM, const string &imgName, float dpi=254.0f, bool showImage=false)
Helper function to draw and save an aruco marker board image.
CVArucoParams _params
Aruco parameters.
int _arucoID
Aruco Marker ID for this node.
static void drawArucoMarker(int dictionaryId, int minMarkerId, int maxMarkerId, int markerSizePX=200)
Helper function to draw and save an aruco marker set.
CVTrackedAruco(int arucoID, string calibIniPath)
bool trackAll(CVMat imageGray, CVMat imageBgr, CVCalibration *calib, CVRect roi=CVRect(0, 0, 0, 0))
vector< int > arucoIDs
detected Aruco marker IDs
CVVMatx44f objectViewMats
object view matrices for all found markers
CVMatx44f _objectViewMat
view transformation matrix
static AvgFloat detectTimesMS
Averaged time for video feature detection & description in ms.
bool _drawDetection
Flag if detection should be drawn into image.
static cv::Matx44f createGLMatrix(const CVMat &tVec, const CVMat &rVec)
Create an OpenGL 4x4 matrix from an OpenCV translation & rotation vector.
HighResTimer _timer
High resolution timer.
static AvgFloat poseTimesMS
Averaged time for video feature pose estimation in ms.
float elapsedTimeInMilliSec()
void set(T value)
Sets the current value in the value array and builds the average.
string formatString(string fmt_str,...)
Returns a formatted string as sprintf.
void warnMsg(const char *tag, const char *msg, const int line, const char *file)
Platform independent warn message output.
void exitMsg(const char *tag, const char *msg, const int line, const char *file)
Terminates the application with a message. No leak checking.