OpenCV中文网站

 找回密码
 立即注册
搜索
热搜: 安装 配置
查看: 2444|回复: 0

哪位大神知道哪里出错了,非常感谢。

[复制链接]
发表于 2018-10-19 19:44:33 | 显示全部楼层 |阅读模式
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <stdio.h>
#include<stdlib.h>
#include<iostream>


using namespace std;
using namespace cv;

int m =255;
Mat n(3157, 4309, CV_32FC1);
Mat A(3157, 4309, CV_32FC1);
int main()
{
        Mat img, templ, result;
        img = imread("350.jpg");//待搜索图像
        templ = imread("pic2.bmp");//搜索模板

        int result_cols = img.cols - templ.cols + 1;
        int result_rows = img.rows - templ.rows + 1;       //比较结果映射图像
        result.create(result_cols, result_rows, CV_32FC1);

        matchTemplate(img, templ, result, CV_TM_SQDIFF_NORMED);//标准平方差匹配 method=CV_TM_SQDIFF_NORMED,
                                                                                                                   //数值越小匹配度越好

       
        normalize(result, result, 0, 1, NORM_MINMAX, -1, Mat());  //矩阵归一化

       
        Mat n = result*m;

        //cout << "矩阵" << n;

        int i = 0;
        int j = 0;
        float b=0;
    float c=0;

       
        for (int i = 0; i < A.rows; i++);
        {
                for (int j = 0; j < A.cols; j++);
                {
                        b = n.at<float>(i, j);
                        c = cvFloor(b);
                        A.at<float>(i, j) = c;
                }       
        }

        cout << "矩阵" << A;

        cvNamedWindow("img", CV_WINDOW_NORMAL);
        imshow("img", img);
        waitKey(0);

        return 0;
       
}







C:\Users\sony\Desktop
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|OpenCV中文网站

GMT+8, 2024-4-29 05:02 , Processed in 0.009198 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表