Game Development Reference
In-Depth Information
Initialization
This step opens the video device with the AR API call:
if( arVideoOpen( vconf ) < 0 ) exit(0);
Note that the API requires a video configuration descriptor. This is required for Windows
platforms only. In Linux/Android, it can be NULL. If the call fails, you should abort with an
error message. Once the video is opened, you can get the size of the display with a call to
if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
The display size is then stored in xsize and ysize . Next, it loads the default camera
parameters and adjusts the size based on the display parameters.
/* set the initial camera parameters */
ARParam wparam;
ARParam cparam;
if( arParamLoad("Data/camera_para.dat", 1, &wparam) < 0 ) {
printf("Camera parameter load error !!\n");
exit(0);
}
arParamChangeSize( &wparam, xsize, ysize, &cparam );
arInitCparam( &cparam );
// display camera params
arParamDisp( &cparam );
The initial (or default) camera parameters are loaded from the binary file Data/camera_para.dat .
Then the camera size is adjusted to match the values returned by xsize and ysize . In
Video4Linux, default camera parameters include)
The device name : Usually /dev/video[0-1] . In Android the default video
device is /dev/video0 .
The palette type : It can be RGB32 or RGBA32 for 32-bit red, blue, and
green pixel format.
Pixel format : It should match the palette value used above.
Refer to https://archive.fosdem.org/2014/schedule/event/v4l_intro/ for more
information about Video4Linux.
Next, it loads a pattern Data/patt.hiro from disk on which the 3D objects will be rendered.
if( ( patt_id = arLoadPatt("Data/patt.hiro")) < 0 ) {
printf("pattern load error !!\n");
exit(0);
}
 
Search WWH ::




Custom Search