Closed GoogleCodeExporter closed 8 years ago
You're welcome!
I will try to reproduce the problem as soon as possible. I passed Valgrind when
I
coded that part with no issues, but I certainly I don't test it enough.
Thank you for post it.
Original comment by grendel....@gmail.com
on 26 Nov 2009 at 6:39
[deleted comment]
I tried again yesterday with a brand-new test code ;). I post it here in case
you
need it:
#include <iostream>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <cvblob.h>
using namespace std;
int
main()
{
uchar nFrame = 0;
CvSize imSize = cvSize(640, 480); //Change to your resolution camera
IplImage* binaryImage = cvCreateImage(imSize, IPL_DEPTH_8U, 1);
IplImage* labelImg = cvCreateImage(imSize, IPL_DEPTH_LABEL, 1);
IplImage* image;
CvCapture* camera = cvCaptureFromAVI(0);
cvNamedWindow("IP Camera", 1);
while (1)
{
image = cvQueryFrame(camera); //Gets a frame from the source
//IP source is upside down, so flip the image in order to see it correctly
cvFlip(image, image, -1);
cvCvtColor(image, binaryImage, CV_RGB2GRAY);
cvThreshold(binaryImage, binaryImage, 120, 255, CV_THRESH_BINARY);
CvBlobs blobs;
CvTracks tracks;
cvLabel(binaryImage, labelImg, blobs);
cvUpdateTracks(blobs, tracks, 5., 10); //Do the tracking
cvRenderTracks(tracks, image, image, CV_TRACK_RENDER_ID
| CV_TRACK_RENDER_TO_LOG);
cvShowImage("IP Camera", image);
cvReleaseBlobs(blobs);
if (nFrame == 127)
break;
nFrame++;
}
cvReleaseCapture(&camera);
cvReleaseImage(&binaryImage);
cvReleaseImage(&labelImg);
return 0;
}
Same memory leaks have been reproduced using this new code.
==9087== 7,168 bytes in 128 blocks are definitely lost in loss record 100 of 111
==9087== at 0x4C23809: operator new(unsigned long) (vg_replace_malloc.c:230)
==9087== by 0x409995: cvRenderTracks (in
/home/jorge/Eclipse_Projects/TestTracks/Debug/TestTracks)
==9087== by 0x401FCD: main (TestTracks.cpp:49)
==9087==
==9087==
==9087== 398,592 bytes in 8,304 blocks are definitely lost in loss record 110
of 111
==9087== at 0x4C23809: operator new(unsigned long) (vg_replace_malloc.c:230)
==9087== by 0x40A6E4: cvUpdateTracks (in
/home/jorge/Eclipse_Projects/TestTracks/Debug/TestTracks)
==9087== by 0x401F9B: main (TestTracks.cpp:47)
==9087==
See you ;)
Original comment by djta...@gmail.com
on 27 Nov 2009 at 7:45
Thanks!
I've just fixed one of the memory leaks. The one in cvRenderTracks (I don't
know how
I coded that :-S ). I have commited this changes.
Now I'm working in the cvUpdateTracks code. This is more difficult.
Bye!
Original comment by grendel....@gmail.com
on 27 Nov 2009 at 9:33
Cool Grendel.
Good luck with the other one ;)
Thanks
Original comment by djta...@gmail.com
on 27 Nov 2009 at 9:38
Hi again!
I believe I just have fixed the memory leak. Can you check it with your code
and the
cvBlob svn version?
When I have time I'll build a package.
Thank you for your patience!
Original comment by grendel....@gmail.com
on 11 Dec 2009 at 1:08
Hi Grendel.
I have just downloaded from the SVN and compiled it.
I'm afraid the problem is still there (I checked it for three times with two
different codes).
Here is the error:
==13900== 448,896 bytes in 9,352 blocks are definitely lost in loss record 110
of 111
==13900== at 0x4C23809: operator new(unsigned long) (vg_replace_malloc.c:230)
==13900== by 0x40ABF1: cvUpdateTracks (in
/home/jorge/Eclipse_Projects/TestTracks/Debug/TestTracks)
==13900== by 0x401F9B: main (TestTracks.cpp:47)
.
.
Keep on trying please ;)
Thanks for your big effort.
Tarki.
Original comment by djta...@gmail.com
on 11 Dec 2009 at 1:44
Hello Tarki,
The code of cvBlob is fine (as much as I know :D ). I have used the code you
posted
in comment 3 and I have seen that you do a pair of things wrong:
First, you must declare "CvTracks tracks" outside the loop, because the tracking
information must be updating from iteration to iteration. Unlike the blob
information, which is new in each frame. Let's say that "tracks" save
information of
the correspondence of blobs through frames.
Second, at the end (outside the loop) you must release the last tracks that
remain in
memory with the function "cvReleaseTracks".
You can see it in the "test_tracking.cpp" code. Briefly:
-------------------------------------------------------------------------
int main()
{
...
CvTracks tracks;
...
while (1)
{
...
CvBlobs blobs;
unsigned int result = cvLabel(chB, labelImg, blobs);
...
cvUpdateTracks(blobs, tracks, 5., 10);
cvRenderBlobs(labelImg, blobs, frame, frame,
CV_BLOB_RENDER_CENTROID|CV_BLOB_RENDER_BOUNDING_BOX);
cvRenderTracks(tracks, frame, frame, CV_TRACK_RENDER_ID);
...
cvReleaseBlobs(blobs);
...
}
...
cvReleaseTracks(tracks);
...
}
-------------------------------------------------------------------------
Tell me if this works!
Cristóbal
Original comment by grendel....@gmail.com
on 12 Dec 2009 at 7:59
Hi again Cristóbal.
It was definitely my fault. As you said I used cvTracks incorrectly: CvTracks
declaration wasn't declared outside the loop (in any of the programs I tested)
and I
did not used cvReleaseTracks() because I did not know that existed inside your
library!
Now I have tried again following your instructions and there are no memory
leaks any
more.
Thanks a lot Cristóbal. Let me know if you need anything ;)
Original comment by djta...@gmail.com
on 14 Dec 2009 at 8:05
Hello Tarki,
I'm glad to hear it's working now. It was not all your fault, there was bugs in
my
library at the beginning, thanks for post it. The cvReleaseTracks is very new,
I need
to improve the documentation :-S
Thanks for support!
PS: I'm curious to know for what kind of application are you using cvBlob :D
Original comment by grendel....@gmail.com
on 14 Dec 2009 at 11:33
Thanks to you ;)
I use your library together with a motion detector that I am optimizing in
order to
achieve real time.
Regards.
Original comment by djta...@gmail.com
on 14 Dec 2009 at 11:37
Original issue reported on code.google.com by
djta...@gmail.com
on 26 Nov 2009 at 9:34