Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #include "ARToolKitPlus/TrackerMultiMarkerImpl.h"
00048
00049
00050 class MyLogger : public ARToolKitPlus::Logger
00051 {
00052 void artLog(const char* nStr)
00053 {
00054 printf(nStr);
00055 }
00056 };
00057
00058
00059 int main(int argc, char** argv)
00060 {
00061 const int width = 320, height = 240, bpp = 1;
00062 size_t numPixels = width*height*bpp;
00063 size_t numBytesRead;
00064 const char *fName = "data/markerboard_480-499.raw";
00065 unsigned char *cameraBuffer = new unsigned char[numPixels];
00066 MyLogger logger;
00067
00068
00069
00070
00071
00072
00073 if(FILE* fp = fopen(fName, "rb"))
00074 {
00075 numBytesRead = fread(cameraBuffer, 1, numPixels, fp);
00076 fclose(fp);
00077 }
00078 else
00079 {
00080 printf("Failed to open %s\n", fName);
00081 delete cameraBuffer;
00082 return -1;
00083 }
00084
00085 if(numBytesRead != numPixels)
00086 {
00087 printf("Failed to read %s\n", fName);
00088 delete cameraBuffer;
00089 return -1;
00090 }
00091
00092
00093
00094
00095
00096
00097
00098 ARToolKitPlus::TrackerMultiMarker *tracker = new ARToolKitPlus::TrackerMultiMarkerImpl<6,6,6, 1, 16>(width,height);
00099
00100 const char* description = tracker->getDescription();
00101 printf("ARToolKitPlus compile-time information:\n%s\n\n", description);
00102
00103
00104
00105 tracker->setLogger(&logger);
00106 tracker->setPixelFormat(ARToolKitPlus::PIXEL_FORMAT_LUM);
00107
00108
00109
00110
00111 if(!tracker->init("data/LogitechPro4000.dat", "data/markerboard_480-499.cfg", 1.0f, 1000.0f))
00112 {
00113 printf("ERROR: init() failed\n");
00114 delete cameraBuffer;
00115 delete tracker;
00116 return -1;
00117 }
00118
00119
00120 tracker->setBorderWidth(0.125f);
00121
00122
00123 tracker->setThreshold(160);
00124
00125
00126
00127 tracker->setUndistortionMode(ARToolKitPlus::UNDIST_LUT);
00128
00129
00130
00131
00132
00133
00134 tracker->setMarkerMode(ARToolKitPlus::MARKER_ID_SIMPLE);
00135
00136
00137
00138
00139
00140
00141 int numDetected = tracker->calc(cameraBuffer);
00142
00143
00144
00145
00146
00147 printf("\n%d good Markers found and used for pose estimation.\nPose-Matrix:\n ", numDetected);
00148 for(int i=0; i<16; i++)
00149 printf("%.2f %s", tracker->getModelViewMatrix()[i], (i%4==3)?"\n " : "");
00150
00151 bool showConfig = false;
00152
00153 if(showConfig)
00154 {
00155 const ARToolKitPlus::ARMultiMarkerInfoT *artkpConfig = tracker->getMultiMarkerConfig();
00156 printf("%d markers defined in multi marker cfg\n", artkpConfig->marker_num);
00157
00158 printf("marker matrices:\n");
00159 for(int multiMarkerCounter = 0; multiMarkerCounter < artkpConfig->marker_num; multiMarkerCounter++)
00160 {
00161 printf("marker %d, id %d:\n", multiMarkerCounter, artkpConfig->marker[multiMarkerCounter].patt_id);
00162 for(int row = 0; row < 3; row++)
00163 {
00164 for(int column = 0; column < 4; column++)
00165 printf("%.2f ", artkpConfig->marker[multiMarkerCounter].trans[row][column]);
00166 printf("\n");
00167 }
00168 }
00169 }
00170
00171 delete [] cameraBuffer;
00172 delete tracker;
00173 return 0;
00174 }