rPI camera + zBar = memory-leak

Hi,

I'v trying to build a simple QR codes scanner using a Raspberry PI with camera and the zBar library.

That works but I have a memory-leak problem and I can't find it.

I'm using zbar-0.10 and raspicam-0.1.1

here is my source-code :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <ctime>
#include <fstream>
#include <iostream>
#include <raspicam/raspicam.h>
#include <zbar.h>
#include <time.h>

using namespace std;
using namespace zbar;

#define CAMERA_FRAME_WIDTH 640
#define CAMERA_FRAME_HEIGHT 480

int main ( int argc,char **argv )
{
   unsigned int counter = 0;

    raspicam::RaspiCam Camera; // Camera object
   
   // camera setup
   Camera.setFormat( raspicam::RASPICAM_FORMAT_GRAY );
   Camera.setCaptureSize( CAMERA_FRAME_WIDTH, CAMERA_FRAME_HEIGHT );
   
   // zbar setup
   ImageScanner zBar_scanner;
   //
   zBar_scanner.set_config( ZBAR_NONE, ZBAR_CFG_ENABLE, 0 );  
   zBar_scanner.set_config( ZBAR_QRCODE, ZBAR_CFG_ENABLE, 1 );  

    // open camera 
    cout<<"Opening Camera..."<<endl;
   
    if ( !Camera.open() )
   {
      cerr<<"Error opening camera"<<endl;
      return -1;
   }

    //wait a while until camera stabilizes
    cout<<"Sleeping for 3 secs"<<endl;
    sleep(3);
   
   while(1)
   {
      printf("#%d\n", counter++);
   
      // capture a new frame
      Camera.grab();

      Image newCameraFrame(CAMERA_FRAME_WIDTH, CAMERA_FRAME_HEIGHT, "Y800", Camera.getImageBufferData(), Camera.getImageTypeSize(Camera.getFormat()) );
      
      int decodeResult = zBar_scanner.scan( newCameraFrame );
      if( decodeResult > 0 )
      {
         for( Image::SymbolIterator symbol = newCameraFrame.symbol_begin() ; symbol != newCameraFrame.symbol_end(); ++symbol )
         {  
            printf("QR = %s\n", symbol->get_data().c_str() );
         }            
      }
      else
      {
         printf("No data\n");
      }
   }
   
    return 0;
}


and here is my makefile :
1
2
all:
   g++ main.cpp -o Test_04 -Wall -I/usr/local/include -L/opt/vc/lib -lrt -lraspicam -lmmal -lmmal_core -lmmal_util -lzbar


when this program run, I can see (using top cmd on a remote shell) the RES value grow endless.

I feel that the problem is around the "Image newCameraFrame(...)" but cannot find how to solve that.

Thanks !

Seb
Last edited on
$ valgrind --leak-check=full ./a.out
valgrind don't work fine on Raspberry PI ...
Topic archived. No new replies allowed.