Solved

OpenCV, c++ problem

Posted on 2010-08-12
7
716 Views
Last Modified: 2012-08-14
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;

      src=cvLoadImage("pic1.bmp");
      
      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);

      cvWaitKey(0);

}

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

Thank you

panJames
cvroblem.gif
0
Comment
Question by:panJames
  • 2
  • 2
  • 2
7 Comments
 
LVL 20

Expert Comment

by:ikework
ID: 33421692
Just press the "Break" button in the dialog that you posted, then the debugger will jump to the code-line where the crash occured.
0
 
LVL 20

Expert Comment

by:ikework
ID: 33421715
Most likely "pic1.bmp" cant be found.
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 33421733
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).
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:panJames
ID: 33424139
ikework: -> it can find the image

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

panJames
0
 
LVL 86

Expert Comment

by:jkr
ID: 33424200
Try specifying compatible parameters with 'cvCreateImage()'.
0
 

Author Comment

by:panJames
ID: 33429087
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?

panJames






cv.gif
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now