识别具有相同形状的随机放置的对象

时间:2017-01-25 07:17:32

标签: image-processing pattern-matching robotics object-detection object-recognition

如下图所示,获取随机放置物体的确切位置的最佳方法是什么:

enter image description here

我想建立机器人应用程序,以便机器人能够从盒子中随机挑选金属部件。所以我们有一个盒子里有很多提到的部分,随机扔进那个盒子里。机器人必须拾取那些物体并将它们放在其他空盒子里。

谢谢大家的回答!

1 个答案:

答案 0 :(得分:0)

假设比较的图像具有相同的比例:

// read template and convert it to polar coordinates
int radius = 100;
Mat target = imread("target.jpg);

Mat template;
cvLinearPolar(target, template, Point(target.cols/2, target.rows/2), ...);

// read src
Mat src = imread("src.jpg);

// initialize values to store best match
double best_score = DBL_MAX;
double best_x = -1;
double best_y = -1;
double best_angle = -1;

for (x=0;x<src.width;x++)
  for (y=0;y<src.height;y++) {
    Mat polar;
    cvLinearPolar(src, polar, Point(x,y), ...);

    ... calculate the best rotation angle that produces smallest difference
    ... between matched template and a calculated polar image

    if (min_difference < best_score) {
       ... update score, x, y, angle ...
    }
}

... best_x, best_y, best_angle should now store the best object location