#include #include using namespace std;
int main()
影象相似度orb演算法
#define _crt_secure_no_deprecate
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;
using namespace cv;
//opencv影象相似度orb演算法(影象特徵比對)
int getorb(char * imagepatha, char * imagepathb)
orb orb;
vectorkeypoints_1, keypoints_2;
mat descriptors_1, descriptors_2;
orb(img_1, mat(), keypoints_1, descriptors_1);
orb(img_2, mat(), keypoints_2, descriptors_2);
bruteforcematchermatcher;
vectormatches;
matcher.match(descriptors_1, descriptors_2, matches);
double max_dist = 0; double min_dist = 100;
for (int i = 0; i < descriptors_1.rows; i++)
printf("-- max dist : %f \n", max_dist);
printf("-- min dist : %f \n", min_dist);
std::vector< dmatch > good_matches;
for (int i = 0; i < descriptors_1.rows; i++)
} t = gettickcount() - t;
t = t * 1000 / gettickfrequency();
mat img_matches;
drawmatches(img_1, keypoints_1, img_2, keypoints_2, good_matches, img_matches,
scalar::all(-1), scalar::all(-1), vector(),
drawmatchesflags::not_draw_single_points);
imshow("match", img_matches);
printf("%f ms\n", t);
cvwaitkey(0);
return 0;
}int main(int argc, char* argv)
google影象對比基本演算法
#include #include #include // google影象對比基本演算法
//計算影象感知hash值。詳情看:
int64 calcimageperceptualhashkey(const iplimage* pimage)
} felementmean /= 64;
unsigned char celementkey = 0;
int64 key = 0;
unsigned char* pkeyptr = (unsigned char*)&key;
for (int y = 0; y < 8; ++y)
else
}pkeyptr[y] = celementkey;
} cvreleaseimage(&pgrayscaleimage);
return key;
}//比較2個key的相似度,結果以1為最相似,0為不相似。
float compareimagekeysimilarity(int64 key1, int64 key2)
printf("nonecount = %dn", nonecount);
return nonecount == 0 ? 1 : (64 - nonecount) / (float)64;
}int main(int argc, char* argv)
模板匹配:
/**
* @file matchtemplate_demo.cpp
* @brief sample code to use the function matchtemplate
* @author opencv team
*///#include #include #include #include #include using namespace std;
using namespace cv;
/// global variables
mat img; mat templ; mat result;
const char* image_window = "source image";
const char* result_window = "result window";
int match_method;
int max_trackbar = 5;
/// function headers
void matchingmethod(int, void*);
/*** @function main
*/int main(int, char** argv)
/*** @function matchingmethod
* @brief trackbar callback
*/void matchingmethod(int, void*)
else
/// show me what you got
rectangle(img_display, matchloc, point(matchloc.x + templ.cols, matchloc.y + templ.rows), scalar::all(0), 2, 8, 0);
rectangle(result, matchloc, point(matchloc.x + templ.cols, matchloc.y + templ.rows), scalar::all(0), 2, 8, 0);
imshow(image_window, img_display);
imshow(result_window, result);
return;
}
相似性對比
#include #include #include #include #include /*
*函式功能:獲取輸入影象 的輪廓
**輸入:
*srcin : 單通道影象
**返回:
*cvseq* : 儲存輪廓資訊**/
cvseq* getimagecontour(iplimage* srcin)
//二值化影象
cvthreshold(src, src, 100, 255, 0);
//計算影象輪廓 計算後的輪廓資訊不能釋放 在後面需要用到
cvfindcontours(src, mem, &seq, sizeof(cvcontour), cv_retr_ccomp);
//釋放影象空間
cvreleaseimage(&src);
//返回輪廓資訊
return seq;
}int main(int argc, char* argv)
Cmake構建OpenCV測試例子
適用cmake的cmakelists.txt來編譯乙個opencv的測試例子。cmakelists.txt的寫法為 project main 新增標頭檔案路徑 include directories usr local opencv347 include usr local opencv347 in...
opencv聯合dlib人臉檢測例子
原始碼比較簡潔,雜餘資訊全部去掉,原始碼中已經做了中文注釋。本例子是用opencv載入影象,然後呼叫dlib進行人臉檢測,得到人臉所在區域以及特徵點,最後還是用opencv描繪人臉特徵點。例子原始碼以及解釋 include include include include include includ...
jQuery cookie的使用例子
這是乙個jquery cookie的使用例子,通過本示例的學習希望朋友們能熟悉在引入jquery.cookie.js外掛程式後,如何去使用它,你可以了解到cookie天數設定 日期設定 多個cookie的設定 如何獲取cookie 通過 date 物件設定過期日期為 3 天後的那天 設定有效期天數等...