Rectangle localization on an image

edited July 2016 in Kinect

Hello everyone,

I'm a new user of processing, discovered this great thing a couple of weeks ago, and already enjoying it. I have a question about image processing.

The thing I have to do, is to detect (and localize on the picture) a set of rectangles.

Below is a drawing of what i would like to do : Capture_ezra

I tried to detect lines with hough lines detection algorithm, but it doesn't manage to do it.

Of course I just have to invert the picture, I don't have to do an edge detection (canny) as the images already shows the edges for the rectangles to be located.

Here is what I came up with so far.

void rect_detect(){
  PImage src = loadImage("Lignes_i.jpg");
  src.resize(width,height);
  //surface.setSize(src.width,src.height);

  opencv = new OpenCV(this,src);
  //opencv.findCannyEdges(20,75);

  // Arguments are: threshold, minLengthLength, maxLineGap
  lines = opencv.findLines(100, 30, 20);
}

I don't know if the reason is that the lines are not perfectly vertical or horizontal, but the detection is irrelevant. Capture_ezra_2

Tagged:

Answers

  • Hey Try the WarpPerspective example in the OpenCV examples. I think that could work for you and it is exactly what you are trying to do. For example, I tried your image. At first, I thought it didn't work as the first image does not make sense. However, if you try image #35 (through the get() function while assigning the contour object, it detected one of the rectangles. The question is to go through the array of objects and discards those that are not rectangles. Note that in your image, the algorithm detected 40 contours!

    I hope this helps,

    Kf

  • Thanks, I tried but didn't really got it to work :s However I succeded by using the "Find contours" example and by using the ".getBoundingBox()" method !

Sign In or Register to comment.