OpenCv - 深度图

时间:2014-11-18 09:49:08

标签: opencv camera depth vision

Hello Stackoverflowers,

我目前的任务包括查找金属坯料(木材)是由一个或两个零件制成的。我第一次看到的是搜索黑色垂直线,表明两个日志之间的分离。如果我找不到分离,我就得出结论。

enter image description here

这个程序完美无缺,直到......黑暗的相互碰撞的方坯出现...... enter image description here

所以我决定使用另一个我知道永远是真实的参数,深度。方坯和间隙之间总会有不同的深度。

所以我致力于尝试两个相互平行安装的相机,有没有人有任何指针如何正确设置?

或者有人知道另一种方法来完成我的任务吗?

提前致谢!

1 个答案:

答案 0 :(得分:0)

最好的IMO: 使用便宜的激光线(在工具/硬件商店中约20美元),并在图像中搜索激光。它的线条贯穿整个方坯,是一块。如果线路中断或强烈的扭曲,则有2个方坯。

我的想法:

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

如果方坯足够远,也许你可以在适当的距离使用kinect。立体图像在极线上使用大多数时间块匹配。这意味着需要3x3像素,从左到右,并尝试找到3x3像素看起来相似。这可能是使用金属的问题。首先,你有重复的模式。其次你有反射,每个相机都会有不同的反射,因为它们的视角略有不同。

kinect也会出现与金属反射相同的问题,但不会出现重复模式:

“这取决于用于制作物体的材料。如果物体由金属,玻璃制成或有光泽,则深度相机将难以准确地捕捉图像。”

OpenCV提供了rectifyStereoIamge(或类似的东西)功能,当你使用2个摄像头时它会有很大的帮助。

相关问题