hi all,
Thanks to a user sending in sample data that would make ARToolKitPlus
crash, i was able to identify a bug that is probably in there since one
of the first versions of ARToolKit (not just Plus...) and is still there
in ARToolKit 2.71.2.
The bug occurs when seeing many markers (more than AR_SQUARE_MAX) and
using arDetectMarker(), It does not happen with arDetectMarkerLite(). If
the history is already full and another marker is detected it will still
be added to the history and thereby write beyond the end of the array
which quite surely results in a crash soon after that. the fix is very
simple:
In arDetectMarker.c go to line 138; there should be a block of code line
this:
for( i = 0; i < wmarker_num; i++ ) {
if( wmarker_info[i].id < 0 ) continue;
for( j = 0; j < prev_num; j++ ) {
if( prev_info[j].marker.id == wmarker_info[i].id ) break;
}
prev_info[j].marker = wmarker_info[i];
prev_info[j].count = 1;
if( j == prev_num ) prev_num++;
}
Replace it with this:
for( i = 0; i < wmarker_num; i++ ) {
if( wmarker_info[i].id < 0 ) continue;
for( j = 0; j < prev_num; j++ ) {
if( prev_info[j].marker.id == wmarker_info[i].id ) break;
}
if(j<AR_SQUARE_MAX) {
prev_info[j].marker = wmarker_info[i];
prev_info[j].count = 1;
if( j == prev_num ) prev_num++;
}
}
In ARToolKitPlus paste MAX_IMAGE_PATTERNS instead of AR_SQUARE_MAX.
The problem is only likely to happen when using a small value for
AR_SQUARE_MAX (in ARToolKit) or MAX_IMAGE_PATTERNS (in ARToolKitPlus).
The bugfix will in integrated into the next release of ARToolKitPlus.
bye,
Daniel
|