Error MSG:Bad argument (Array should be cvMat or IplImage) in function [openCVDir]\cxcore\src\cxarray.cpp

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

Error MSG:Bad argument (Array should be cvMat or IplImage) in function [openCVDir]\cxcore\src\cxarray.cpp

Venkat-3
Hi Everybody,
                  I am just getting started with openCV. I was running this
sample code

\* This Code generated by cvPreprocessor ver 0.5 */
#include <cv.h>
#include <highgui.h>

IplImage* img,*pimg,*timg;
void Process();

int main( )
{
   Process();
   if(img){
     cvNamedWindow( "Source", 1 );
     cvShowImage( "Source", img );
   }
   if(pimg){
     cvNamedWindow( "Processed Image", 1 );
     cvShowImage( "Processed Image", pimg );
   }
   cvWaitKey(0);

   if(img)
     cvReleaseImage(&img);
   if(pimg)
     cvReleaseImage(&pimg);

}
void Process()
{

/* Loads Images */
  if(img)
   // cvReleaseImage(&img);
  img=cvLoadImage( "03.jpg ", CV_LOAD_IMAGE_UNCHANGED );
/* Converts image from color space ( RGB ) to a Gray Scale */
  if(pimg)
    cvReleaseImage(&pimg);
  pimg = cvCreateImage( cvGetSize(img), IPL_DEPTH_8U, 1 );
  cvCvtColor( img, pimg, CV_RGB2GRAY );
}



and am getting this error message

*Error MSG:Bad argument (Array should be cvMat or IplImage) in function
[openCVDir]\cxcore\src\cxarray.cpp*
*Abort, Retry, Fail*

**
*Other sample codes are working fine. *Can you please tell me the cause of
this error?

*Thanks*


--
Venkat


[Non-text portions of this message have been removed]

Reply | Threaded
Open this post in threaded view
|

Re: Error MSG:Bad argument (Array should be cvMat or IplImage) in function [open

get_imaginary
It would help to know which line is throwing the error. (That's a good
first step, btw, when debugging any code ;)

However, even w/o that.... It's possible you need to initialize img
and pimg:
IplImage* img=0,*pimg=0,*timg=0;

I'd also suggest you add checks for img==0 and pimg==0 before using
them in function calls.

Robin


--- In [hidden email], Venkat <venkat.ufl@...> wrote:
>
> Hi Everybody,
>                   I am just getting started with openCV. I was
running this

> sample code
>
> \* This Code generated by cvPreprocessor ver 0.5 */
> #include <cv.h>
> #include <highgui.h>
>
> IplImage* img,*pimg,*timg;
> void Process();
>
> int main( )
> {
>    Process();
>    if(img){
>      cvNamedWindow( "Source", 1 );
>      cvShowImage( "Source", img );
>    }
>    if(pimg){
>      cvNamedWindow( "Processed Image", 1 );
>      cvShowImage( "Processed Image", pimg );
>    }
>    cvWaitKey(0);
>
>    if(img)
>      cvReleaseImage(&img);
>    if(pimg)
>      cvReleaseImage(&pimg);
>
> }
> void Process()
> {
>
> /* Loads Images */
>   if(img)
>    // cvReleaseImage(&img);
>   img=cvLoadImage( "03.jpg ", CV_LOAD_IMAGE_UNCHANGED );
> /* Converts image from color space ( RGB ) to a Gray Scale */
>   if(pimg)
>     cvReleaseImage(&pimg);
>   pimg = cvCreateImage( cvGetSize(img), IPL_DEPTH_8U, 1 );
>   cvCvtColor( img, pimg, CV_RGB2GRAY );
> }
>
>
>
> and am getting this error message
>
> *Error MSG:Bad argument (Array should be cvMat or IplImage) in function
> [openCVDir]\cxcore\src\cxarray.cpp*
> *Abort, Retry, Fail*
>
> **
> *Other sample codes are working fine. *Can you please tell me the
cause of

> this error?
>
> *Thanks*
>
>
> --
> Venkat
>
>
> [Non-text portions of this message have been removed]
>


Reply | Threaded
Open this post in threaded view
|

Re: Error MSG:Bad argument (Array should be cvMat or IplImage) in function [openCVDir]\cxcore\src\cxarray.cpp

Adam Coirazza
In reply to this post by Venkat-3
what line generates the error?

also, i've found that you can nest the method which returns the image
directly in the cvCvtColor method to avoid having too many intermediate
objects, assuming you don't need them.

On Fri, Jan 2, 2009 at 6:00 PM, Venkat <[hidden email]> wrote:

>   Hi Everybody,
> I am just getting started with openCV. I was running this
> sample code
>
> \* This Code generated by cvPreprocessor ver 0.5 */
> #include <cv.h>
> #include <highgui.h>
>
> IplImage* img,*pimg,*timg;
> void Process();
>
> int main( )
> {
> Process();
> if(img){
> cvNamedWindow( "Source", 1 );
> cvShowImage( "Source", img );
> }
> if(pimg){
> cvNamedWindow( "Processed Image", 1 );
> cvShowImage( "Processed Image", pimg );
> }
> cvWaitKey(0);
>
> if(img)
> cvReleaseImage(&img);
> if(pimg)
> cvReleaseImage(&pimg);
>
> }
> void Process()
> {
>
> /* Loads Images */
> if(img)
> // cvReleaseImage(&img);
> img=cvLoadImage( "03.jpg ", CV_LOAD_IMAGE_UNCHANGED );
> /* Converts image from color space ( RGB ) to a Gray Scale */
> if(pimg)
> cvReleaseImage(&pimg);
> pimg = cvCreateImage( cvGetSize(img), IPL_DEPTH_8U, 1 );
> cvCvtColor( img, pimg, CV_RGB2GRAY );
> }
>
> and am getting this error message
>
> *Error MSG:Bad argument (Array should be cvMat or IplImage) in function
> [openCVDir]\cxcore\src\cxarray.cpp*
> *Abort, Retry, Fail*
>
> **
> *Other sample codes are working fine. *Can you please tell me the cause of
> this error?
>
> *Thanks*
>
> --
> Venkat
>
> [Non-text portions of this message have been removed]
>
>
>



--
Cheers

Adam Coirazza
TKE KX-499
Crysophylos / Hegemon
514-266-6031


[Non-text portions of this message have been removed]