27 int main(
int argc,
char **argv)
31 printf(
"IdPatGen 1.1\n\n");
32 printf(
"IdPatGen [-noborder] [-all] [-board] [id-number] filename\n\n");
33 printf(
" -noborder create no border around the pattern image\n");
34 printf(
" -thinborder creates thin border (1 pixel) around the pattern image\n");
35 printf(
" instead of a normal border (3 pixels)\n");
36 printf(
" -all creates all markers (no id-number required)\n");
37 printf(
" will add id to the filename\n");
38 printf(
" -board creates a large image with all markers\n");
39 printf(
" counts as: first rows, then columns\n");
40 printf(
" -bch creates marker for the BCH system rather than\n");
41 printf(
" the simple (original ARToolKitPlus marker system\n");
42 printf(
" id-number id of the marker to create\n");
43 printf(
" do not apply this option when using board\n");
44 printf(
" filename filename of the marker or board\n");
45 printf(
" do not pass an extension\n");
49 bool _border=
true, _all=
false, _board=
false, _thinborder=
false, _bch=
false;
50 int idnumber=0, numOpts=argc-1;
51 std::string basefilename;
55 for(
int optid=1; optid<numOpts; optid++)
57 std::string opt = argv[optid];
62 if(opt==
"-thinborder")
75 if(!_all && optid==argc-2)
78 printf(
"ERROR: unknown parameter '%s'\n", opt.c_str());
85 printf(
"Creating marker(s) for %s id-system\n", _bch ?
"BCH" :
"SIMPLE");
88 idnumber = atoi(argv[argc-2]);
89 basefilename = argv[argc-1];
91 if(idnumber<0 || idnumber>idMax)
93 printf(
"ERROR: invalid id-number %d. must be in rage [0,%d]\n", idnumber, idMax);
98 int borderWidth = _thinborder ? 1 : 3;
104 if(_board || _border)
114 for(
int i=0; i<=
idMax; i++)
118 sprintf(filename,
"%s_%04d.tga", basefilename.c_str(), i);
125 markerImg->
drawImage(borderWidth,borderWidth, patImg);
139 sprintf(filename,
"%s_%04d.tga", basefilename.c_str(), idnumber);
146 markerImg->
drawImage(borderWidth,borderWidth, patImg);
160 int imgW = _bch ? 260*4 : 260,
161 imgH = _bch ? 516*2 : 516;
162 int markersPerRow = _bch ? 16*4 : 16,
163 markersRows = _bch ? 32*2 : 32;
166 board->
clear(0xffff);
170 for(
y=0;
y<markersRows;
y++)
171 for(x=0; x<markersPerRow; x++)
173 int id =
y*markersPerRow+x;
178 markerImg->
drawImage(borderWidth,borderWidth, pattern);
179 board->
drawImage(4+x*(markerSize+4), 4+
y*(markerSize+4), markerImg);
184 sprintf(filename,
"%s.tga", basefilename.c_str());
203 pixels[ARToolKitPlus::pattBits-1-i] = 0xffff;
205 pixels[ARToolKitPlus::pattBits-1-i] = 0;
PN::Image * createImageFromPattern(ARToolKitPlus::IDPATTERN nPattern)
void drawImage(int nX, int nY, const Image *nImage, int nSx0, int nSy0, int nSx1, int nSy1, bool nTransparent=false)
Draws another bitmap inside this bitmap.
int main(int argc, char **argv)
static Image * createFromPixelBuffer(int nWidth, int nHeight, unsigned short *nPixels, bool nOwner)
Creates an Image object directly from a pixel buffer.
TFSIMD_FORCE_INLINE const tfScalar & y() const
void clear(int nRed, int nGreen, int nBlue)
Clears the bitmap with the given RGB color.
TFSIMD_FORCE_INLINE const tfScalar & x() const
void generatePattern(bool nBCH, int nID, ARToolKitPlus::IDPATTERN &nPattern)
The Image class provides basic RGB565 image handing capabilities.