new to openCV....have question about cvReleaseImage() error in in VC++ 2003

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

new to openCV....have question about cvReleaseImage() error in in VC++ 2003

stars_sailor_8013
Hi All,

I am new to openCV but I like this SDK very much and would like to
learn more about it.


I have created a MFC dialog based project in VC++ 2003 (Window XP
SP2) to test out this sdk.

My code is very simple only 3 lines.

void CimgSearchDlg::OnBnClickedButton1()
{

  IplImage *tpl;
       
  tpl = cvLoadImage( "aaa.jpg", CV_LOAD_IMAGE_COLOR );

  cvReleaseImage( &tpl );

}

When I run my code in release or debug mode, after executing the last
line of code "cvReleaseImage( &tpl ); " an error message pop-up with
the following message:

***************************************************************
Unhandled exception at 0x7c921230 in imgSearch.exe: User breakpoint.
***************************************************************


and following lines appear on the Output window:
*****************************************************************
HEAP[imgSearch.exe]: Invalid Address specified to RtlFreeHeap(
003B0000, 01520040 )
Unhandled exception at 0x7c921230 in imgSearch.exe: User breakpoint.
*******************************************************************

Following are the steps taken to integrate the openCV to my project:

1. Downloaded OpenCV_1.1pre1a.exe setup and installed on my pc.

2. Upgrade the opencv.dsw to opencv.sln and rebuild the dlls and
libs. (Without this step I encountered an initialization error when
using opencv in vc++ 2003.)

3. Follow the instructions from this site to integrate openCV to my
project.
(http://homepages.nyu.edu/~rnp226/mocap/openvc_visualstudio_guide.txt)


Am I missing any steps in the setup process or do I need to change
any settings in my project properties?


Thank you very much.

Joe


Reply | Threaded
Open this post in threaded view
|

Re: new to openCV....have question about cvReleaseImage() error in in VC++ 2003

stars_sailor_8013
Just an update on my situation, when I put the same code in a VC++ 2003
Win32 DLL project, the dll works fine in both release and debug mode.

Maybe someone can explain more about the reason behind it, thx.

Joe



Reply | Threaded
Open this post in threaded view
|

Re: new to openCV....have question about cvReleaseImage() error in in VC++ 2003

asm warrior
Interesting.
Does it means that using MFC can bring errors?

Reply | Threaded
Open this post in threaded view
|

Re: new to openCV....have question about cvReleaseImage() error in in VC++ 2003

Jean-Pierre Landry
In reply to this post by stars_sailor_8013
I would maybe check the value of 'tpl' before releasing it...
cvLoadImage will return a NULL pointer if it can't find the file...

so

    IplImage *tpl;
 
    tpl = cvLoadImage( "aaa.jpg", CV_LOAD_IMAGE_COLOR );

    if(tpl)
        cvReleaseImage( &tpl );


stars_sailor_8013 wrote:

> Hi All,
>
> I am new to openCV but I like this SDK very much and would like to
> learn more about it.
>
>
> I have created a MFC dialog based project in VC++ 2003 (Window XP
> SP2) to test out this sdk.
>
> My code is very simple only 3 lines.
>
> void CimgSearchDlg::OnBnClickedButton1()
> {
>
>   IplImage *tpl;
>
>   tpl = cvLoadImage( "aaa.jpg", CV_LOAD_IMAGE_COLOR );
>
>   cvReleaseImage( &tpl );
>
> }
>
> When I run my code in release or debug mode, after executing the last
> line of code "cvReleaseImage( &tpl ); " an error message pop-up with
> the following message:
>
> ***************************************************************
> Unhandled exception at 0x7c921230 in imgSearch.exe: User breakpoint.
> ***************************************************************
>
>
> and following lines appear on the Output window:
> *****************************************************************
> HEAP[imgSearch.exe]: Invalid Address specified to RtlFreeHeap(
> 003B0000, 01520040 )
> Unhandled exception at 0x7c921230 in imgSearch.exe: User breakpoint.
> *******************************************************************
>
> Following are the steps taken to integrate the openCV to my project:
>
> 1. Downloaded OpenCV_1.1pre1a.exe setup and installed on my pc.
>
> 2. Upgrade the opencv.dsw to opencv.sln and rebuild the dlls and
> libs. (Without this step I encountered an initialization error when
> using opencv in vc++ 2003.)
>
> 3. Follow the instructions from this site to integrate openCV to my
> project.
> (http://homepages.nyu.edu/~rnp226/mocap/openvc_visualstudio_guide.txt)
>
>
> Am I missing any steps in the setup process or do I need to change
> any settings in my project properties?
>
>
> Thank you very much.
>
> Joe
>
>
>
> ------------------------------------
>
> Change settings: http://www.yahoogroups.com/mygroups, select
>    Get Emails (get all posts)
>    Daily Digest (one summary email per day)
>    Read on the web (read posts on the web only)Or Unsubscribe by mailing [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Re: new to openCV....have question about cvReleaseImage() error in in VC++ 2003

Peter Eisenlohr
Jean-Pierre Landry schrieb:
> I would maybe check the value of 'tpl' before releasing it...
> cvLoadImage will return a NULL pointer if it can't find the file...

Not necessary. cvReleaseImage() is save if *tpl is NULL.

  Peter
Reply | Threaded
Open this post in threaded view
|

Re: new to openCV....have question about cvReleaseImage() error in in VC++ 2003

Jean-Pierre Landry
Agreed!  :-)

I didn't take the time to verify but according to this:

CV_IMPL void
cvReleaseImage( IplImage ** image )
{
     CV_FUNCNAME( "cvReleaseImage" );

     __BEGIN__

     if( !image )
         CV_ERROR( CV_StsNullPtr, "" );

     if( *image )
     {
         IplImage* img = *image;
         *image = 0;

         cvReleaseData( img );
         cvReleaseImageHeader( &img );
     }

     __END__;
}

I would say you're right...  :-)

But saying MFC brings error is, I think, premature here...  :-)

The orignal poster's problem is maybe with compilation switches or
something...  I see no apparent reason why this simple code would fail...

Peter Eisenlohr wrote:

> Jean-Pierre Landry schrieb:
>> I would maybe check the value of 'tpl' before releasing it...
>> cvLoadImage will return a NULL pointer if it can't find the file...
>
> Not necessary. cvReleaseImage() is save if *tpl is NULL.
>
>   Peter
>
>
> ------------------------------------
>
> Change settings: http://www.yahoogroups.com/mygroups, select
>    Get Emails (get all posts)
>    Daily Digest (one summary email per day)
>    Read on the web (read posts on the web only)Or Unsubscribe by mailing [hidden email]