【问题标题】:IMAGE COMPARISON USING OPENCV code from poitr使用 poitr 的 OPENCV 代码进行图像比较
【发布时间】:2013-09-03 16:42:05
【问题描述】:

您好,我找到了这段代码来比较图像

cv::Mat img1 = ...
cv::Mat img2 = ...
cv::Mat result = ...

int threshold = (double)(img1.rows * img1.cols) * 0.7; 

cv::compare(img1 , img2  , result , cv::CMP_EQ );
int similarPixels  = countNonZero(result);

if ( similarPixels  > threshold ) {
   cout << "similar" << endl;
}

但由于我是 OPENCV 的新手,我不知道“cv::Mat img1=...”的值是什么 请帮助我并尝试以图像路径为值的代码,但它给出了错误

【问题讨论】:

    标签: c++ opencv image-processing


    【解决方案1】:
    void compare(const MatND& src1, const MatND& src2, MatND& dst, int cmpop)
    

    比较函数有 4 个参数,这是 ;

    •src1 – The first source array
    •src2 – The second source array; must have the same size and same type as src1
    •value – The scalar value to compare each array element with
    •dst – The destination array; will have the same size as src1 and type= CV_8UC1
    

    据我了解,这张图片有一些 fiducial points 之类的坐标系(X / Y )

    如;

    1 45 123
    2 56 164
    3 64 147
    

    并将这些点存储在数组中,然后将数组发送到比较函数以查找匹配器。

    如果你想进行图像比较,我的建议是你可以搜索feret database,它可以免费用于研究。

    【讨论】:

      【解决方案2】:

      您可以使用imread 将图像加载到cv::Mat img1,例如

      cv::Mat img1 = imread("c:\\test.bmp");    // To load an RGB image
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-06-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-04-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多