------=_Part_66756_12189561.1160984593882
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi, I can't seem to detect the id-markers when I try to use ARToolkit
Plus. I'm using AR Toolkit to display and draw. I'm using standard simple
markers and I'm sure that the size of my marker is 8cm and is the right
marker. I have no problems compiling and I have included both ARToolkit and
Plus libraries and include directories. I'm uncertain whether its my code
or other external factors. Below is my code and I hope that someone
can help me.
Thanks!
Mingwei
#include <iostream>
#ifdef _WIN32
#include <windows.h>
#endif
#ifndef __APPLE__
#include <GL/gl.h>
#include <GL/glut.h>
#else
#include <OpenGL/gl.h>
#include <GLUT/glut.h>
#endif
#include <AR/gsub.h>
#include <AR/video.h>
#include <AR/param.h>
#include <AR/ar.h>
#include "ARToolkitPlus/TrackerSingleMarkerImpl.h"
using namespace std;
/* set up the video format globals */
#ifdef _WIN32
char *vconf = "data\\WDM_camera_flipV.xml";
#else
char *vconf = "";
#endif
int xsize, ysize;
int count = 0;
char *cparam_name = "data/camera_para.dat";
char *nCamParamFile = "data/camera_para.dat";
ARParam cparam;
double patt_width = 80.0;
double patt_center[2] = {0.0, 0.0};
double patt_trans[3][4];
static void init(void);
static void cleanup(void);
static void keyEvent( unsigned char key, int x, int y);
static void mainLoop( void );
class MyLogger : public ARToolKitPlus::Logger
{
void artLog(const char* nStr)
{
cout << nStr;
}
};
MyLogger logger;
ARToolKitPlus::TrackerSingleMarker *tracker;
int main(int argc, char **argv)
{
glutInit(&argc, argv);
init();
tracker = new ARToolKitPlus::TrackerSingleMarkerImpl<6,6,6, 1, 8>(640,480);
const char* description = tracker->getDescription();
printf("ARToolKitPlus compile-time information:\n%s\n\n", description);
tracker->setLogger(&logger);
if(!tracker->init(nCamParamFile, 1.0f, 1000.0f)) // load std.
ARToolKit camera file
{
printf ("ERROR: init() failed\n");
delete tracker;
return -1;
}
tracker->setPatternWidth(80);
tracker->setBorderWidth(0.250f);
tracker->setThreshold(150);
tracker->setUndistortionMode(ARToolKitPlus::UNDIST_LUT);
tracker->setMarkerMode(ARToolKitPlus::MARKER_ID_SIMPLE);
tracker->setPixelFormat(ARToolKitPlus::PIXEL_FORMAT_RGB);
arVideoCapStart();
argMainLoop( NULL, keyEvent, mainLoop );
return (0);
}
static void keyEvent( unsigned char key, int x, int y)
{
/* quit if the ESC key is pressed */
if( key == 0x1b ) {
printf ("*** %d (frame/sec)\n", (double)count/arUtilTimer());
cleanup();
exit(0);
}
}
/* main loop */
static void mainLoop( void )
{
ARUint8 *dataPtr;
/* grab a video frame */
if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL ) {
arUtilSleep(2);
return;
}
if( count == 0 ) arUtilTimerReset();
count++;
argDrawMode2D();
argDispImage( dataPtr, 0,0 );
/* detect the markers in the video frame */
int markerId = tracker->calc((unsigned char*)dataPtr);
float conf = (float)tracker->getConfidence();
if (markerId >= 0) {
printf("\n\nFound marker %d (confidence %d%%)\n\nPose-Matrix:\n ",
markerId, (int(conf*100.0f)));
}
arVideoCapNext();
argSwapBuffers();
}
static void init( void )
{
ARParam wparam;
/* open the video path */
if( arVideoOpen( vconf ) < 0 ) exit(0);
/* find the size of the window */
if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
cout << "Image size (x,y) = (" << xsize << "," << ")" << endl;
/* set the initial camera parameters */
if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
cout << "Camera parameter load error !!" << endl;
exit(0);
}
arParamChangeSize( &wparam, xsize, ysize, &cparam );
arInitCparam( &cparam );
printf ("*** Camera Parameter ***\n");
arParamDisp( &cparam );
/* open the graphics window */
argInit( &cparam, 1.0, 0, 0, 0, 0 );
}
/* cleanup function called when program exits */
static void cleanup(void)
{
arVideoCapStop();
arVideoClose();
argCleanup();
}
------=_Part_66756_12189561.1160984593882
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
<div>Hi, I can't seem to detect the id-markers when I try to use ARToolkit Plus. I'm using AR Toolkit to display and draw. I'm using standard simple markers and I'm sure that the size of my marker is 8cm and is the right marker. I have no problems compiling and I have included both ARToolkit and Plus libraries and include directories. I'm uncertain whether its my code or other external factors. Below is my code and I hope that someone can help me.
</div>
<div> </div>
<div>Thanks!</div>
<div>Mingwei</div>
<div><font size="2"><font size="2"></font></font> </div>
<div><font size="2"><font size="2">
<p>#include <iostream></p>
<p>#ifdef _WIN32<br>#include <windows.h><br>#endif<br>#ifndef __APPLE__<br>#include <GL/gl.h><br>#include <GL/glut.h><br>#else<br>#include <OpenGL/gl.h><br>#include <GLUT/glut.h><br>#endif</p>
<p>#include <AR/gsub.h><br>#include <AR/video.h><br>#include <AR/param.h><br>#include <AR/ar.h></p>
<p>#include "ARToolkitPlus/TrackerSingleMarkerImpl.h"<br>using namespace std;</p>
<p>/* set up the video format globals */</p>
<p>#ifdef _WIN32<br>char *vconf = "data\\WDM_camera_flipV.xml";<br>#else<br>char *vconf = "";<br>#endif</p>
<p>int xsize, ysize;<br>int count = 0;</p>
<p><br>char *cparam_name = "data/camera_para.dat";<br>char *nCamParamFile = "data/camera_para.dat";<br>ARParam cparam;</p>
<p><br>double patt_width = 80.0;<br>double patt_center[2] = {0.0, 0.0};<br>double patt_trans[3][4];</p>
<p><br>static void init(void);<br>static void cleanup(void);<br>static void keyEvent( unsigned char key, int x, int y);<br>static void mainLoop( void );<br><br>class MyLogger : public ARToolKitPlus::Logger<br>{<br>
void artLog(const char* nStr)<br> {<br> cout << nStr;<br> }<br>};</p>
<p>MyLogger logger;<br>ARToolKitPlus::TrackerSingleMarker *tracker;</p>
<p>int main(int argc, char **argv)<br>{</p>
<p> glutInit(&argc, argv);<br> init();<br><br> tracker = new ARToolKitPlus::TrackerSingleMarkerImpl<6,6,6, 1, 8>(640,480);</p>
<p> const char* description = tracker->getDescription();<br> printf("ARToolKitPlus compile-time information:\n%s\n\n", description);</p>
<p> tracker->setLogger(&logger);</p>
<p> if(!tracker->init(nCamParamFile, 1.0f, 1000.0f)) // load std. ARToolKit camera file<br> {<br> printf ("ERROR: init() failed\n");<br> delete tracker;<br> return -1;<br> }</p>
<p> tracker->setPatternWidth(80);<br> tracker->setBorderWidth(0.250f);<br> tracker->setThreshold(150);<br> tracker->setUndistortionMode(ARToolKitPlus::UNDIST_LUT);<br> tracker->setMarkerMode(ARToolKitPlus::MARKER_ID_SIMPLE);
<br> tracker->setPixelFormat(ARToolKitPlus::PIXEL_FORMAT_RGB);</p>
<p> arVideoCapStart();</p>
<p> argMainLoop( NULL, keyEvent, mainLoop );</p>
<p> return (0);<br>}</p>
<p><br>static void keyEvent( unsigned char key, int x, int y)<br>{<br> /* quit if the ESC key is pressed */<br> if( key == 0x1b ) {<br> printf ("*** %d (frame/sec)\n", (double)count/arUtilTimer());
<br> cleanup();<br> exit(0);<br> }<br>}</p>
<p>/* main loop */<br>static void mainLoop( void )<br>{<br> ARUint8 *dataPtr;</p>
<p><br> /* grab a video frame */<br> if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL ) {<br> arUtilSleep(2);<br> return;<br> }<br> if( count == 0 ) arUtilTimerReset();<br> count++;</p>
<p> argDrawMode2D();<br> argDispImage( dataPtr, 0,0 );<br> /* detect the markers in the video frame */</p>
<p><br> int markerId = tracker->calc((unsigned char*)dataPtr);<br> float conf = (float)tracker->getConfidence();<br> if (markerId >= 0) {<br> printf("\n\nFound marker %d (confidence %d%%)\n\nPose-Matrix:\n ", markerId, (int(conf*
100.0f)));<br><br> }</p>
<p> arVideoCapNext();</p>
<p><br> argSwapBuffers();<br>}</p>
<p>static void init( void )<br>{</p>
<p> ARParam wparam;</p>
<p> /* open the video path */<br> if( arVideoOpen( vconf ) < 0 ) exit(0);<br> /* find the size of the window */<br> if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);<br> cout << "Image size (x,y) = (" << xsize << "," << ")" << endl;
</p>
<p> /* set the initial camera parameters */<br> if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {<br> cout << "Camera parameter load error !!" << endl;<br> exit(0);<br> }<br> arParamChangeSize( &wparam, xsize, ysize, &cparam );
<br> arInitCparam( &cparam );<br> printf ("*** Camera Parameter ***\n");<br> arParamDisp( &cparam );</p>
<p> /* open the graphics window */<br> argInit( &cparam, 1.0, 0, 0, 0, 0 );<br>}</p>
<p>/* cleanup function called when program exits */<br>static void cleanup(void)<br>{<br> arVideoCapStop();<br> arVideoClose();<br> argCleanup();<br>}</p></font></font></div>
------=_Part_66756_12189561.1160984593882--
|