33 #include <opencv2/highgui/highgui.hpp>    35 using namespace aruco;
    38 class CmdLineParser{
int argc; 
char **argv; 
public: 
CmdLineParser(
int _argc,
char **_argv):argc(_argc),argv(_argv){}  
bool operator[] ( 
string param ) {
int idx=-1;  
for ( 
int i=0; i<argc && idx==-1; i++ ) 
if ( 
string ( argv[i] ) ==param ) idx=i;    
return ( idx!=-1 ) ;    } 
string operator()(
string param,
string defvalue=
"-1"){
int idx=-1;    
for ( 
int i=0; i<argc && idx==-1; i++ ) 
if ( 
string ( argv[i] ) ==param ) idx=i; 
if ( idx==-1 ) 
return defvalue;   
else  return ( argv[  idx+1] ); }};
    40 int main(
int argc, 
char **argv) {
    43         if (argc ==1 || cml[
"-h"] ){
    44             cerr << 
"Usage: (in_image|video.avi) [-c cameraParams.yml] [-s markerSize] [-d <dicionary>:ARUCO default] [-o <outImage>] " << endl;
    46             cout<<
"Example to work with apriltags dictionary : video.avi -d TAG36h11"<<endl<<endl;
    56         VideoCapture vreader(argv[1]);
    57         if (vreader.isOpened()) vreader>>InImage;
    58         else{cerr<<
"Could not open input"<<endl;
return -1;}
    62         float MarkerSize = std::stof(cml(
"-s",
"-1"));
    73         vector< Marker >  Markers=MDetector.
detect(InImage, CamParam, MarkerSize);
    76         for (
unsigned int i = 0; i < Markers.size(); i++) {
    77             cout << Markers[i] << endl;
    78             Markers[i].draw(InImage, Scalar(0, 0, 255), 2);
    81         if (CamParam.
isValid() && MarkerSize != -1)
    82             for (
unsigned int i = 0; i < Markers.size(); i++) {
    83                 CvDrawingUtils::draw3dCube(InImage, Markers[i], CamParam);
    86         cv::namedWindow(
"in", 1);
    87         cv::imshow(
"in", InImage);
    88         while( 
char(cv::waitKey(0))!=27); 
    91         if (cml[
"-o"]) cv::imwrite(cml(
"-o"), InImage);
    92     } 
catch (std::exception &ex)
    95         cout << 
"Exception :" << ex.what() << endl;
 void setThresholdParams(double param1, double param2)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val)
int main(int argc, char **argv)
static std::vector< std::string > getDicTypes()
void setDictionary(std::string dict_type, float error_correction_rate=0)
std::vector< aruco::Marker > detect(const cv::Mat &input)
void readFromXMLFile(string filePath)
void setThresholdParamRange(size_t r1=0, size_t r2=0)
Main class for marker detection. 
Parameters of the camera.