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,
 
  105     detector.detectMarkers(croppedImageGray,
 
  111     for (
auto& corner : corners)
 
  113         for (
auto& j : corner)
 
  125             cv::aruco::drawDetectedMarkers(imageBgr,
 
  128                                            cv::Scalar(0, 0, 255));
 
  138         cv::aruco::estimatePoseSingleMarkers(corners,
 
  148         for (
size_t i = 0; i < 
arucoIDs.size(); ++i)
 
  155 #if CV_MAJOR_VERSION < 4 || CV_MINOR_VERSION < 6 
  157                 cv::drawFrameAxes(imageBgr,
 
  187                                           const string& imgName,
 
  191 #if CV_MAJOR_VERSION < 4 || CV_MINOR_VERSION < 7 
  192     cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::PREDEFINED_DICTIONARY_NAME(dictionaryId));
 
  193     cv::Ptr<cv::aruco::GridBoard>  board      = cv::aruco::GridBoard::create(numMarkersX,
 
  199     imageSize.width  = (int)((markerEdgeM + markerSepaM) * 100.0f / 2.54f * 
dpi * (float)numMarkersX);
 
  200     imageSize.height = (int)((markerEdgeM + markerSepaM) * 100.0f / 2.54f * 
dpi * (float)numMarkersY);
 
  202     imageSize.width -= (imageSize.width % 4);
 
  203     imageSize.height -= (imageSize.height % 4);
 
  207     board->draw(imageSize, boardImage, 0, 1);
 
  211         imshow(
"board", boardImage);
 
  215     cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::PredefinedDictionaryType(dictionaryId));
 
  216     cv::aruco::GridBoard  board      = cv::aruco::GridBoard(cv::Size(numMarkersX, numMarkersY),
 
  222     imageSize.width  = (int)((markerEdgeM + markerSepaM) * 100.0f / 2.54f * 
dpi * (float)numMarkersX);
 
  223     imageSize.height = (int)((markerEdgeM + markerSepaM) * 100.0f / 2.54f * 
dpi * (float)numMarkersY);
 
  225     imageSize.width -= (imageSize.width % 4);
 
  226     imageSize.height -= (imageSize.height % 4);
 
  230     cv::aruco::drawPlanarBoard(&board,
 
  235 #    ifndef __EMSCRIPTEN__ 
  238         imshow(
"board", boardImage);
 
  244 #ifndef __EMSCRIPTEN__ 
  245     imwrite(imgName, boardImage);
 
  254     assert(dictionaryId > 0);
 
  255     assert(minMarkerId > 0);
 
  256     assert(minMarkerId < maxMarkerId);
 
  258 #if CV_MAJOR_VERSION < 4 || CV_MINOR_VERSION < 7 
  259     cv::Ptr<cv::aruco::Dictionary> dict = getPredefinedDictionary(cv::aruco::PREDEFINED_DICTIONARY_NAME(dictionaryId));
 
  260     if (maxMarkerId > dict->bytesList.rows)
 
  261         maxMarkerId = dict->bytesList.rows;
 
  265     for (
int i = minMarkerId; i < maxMarkerId; ++i)
 
  267         cv::aruco::drawMarker(dict, i, markerSizePX, markerImg, 1);
 
  268 #    ifndef __EMSCRIPTEN__ 
  277     cv::aruco::Dictionary dict = getPredefinedDictionary(cv::aruco::PredefinedDictionaryType(dictionaryId));
 
  278     if (maxMarkerId > dict.bytesList.rows)
 
  279         maxMarkerId = dict.bytesList.rows;
 
  283     for (
int i = minMarkerId; i < maxMarkerId; ++i)
 
  285         cv::aruco::generateImageMarker(dict,
 
  290 #    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.