ARToolKit | Mailing List Archive |
![]() |
From: | artoolkit@h ........ | Received: | Oct 14, 2004 |
To | artoolkit@h .................. | ||
Subject: | possible bug in libARvideo | ||
Hi everyone, maybe i am wrong, but i think there is a bug in libARvideo. The circumstance: there is a video source opened with arVideoOpen... later on this source is closed by arVideoClose, after this a reopen with arVideoOpen is not possible, because the pointer gVid to the AR2VideoParamT struct is not NULL. In ar2VideoClose i found that the video source has been closed and the memory for the structure has been freed. BUT the pointer gVid still points to the structure is not set to NULL again. After correcting this everything works fine. Is this already known? Maybe somebody else had this problem before. kind regards J=F6rg Hedrich |
From: | Philip Lamb <phil@e ..........> | Received: | Oct 15, 2004 |
To | artoolkit@h ........, artoolkit@h .................. | ||
Subject: | Re: possible bug in libARvideo | ||
At 12:29 PM +0200 14/10/04, artoolkit@h ........ wrote: >Hi everyone, > >maybe i am wrong, but i think there is a bug in libARvideo. The >circumstance: >there is a video source opened with arVideoOpen... >later on this source is closed by arVideoClose, >after this a reopen with arVideoOpen is not possible, because the >pointer gVid to the AR2VideoParamT struct is not NULL. >In ar2VideoClose i found that the video source has been closed and >the memory for the structure has been freed. BUT the pointer gVid >still points to the structure is not set to NULL again. After >correcting this everything works fine. > >Is this already known? Maybe somebody else had this problem before. > >kind regards >Jörg Hedrich Hi Jörg, You are correct.. looks like that bug has been there a while, and it is in all the video libraries. As you discovered, it only shows up if you make multiple calls to arVideoOpen(). You can patch your copy of ARToolKit 2.68.2 by inserting: vid = NULL; immediately after the line that reads: free (vid); in function ar2VideoClose() in these files: - lib/SRC/VideoWin32DirectShow/videoWin32DirectShow.cpp - lib/SRC/VideoLinuxDV/video.c - lib/SRC/VideoLinux1394Cam/video.c - lib/SRC/VideoLinuxV4L/video.c - lib/SRC/VideoSGI/video.c. and inserting: free (vid); vid = NULL; immediately after the comment line: // Count one less grabber running. in function ar2VideoClose() in file lib/SRC/VideoMacOSX/video.c. I've made the change in our CVS sources here at the HIT Lab. These sources will be uploaded to SourceForge when I have time (not much right at the moment owing to ill health). Regards, Phil. -- Philip Lamb Research Student, Human Interface Technology Laboratory New Zealand, University of Canterbury, Christchurch, NZ. +64 3 3642987 x3070 |
From: | Blair MacIntyre <blair@c ............> | Received: | Oct 16, 2004 |
To | Philip Lamb <phil@e ..........> | ||
Subject: | Re: possible bug in libARvideo | ||
Close Philip, but I don't think that works. setting vid to NULL in those functions doesn't propogate. You need to=20= change arVideoClose to look something like this, since it keeps a copy=20= of the pointer. int arVideoClose(void) { if (gVid =3D=3D NULL) return (-1); int ret =3D ar2VideoClose(gVid); gVid =3D NULL; return ret; } On Oct 14, 2004, at 9:19 PM, Philip Lamb wrote: > At 12:29 PM +0200 14/10/04, artoolkit@h ........ wrote: >> Hi everyone, >> >> maybe i am wrong, but i think there is a bug in libARvideo. The >> circumstance: >> there is a video source opened with arVideoOpen... >> later on this source is closed by arVideoClose, >> after this a reopen with arVideoOpen is not possible, because the >> pointer gVid to the AR2VideoParamT struct is not NULL. >> In ar2VideoClose i found that the video source has been closed and >> the memory for the structure has been freed. BUT the pointer gVid >> still points to the structure is not set to NULL again. After >> correcting this everything works fine. >> >> Is this already known? Maybe somebody else had this problem before. >> >> kind regards >> J=F6rg Hedrich > > Hi J=F6rg, > > You are correct.. looks like that bug has been there a while, and it=20= > is in all the video libraries. As you discovered, it only shows up if=20= > you make multiple calls to arVideoOpen(). > > You can patch your copy of ARToolKit 2.68.2 by inserting: > vid =3D NULL; > immediately after the line that reads: > free (vid); > in function ar2VideoClose() in these files: > - lib/SRC/VideoWin32DirectShow/videoWin32DirectShow.cpp > - lib/SRC/VideoLinuxDV/video.c > - lib/SRC/VideoLinux1394Cam/video.c > - lib/SRC/VideoLinuxV4L/video.c > - lib/SRC/VideoSGI/video.c. > > and inserting: > free (vid); > vid =3D NULL; > immediately after the comment line: > // Count one less grabber running. > in function ar2VideoClose() in file lib/SRC/VideoMacOSX/video.c. > > I've made the change in our CVS sources here at the HIT Lab. These=20 > sources will be uploaded to SourceForge when I have time (not much=20 > right at the moment owing to ill health). > > Regards, > Phil. > --=20 > Philip Lamb > Research Student, > Human Interface Technology Laboratory New Zealand, > University of Canterbury, Christchurch, NZ. > +64 3 3642987 x3070 |
From: | Philip Lamb <phil@e ..........> | Received: | Oct 18, 2004 |
To | Blair MacIntyre <blair@c ............> | ||
Subject: | Re: possible bug in libARvideo | ||
Arrgh.. of course it is. How embarrassing.. for some reason I looked at the code and coded as if vid was a handle in ar2VideoClose. P. At 2:21 PM -0400 16/10/04, Blair MacIntyre wrote: >Close Philip, but I don't think that works. > >setting vid to NULL in those functions doesn't propogate. You need >to change arVideoClose to look something like this, since it keeps a >copy of the pointer. > >int arVideoClose(void) >{ > if (gVid == NULL) return (-1); > int ret = ar2VideoClose(gVid); > gVid = NULL; > return ret; >} > >On Oct 14, 2004, at 9:19 PM, Philip Lamb wrote: > >>At 12:29 PM +0200 14/10/04, artoolkit@h ........ wrote: >>>Hi everyone, >>> >>>maybe i am wrong, but i think there is a bug in libARvideo. The >>>circumstance: >>>there is a video source opened with arVideoOpen... >>>later on this source is closed by arVideoClose, >>>after this a reopen with arVideoOpen is not possible, because the >>>pointer gVid to the AR2VideoParamT struct is not NULL. >>>In ar2VideoClose i found that the video source has been closed and >>>the memory for the structure has been freed. BUT the pointer gVid >>>still points to the structure is not set to NULL again. After >>>correcting this everything works fine. >>> >>>Is this already known? Maybe somebody else had this problem before. >>> >>>kind regards >>>Jörg Hedrich >> >>Hi Jörg, >> >>You are correct.. looks like that bug has been there a while, and >>it is in all the video libraries. As you discovered, it only shows >>up if you make multiple calls to arVideoOpen(). >> >>You can patch your copy of ARToolKit 2.68.2 by inserting: >> vid = NULL; >>immediately after the line that reads: >> free (vid); >>in function ar2VideoClose() in these files: >> - lib/SRC/VideoWin32DirectShow/videoWin32DirectShow.cpp >> - lib/SRC/VideoLinuxDV/video.c >> - lib/SRC/VideoLinux1394Cam/video.c >> - lib/SRC/VideoLinuxV4L/video.c >> - lib/SRC/VideoSGI/video.c. >> >>and inserting: >> free (vid); >> vid = NULL; >>immediately after the comment line: >> // Count one less grabber running. >>in function ar2VideoClose() in file lib/SRC/VideoMacOSX/video.c. >> >>I've made the change in our CVS sources here at the HIT Lab. These >>sources will be uploaded to SourceForge when I have time (not much >>right at the moment owing to ill health). >> >>Regards, >>Phil. >>-- >>Philip Lamb >>Research Student, >>Human Interface Technology Laboratory New Zealand, >>University of Canterbury, Christchurch, NZ. >>+64 3 3642987 x3070 |