Hi guys,
I found a strange bug.
I have two versions of ARToolKit on my pc: the first compiled with Video4Linux (option 1 of the Configure file), the second with gstreamer input (option 5 of the Configure file). When i run the example simpleVRML with Video4Linux it works well but if i try to run it with gstreamer input i have this error:
VRML id - -1
setupMarkersObjects(): read_VRMLdata returned error !!
main(): Unable to set up AR objects and markers.
Segmentation fault
I have tried debugging both and it seems that it fails when it tried to load .dat files and scaling and rotation values from this file. In particular the source code that cause application crash is the following:
get_buff(buf, 256, fp);
if( sscanf(buf, "%lf %lf %lf", &viewer[id]->scale[0], &viewer[id]->scale[1],
&viewer[id]->scale[2]) != 3 ) {
delete viewer[id];
viewer[id] = NULL;
fclose(fp);
return -1;
}
The sscanf doesn't return 3 so the program crash.
I have this error passing the string:
export ARTOOLKIT_CONFIG="v4lsrc device=/dev/video ! video/x-raw-rgb,width=320,height=240 ! ffmpegcolorspace ! identity name=artoolkit ! fakesink"
I i give a simple videotest string it works.
The strange thing is that with version compiled with Video4Linux it works well but it seems using the same functions and i don't understand what's the difference beetween the two version during loading vrml dat file.
Other informations:
Operating System: Fedora Core 7
ARToolKit version: 2.72
Gstreamer version: 0.10
Complete output:
Using config string from environment [v4lsrc device=/dev/video ! video/x-raw-rgb,width=320,height=240 ! ffmpegcolorspace ! identity name=artoolkit ! fakesink].
libARvideo: GStreamer 0.10.15
libARvideo: GStreamer pipeline is PAUSED!
libARvideo: GStreamer negotiated 320x240
libARvideo: GStreamer pipeline is PLAYING!
libARvideo: GStreamer pipeline is PAUSED!
Camera image size (x,y) = (320,240)
*** Camera Parameter ***
--------------------------------------
SIZE = 320, 240
Distortion factor = 159,250000 131,750000 104,800000 1,012757
350,47574 0,00000 158,25000 0,00000
0,00000 363,04709 120,75000 0,00000
0,00000 0,00000 1,00000 0,00000
--------------------------------------
libARvideo: GStreamer pipeline is PLAYING!
FittingMode (Z): COMPENSATED IMAGE
ProcMode (X) : FULL IMAGE
DrawMode (C) : TEXTURE MAPPING (FULL RESOLUTION)
TemplateMatchingMode (M) : Color Template
MatchingPCAMode (P) : Without PCA
Opening model file Data/object_data_vrml
About to load 2 models.
Model 1: Wrl/snoman.dat
VRML id - -1
setupMarkersObjects(): read_VRMLdata returned error !!
main(): Unable to set up AR objects and markers.
Segmentation fault
Thanks
Seems usage problem - need more info.
I have resolved that problem inserting only a line of code that was necessary to change context with the instruction
setlocale(LC_NUMERIC, "C");
added to the function setupCamera as reported in the following lines:
static int setupCamera(const char *cparam_name, char *vconf, ARParam *cparam)
{
ARParam wparam;
int xsize, ysize;
// Open the video path.
if (arVideoOpen(vconf) < 0) {
fprintf(stderr, "setupCamera(): Unable to open connection to camera.\n");
return (FALSE);
}
////////////////////////////77
setlocale (LC_NUMERIC, "C");
///////////////////////////////7
// Find the size of the window.
if (arVideoInqSize(&xsize, &ysize) < 0) return (FALSE);
fprintf(stdout, "Camera image size (x,y) = (%d,%d)\n", xsize, ysize);
// Load the camera parameters, resize for the window and init.
if (arParamLoad(cparam_name, 1, &wparam) < 0) {
fprintf(stderr, "setupCamera(): Error loading parameter file %s for camera.\n", cparam_name);
return (FALSE);
}
arParamChangeSize(&wparam, xsize, ysize, cparam);
fprintf(stdout, "*** Camera Parameter ***\n");
arParamDisp(cparam);
arInitCparam(cparam);
if (arVideoCapStart() != 0) {
fprintf(stderr, "setupCamera(): Unable to begin camera data capture.\n");
return (FALSE);
}
fprintf(stdout, "*** Setup Camera end function ***\n");
return (TRUE);
}
I hope it could be useful.