Ask Your Question
0

Find pallet front view in 2d photo

asked 2019-12-03 00:08:09 -0600

Greydel gravatar image

updated 2019-12-04 00:10:50 -0600

Trato de encontrar un palet en una foto donde siempre se ve el objeto de frente. Hay alguna forma de definir un objeto como la combinación de figuras geométricas que lo componen o debo recurrir a entrenar un Haar cascade incluso para objetos tan simples?

I'm trying to find a pallet in a "very 2d" photo wich has always at least one object in front view. Is there any way to find objects by the combination of rectangular shapes or i need a cascade classifier? Sorry if my English has mistakes.

I also try using a color seed, picked by mouse, but i'm stocked calculating values for threshold not only for a point but for a window around the selected points. An example can ve ser here:

https://github.com/greydelpf/opencv_f...

All images i'm working look like these:image description

edit retag flag offensive close merge delete

Comments

could you add an example image, and show us, what you've tried so far ?

berak gravatar imageberak ( 2019-12-03 01:14:51 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2019-12-04 09:01:44 -0600

kbarni gravatar image

updated 2019-12-04 09:04:24 -0600

Well, if your photo is "very 2D", you can try to detect horizontal and vertical edges.

Get Gx and Gy gradients with a Sobel filter, then do a vertical sum on Gx and a horizontal sum on Gy using the reduce function.

The maxima of these vectors should represent the positions of the horizontal and vertical lines. Take the first and last to get the edges of the pallet.

The advantage of this approach is that it's simple, fast, color independent and works for any kind of boxes (you need no training for the look of the box). The disadvantage is that it works only if the lines are horizontal/vertical in the image.

If the lines are not horizontal/vertical, you can try to detect the corners of the boxes using the Harris corner detector or the edges using HoughLines or HoughLinesP and try to find the largest rectangle. If the color is known, you can try to segment it using thresholding and make a contour detector.

For an intractive approach (with mouse input), you can use GrabCut.

edit flag offensive delete link more

Comments

Thanks, i already did something like that but using houglines, i'll try your way to. And after i found all lines and rectangular shapes, is there a función for compare an sketch like contours? Iteraring over contours in Array or mats. I try in not optimized way, y found contours twise, first in the original photo and then again in a mat were i draw contours with biggers lines , that way i maximize the acuracy of found rectangular shapes even loosing the real meassures a little.

Greydel gravatar imageGreydel ( 2019-12-04 10:16:16 -0600 )edit

First try the simple solution.

For HoughLines, the parallel lines have the same rho, the perpendicular lines have a rho difference of pi/2. So to detect the horizontal borders, take the lines with rho~0 and look for the highest and lowest theta

kbarni gravatar imagekbarni ( 2019-12-05 09:30:58 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-12-03 00:08:09 -0600

Seen: 452 times

Last updated: Dec 04 '19