aruco_print_marker.cpp
Go to the documentation of this file.
1 /*****************************
2 Copyright 2011 Rafael Muñoz Salinas. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without modification, are
5 permitted provided that the following conditions are met:
6 
7  1. Redistributions of source code must retain the above copyright notice, this list of
8  conditions and the following disclaimer.
9 
10  2. Redistributions in binary form must reproduce the above copyright notice, this list
11  of conditions and the following disclaimer in the documentation and/or other materials
12  provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY Rafael Muñoz Salinas ''AS IS'' AND ANY EXPRESS OR IMPLIED
15 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Rafael Muñoz Salinas OR
17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 
24 The views and conclusions contained in the software and documentation are those of the
25 authors and should not be interpreted as representing official policies, either expressed
26 or implied, of Rafael Muñoz Salinas.
27 ********************************/
28 //saves to file an image of the indicated marker from the dictionary indicated
29 
30 #include <opencv2/highgui/highgui.hpp>
31 #include <iostream>
32 #include "aruco.h"
33 using namespace cv;
34 using namespace std;
35 
36 //convinience command line parser
37 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] ); }};
38 
39 
40 int main(int argc, char **argv) {
41  try {
42  if (argc < 2) {
43  // You can also use ids 2000-2007 but it is not safe since there are a lot of false positives.
44  cerr << "Usage: <makerid> outfile.(jpg|png|ppm|bmp) [options] \n\t[-bs <size>:bit size in pixels. 50 by default ] \n\t[-d <dictionary>: ARUCO default]" << endl;
45  auto dict_names=aruco::Dictionary::getDicTypes();
46  cerr<<"\t\tDictionaries: ";
47  for(auto dict:dict_names) cerr<<dict<<" ";cerr<<endl;
48  return -1;
49  }
50  CmdLineParser cml(argc,argv);
51  int pixSize = std::stoi( cml("-bs","75"));//pixel size each each bit
52  //loads the desired dictionary
54 
55  cv::imwrite(argv[2], dic.getMarkerImage_id(stoi(argv[1]),pixSize));
56 
57  } catch (std::exception &ex) {
58  cout << ex.what() << endl;
59  }
60 }
cv::Mat getMarkerImage_id(int id, int bit_size, bool addWaterMark=true)
Dictionary::getMarkerImage_id.
Definition: dictionary.cpp:191
bool param(const std::string &param_name, T &param_val, const T &default_val)
static std::vector< std::string > getDicTypes()
Definition: dictionary.cpp:270
static Dictionary loadPredefined(DICT_TYPES type)
Definition: dictionary.cpp:63
int main(int argc, char **argv)


tuw_aruco
Author(s): Lukas Pfeifhofer
autogenerated on Mon Jun 10 2019 15:40:45