0

I'm trying to detect an object using opencv and Visual Studio Ultimate using C++. I'm having problems concerning cv::Mat, I cannot find any example of object detection with that kind of variable but just with IplImage. I tried to use an IplImage code and convert it to Mat, but it didn't work. But i don not want to use IplImage, my first part of code is in Mat and I want to keep using it.

What I'm trying to actually do is to detect the BIGGEST rectangle in the image stored from the cam, after thresholding it.

I have already done the threshold part and it's ok, it works and i can se my object (in white) moving in a black background.

Could someone help me with the tracking part? I have seen on the net some blob filtering solutions but they were way too difficult for me! If you can come up with an easy one it would be better.

thank you!

Daisy
  • 1
  • 1
  • http://docs.opencv.org/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.html#cascade-classifier – juanchopanza Aug 24 '12 at 10:11
  • 1
    @Daisy Hello, could we see examples ? – Quentin Geissmann Aug 24 '12 at 10:12
  • @QuentinGeissmann Hi, I have a 2 colors image (white/black). I would like to detect the approximate coordinates of the biggest white part (which is the object). To do so I thought to consider the object as a rectangle, to make it easier.. Am i clear? – Daisy Aug 24 '12 at 11:32
  • please post some code as example – masad Aug 24 '12 at 17:32

2 Answers2

0

cv::Mat is the new image class in opencv. I think the most algorithms still use IplImage. For this reason I have asked times ago the following:

openCV mixing IplImage with cv::Mat

For recognition of objects I would say watch the cvMatchTemplate function of opencv. There is also the mat version cv::matchTemplate. There are also other object recognition methods but they are a bit more difficult to implement ;)

I dont know if I maybe understood your other question right but I think you wannt to recognze rectangle in your image. Maybe watch this tutorial:

http://docs.opencv.org/trunk/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.html

I don t know any standard algorithm for rectangles maybe you will need to code it yourself

Community
  • 1
  • 1
jamk
  • 780
  • 1
  • 8
  • 23
  • You might be better of finding rectangles using CvApproxPoly(). You can find a good example of how to use this function to find rectangles in this example: http://www.aishack.in/2010/01/an-introduction-to-contours/ – diip_thomas Aug 31 '12 at 16:30
0

cv::Mat encapsulate the lower level IplImage and other formats. Regard detection, there is a sample that you could find useful: squares. I googled for it, and found also this other question, that's more recent and could be of interest to you.

Community
  • 1
  • 1
CapelliC
  • 57,813
  • 4
  • 41
  • 80