cvGet2D problem -- Process returned -1073741819 (0xC0000005)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

cvGet2D problem -- Process returned -1073741819 (0xC0000005)

nixknacks
Hey everyone,

I'm really new to OpenCV, so feel free to give me a hard time if I've
made a stupid mistake here.  :)

I'm trying to learn how to use and manipulate images so that I can
eventually write my own algorithms and what not.  Currently, I've been
stuck for some time on a problem and I could really use some help
figuring it out.

The Code: To save your faith in humanity, here is a truncated version
of the code.

#important includes
int main( void ){
     int key=-1,i,j;
     CvScalar pix;

     IplImage* video1 = NULL;
     IplImage* video2 = NULL;

     CvCapture* vidCapture = cvCaptureFromCAM(CV_CAP_ANY);
     cvSetCaptureProperty(vidCapture,CV_CAP_PROP_FRAME_HEIGHT,480);
     cvSetCaptureProperty(vidCapture,CV_CAP_PROP_FRAME_WIDTH,640);

     cvNamedWindow("Direct_Feed");
     cvNamedWindow("Modded_Feed");

     while(key==-1){
          video1 = cvQueryFrame(vidCapture);
          video2 = cvCloneImage(video1);

          for(i=0;i<480;i++){
               for(j=0;j<640;j++){
                    pix = cvGet2D(video2,i,j);
                    //mess around with pix.val for a bit.
                    cvSet2D(video2,i,j,pix);
               }
          }

          cvShowImage("Direct_Feed",video1);
          cvShowImage("Modded_Feed",video2);

          key = cvWaitKey(1);
     }

     cvReleaseCapture(&vidCapture);
     cvDestroyWindow("Direct_Feed");
     cvDestroyWindow("Modded_Feed");
     cvReleaseImage(&video1);
     cvReleaseImage(&video2);

)


The Problem:

Everything works just fine.  However, somewhere around the 50,000th
time that the program calls cvGet2D() the program exits with the
message "Process returned -1073741819 (0xC0000005)".

If I comment out cvGet2D, the code runs just fine without crashing.
I'm pretty sure my camera is compatible with OpenCV.  (I worked with a
camera that was not compatible for awhile, and this camera doesn't
have any of those issues.)  

Any ideas why I would be getting this kind of error?  I did some
looking around, but I couldn't find any information that helped me
point at a solution.

Intuitively, it seems like some kind of memory leak: especially since
it works for a short period of time and then quits out.  

Other possibly relevant info:
Microsoft VX-3000
grabbing RGB frames and modding all 3 channels

Thanks in advance to any helpful responses!

Nick P.
     

Reply | Threaded
Open this post in threaded view
|

Re: cvGet2D problem -- Process returned -1073741819 (0xC0000005)

ekrem guner
Every time you call cvCloneImage, you get a new dynamic
IplImage structure with fully copy. You can figure it out by
looking at function arguments. You just pass video1, do not pass
any other pointer. So function allocates a new dynamic structure
and copies data and returns a pointer to this structure. video2
just pointing this structure.
So you should release it in each cycle after you re done with it
(Not just once at the end of the program).
That is why your memory leaks.  

i hope it is helpful.
Best Regards.


Sorry if my lang. is bad.



--- In [hidden email], "nixknacks" <NixKnacks@...> wrote:
>
> Hey everyone,
>
> I'm really new to OpenCV, so feel free to give me a hard time if
I've
> made a stupid mistake here.  :)
>
> I'm trying to learn how to use and manipulate images so that I can
> eventually write my own algorithms and what not.  Currently, I've
been
> stuck for some time on a problem and I could really use some help
> figuring it out.
>
> The Code: To save your faith in humanity, here is a truncated
version

> of the code.
>
> #important includes
> int main( void ){
>      int key=-1,i,j;
>      CvScalar pix;
>
>      IplImage* video1 = NULL;
>      IplImage* video2 = NULL;
>
>      CvCapture* vidCapture = cvCaptureFromCAM(CV_CAP_ANY);
>      cvSetCaptureProperty(vidCapture,CV_CAP_PROP_FRAME_HEIGHT,480);
>      cvSetCaptureProperty(vidCapture,CV_CAP_PROP_FRAME_WIDTH,640);
>
>      cvNamedWindow("Direct_Feed");
>      cvNamedWindow("Modded_Feed");
>
>      while(key==-1){
>           video1 = cvQueryFrame(vidCapture);
>           video2 = cvCloneImage(video1);
>
>           for(i=0;i<480;i++){
>                for(j=0;j<640;j++){
>                     pix = cvGet2D(video2,i,j);
>                     //mess around with pix.val for a bit.
>                     cvSet2D(video2,i,j,pix);
>                }
>           }
>
>           cvShowImage("Direct_Feed",video1);
>           cvShowImage("Modded_Feed",video2);
>
>           key = cvWaitKey(1);
>      }
>
>      cvReleaseCapture(&vidCapture);
>      cvDestroyWindow("Direct_Feed");
>      cvDestroyWindow("Modded_Feed");
>      cvReleaseImage(&video1);
>      cvReleaseImage(&video2);
>
> )
>
>
> The Problem:
>
> Everything works just fine.  However, somewhere around the 50,000th
> time that the program calls cvGet2D() the program exits with the
> message "Process returned -1073741819 (0xC0000005)".
>
> If I comment out cvGet2D, the code runs just fine without crashing.
> I'm pretty sure my camera is compatible with OpenCV.  (I worked
with a
> camera that was not compatible for awhile, and this camera doesn't
> have any of those issues.)  
>
> Any ideas why I would be getting this kind of error?  I did some
> looking around, but I couldn't find any information that helped me
> point at a solution.
>
> Intuitively, it seems like some kind of memory leak: especially
since

> it works for a short period of time and then quits out.  
>
> Other possibly relevant info:
> Microsoft VX-3000
> grabbing RGB frames and modding all 3 channels
>
> Thanks in advance to any helpful responses!
>
> Nick P.
>