OpenCV, c++ problem

Hello experts!

I am C++ and OpenCV newbie.

Please have a look at the attached image.

This is my code:

int _tmain(int argc, _TCHAR* argv[])
              IplImage* src;

      IplImage* dst = cvCreateImage(cvGetSize(src), 8, 1);
      IplImage* color_dst = cvCreateImage(cvGetSize(src), 8, 3);
      CvMemStorage* storage = cvCreateMemStorage(0);
      CvSeq* lines = 0;

      int i;
      cvCanny(src, dst, 50, 200, 3); //<- program crashes inside this method

      cvCvtColor(dst, color_dst, CV_GRAY2BGR);

      lines = cvHoughLines2(dst,      storage, CV_HOUGH_PROBABILISTIC, 1, CV_PI/180, 80, 30, 10);

      for( i = 0; i < lines->total; i++)
            CvPoint* line = (CvPoint*)cvGetSeqElem(lines,i);
            cvLine(color_dst, line[0], line[1], CV_RGB(255,0,0), 3, 8);

      cvNamedWindow("Source", 1);
      cvShowImage("Source", src);
      cvNamedWindow("Hough", 1);
      cvShowImage("Hough", color_dst);



Any ideas? For me it looks like program crashed inside dll library, maybe dll contains bug?

Thank you

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Just press the "Break" button in the dialog that you posted, then the debugger will jump to the code-line where the crash occured.
Most likely "pic1.bmp" cant be found.
Well, it's not a crash, it's a diagnotic exception raised by OpenCV telling you that there's something wrong with the parameters you are passing to 'cvCanny()' (or 'cvSobel()' respectively, which is called by that function) - here it is that the number of color channels does not seem to match both the source and destination image ('src.channels() == dst.channels()' in your console window).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

panJamesAuthor Commented:
ikework: -> it can find the image

jkr:it may be the reason. I will try different images.

Try specifying compatible parameters with 'cvCreateImage()'.
panJamesAuthor Commented:
In "Learning OpenCV" I found that I need 8bit image. And according to IrfanView I actually use such file (8 bitsperpixel).

Still I get errors as you can see on attached image.

Any ideas?


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.