Null pointer (NULL array pointer is passed)

A

aneuryzma

Hi,

this is my code:

IplImage *image = 0;

....

if( !image ) {
image = cvCreateImage( cvGetSize(frame), 8, 3 );
image->origin = frame->origin;

}

myMethod(image);

cvShowImage( "CamShiftDemo", image );

....


Why do I receive this error ? I'm just passing the pointer image by
reference.. when myMethod finishes, I should have the same pointer to
the modified image instead it is NULL.. ?
 
E

Eric Pruneau

aneuryzma said:
Hi,

this is my code:

IplImage *image = 0;

...

if( !image ) {
image = cvCreateImage( cvGetSize(frame), 8, 3 );
image->origin = frame->origin;

}

myMethod(image);

cvShowImage( "CamShiftDemo", image );

...


Why do I receive this error ?

hummm what error again????
I'm just passing the pointer image by
reference.. when myMethod finishes, I should have the same pointer to
the modified image instead it is NULL.. ?

myMethod probably assign NULL to image... is myMethod declared like that

void myMethod(IplImage*& img);

If you do want to change the value of the pointer, but want to change the
value of what it is pointing to (I strongly suspect it is an image...) then
declare myMethod like that

void myMethod(IplImage* img);

Anyway, if after calling myMethod, your pointer is NULL, then you proibalby
have something else wrong in you method...
 
D

Default User

aneuryzma wrote:

Why do I receive this error ? I'm just passing the pointer image by
reference.. when myMethod finishes, I should have the same pointer to
the modified image instead it is NULL.. ?


Please post a complete, minimal program that demonstrates the problem.





Brian
 
J

Jim Langston

aneuryzma said:
Hi,

this is my code:

IplImage *image = 0;

...

if( !image ) {
image = cvCreateImage( cvGetSize(frame), 8, 3 );
image->origin = frame->origin;

}

myMethod(image);

cvShowImage( "CamShiftDemo", image );
Why do I receive this error ? I'm just passing the pointer image by
reference.. when myMethod finishes, I should have the same pointer to
the modified image instead it is NULL.. ?

You did not give us the signature of cvShowImage or what the error message
is. So without cod I can only guess.
Check line 42 of your program.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top