Aayman Khalid
Aayman Khalid

Reputation: 468

Line Detection openCV

I am running a code to detect lines in openCV 2.1 in visual studio 2008, here is some part of the code:

                  IplImage* src=cvLoadImage("parrot.png");

                  IplImage* dst = cvCreateImage( cvGetSize(src), 8, 1 );
                  IplImage* color_dst = cvCreateImage( cvGetSize(src), 8, 3 );
                  CvMemStorage* storage = cvCreateMemStorage(0);
                  CvSeq* lines = 0;
                  int i;
          int choice=0;
                  cvCanny( src, dst, 10, 100, 3 );

the code compiles fine,but when run gives the following error: OpenCV Error: Unsupported format or combination of formats () in unknown functi n, file ........\ocv\opencv\src\cv\cvcanny.cpp, line 66

any hints on how to fix this...

Upvotes: 0

Views: 483

Answers (1)

Safir
Safir

Reputation: 902

By default when you load an image it loads it as colour image cvLoadImage(const char* filename, int iscolor=CV_LOAD_IMAGE_COLOR). Canny requires single channel image as input and output void cvCanny(const CvArr* image, CvArr* edges, double threshold1, double threshold2, int aperture_size=3). So, I think if you load your image as gray scale or convert it later to gray scale it should work.

Either:

IplImage* src=cvLoadImage("parrot.png", CV_LOAD_IMAGE_GRAYSCALE );

Or:

cvtColor(src, src, CV_RGB2GRAY);

Upvotes: 2

Related Questions