OpenCv - Depth Map

937 views Asked by At

Hello Stackoverflowers,

My current assignment includes finding if a metal billet (log) is made out of one or two parts. My first go at this was searching for a black vertical line, indicating a separation between two logs. If i can't find a separation i conclude it's one piece.

enter image description here

This program worked flawless until.... dark colloured billets came along... enter image description here

So i decided to use one other parameter which i know will always be true, depth. There will always be a depth different between a billet and the gap.

So i dediced to try two camera's mounted parallel to eachother, does anyone have any pointers how to set this up properly?

Or does somebody know another way to accomplish my task?

Thanks in advance!

1

There are 1 answers

2
stupidstudent On BEST ANSWER

Will work best IMO: Use a cheap laser line (around 20$ in a tools / hardware shop), and search the laser in the image. It the lines runs over the whole billet it is one piece. If there is a break in the line or a strong disortion there are 2 billets.

My idea:

glm::vec3 laserColor(1,0,0); //red
glm::vec3 currentColor;
float maximum_color_distance = 0.1;
for(int a = 0; a < image.rows;a++)
{
     for(int b = 0; b < image.rows;b++)
     { 
        currentColor = image.at(a,b);
        float current_distance = glm::distance(laserColor, currentColor);
        if(current_distance > maximum_color_distance)
        {
           image.at(a,b) = 0;
        }
     }
}

glm::vec2 leftPixel = getMostLeftLaserPixel(image);
glm::vec2 rightPixel = getMostRightLaserPixel(image);

 Line line = calculateLine (leftPixel,rightPixel);

line.hasHoles(image, laserColor); //checks for 3x3 pxiel blocks which are on the line, returns false if all pixels in a 3x3 block have an other color then the laser. 3x3 to take small erros to serious

Maybe you can use a kinect in the right distance if the billets are far away enough. Stereo Images use most time block matching on an epipolar line. This means take 3x3 pixels, go from left to right, and try to find 3x3 pixels which look similar. This could be a problem by using metal. First you have repeating patters. Second you have reflection, which will be different on each camera, since they have a slightly different viewing angle.

The kinect could have the same problems with the metal reflectness too, but not with repeating patterns:

"It depends on the material that is used to make the object. If the object is made out of metal, glass or it is shiny, the depth camera will face difficulty in capturing the image accurately."

OpenCV provides the rectifyStereoIamge (or something called similar) function which helps a lot when you use 2 cameras.