资源简介
该压缩包包含编译方式,示例代码,只需拍两张图片即可比较,比较打印输出值小于10,即为相似图片。使用改代码的用户linux系统必须先安装opencv环境.

代码片段和文件信息
// similarity.cpp : 定义控制台应用程序的入口点。
//
//#include “stdafx.h“
#include
#include
#include
#include
#pragma comment(lib“opencv_core2410d.lib“)
#pragma comment(lib“opencv_highgui2410d.lib“)
#pragma comment(lib“opencv_imgproc2410d.lib“)
using namespace std;
int main(int argc char* argv[])
{
string strSrcImageName1 = “pos11.jpg“;
string strSrcImageName2 = “pos12.jpg“;
cv::Mat matSrc matSrc1 matSrc2;
//matSrc = cv::imread(strSrcImageName CV_LOAD_IMAGE_COLOR);
//CV_Assert(matSrc.channels() == 3);
matSrc1 = cv::imread(strSrcImageName1 CV_LOAD_IMAGE_COLOR);
if (matSrc1.empty())
{
cout<<“read failed“<< endl;
return -1;
}
matSrc2 = cv::imread(strSrcImageName2 CV_LOAD_IMAGE_COLOR);
if (matSrc2.empty())
{
cout<<“read failed“<< endl;
return -1;
}
cv::Mat matDst1 matDst2;
cv::cvtColor(matSrc1 matDst1 CV_BGR2GRAY);
cv::cvtColor(matSrc2 matDst2 CV_BGR2GRAY);
int iAvg1 = 0 iAvg2 = 0;
int arr1[64] arr2[64];
for (int i = 0; i < 8; i++)
{
uchar* data1 = matDst1.ptr(i);
uchar* data2 = matDst2.ptr(i);
int tmp = i * 8;
for (int j = 0; j < 8; j++)
{
int tmp1 = tmp + j;
arr1[tmp1] = data1[j] / 4 * 4;
arr2[tmp1] = data2[j] / 4 * 4;
iAvg1 += arr1[tmp1];
iAvg2 += arr2[tmp1];
}
}
iAvg1 /= 64;
iAvg2 /= 64;
for (int i = 0; i < 64; i++)
{
arr1[i] = (arr1[i] >= iAvg1) ? 1 : 0;
arr2[i] = (arr2[i] >= iAvg2) ? 1 : 0;
}
int iDiffNum = 0;
for (int i = 0; i < 64; i++)
if (arr1[i] != arr2[i])
++iDiffNum;
cout<<“iDiffNum = “<
if (iDiffNum <= 5)
cout<<“two images are very similar!“< else if (iDiffNum > 10)
cout<<“they are two different images!“< else
cout<<“two image are somewhat similar!“<
// getchar();
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 277 2017-08-21 18:44 similarity\build_all.sh
文件 72794 2017-08-21 18:41 similarity\similarity
文件 84883 2017-08-21 18:19 similarity\pos1.jpg
文件 2241 2017-08-21 18:41 similarity\similarity.cpp
文件 84883 2017-08-21 18:19 similarity\pos2.jpg
文件 82773 2017-08-21 18:40 similarity\pos11.jpg
文件 82632 2017-08-21 18:20 similarity\pos22.jpg
文件 82427 2017-08-21 18:40 similarity\pos12.jpg
目录 0 2017-08-21 18:44 similarity
----------- --------- ---------- ----- ----
492910 9
相关资源
- 基于OpenCV的数字识别468815
- 使用opencv去掉二值化图像中黑色面积
- opencv环境配置
- win10 64位下编译的opencv4.5.5库,opencv
- NVIDIAOpticalFlowSDK-79c6cee80a2df9a196f20afd6
- opencv_contrib-3.4.0.zip
- opencv2.4.9源码分析——SIFT
- 用两个摄像头实现,双目标定,双目
- opencv_traincascade训练分类器,手势识别
- opencv3.0交叉编译用parallel.cpp
- 基于opencv的图像识别识别图像中的色
- 基于openCV的识别特定颜色区域
- 基于OpenCV的分水岭算法实现
- QT+opencv+OCR 身份证号码,银行卡号识别
- opencv视频特定颜色区域识别
- 把RGB转换为HSV和HSI然后根据黄色和蓝
- opencv视觉测距
- 基于Qt和opencv的身份证号码识别系统
- opencv_ffmpeg249.dll
- SfM稀疏三维点云重建--完整工程文件
- 基于opencv的数人头程序源代码
- 利用OpenCV中的Stitcher类实现全景图像拼
- opencv实现的sift算法源码,包含了图像
- openCV 上的小波变换
- 基于OPENCV的车牌识别系统设计
- 617张国内车牌60-17bmp图片用于OpenCV正样
- hog特征提取,c版本代码
- 基于Qt5.8+OpenCV3.2的Basler多相机触发开
- 基于Opencv实现的图像纠偏
- ImageWatch2019.vsix
评论
共有 条评论