-
大小: 80.22MB文件類型: .7z金幣: 2下載: 1 次發布日期: 2023-05-05
- 語言: 其他
- 標簽: opencv??4.2.0??opencv_contr??tbb??
資源簡介
Windows環境使用VS2017編譯opencv-4.2.0和opencv_contrib-4.2.0源碼,支持TBB
包含x86和x64
https://blog.csdn.net/libaineu2004/article/details/104252289
包含x86和x64
https://blog.csdn.net/libaineu2004/article/details/104252289
代碼片段和文件信息
//?cv420test.cpp?:?此文件包含?“main“?函數。程序執行將在此處開始并結束。
//
#include?
#include?
#include?
//原文鏈接:https://blog.csdn.net/libaineu2004/article/details/104252289
int?main()
{
cv::Mat?imageL?=?cv::imread(“origin_1.jpg“);
cv::Mat?imageR?=?cv::imread(“origin_2.jpg“);
/*imshow(“1“?imageL);
imshow(“2“?imageR);
waitKey();
return?0;*/
//提取特征點方法
//SIFT
cv::Ptr?sift?=?cv::xfeatures2d::SIFT::create();
//ORB
//cv::Ptr?orb?=?cv::ORB::create();
//SURF
//cv::Ptr?surf?=?cv::xfeatures2d::SURF::create();
//特征點
std::vector?keyPointL?keyPointR;
//單獨提取特征點
sift->detect(imageL?keyPointL);
sift->detect(imageR?keyPointR);
//畫特征點
cv::Mat?keyPointImageL;
cv::Mat?keyPointImageR;
drawKeypoints(imageL?keyPointL?keyPointImageL?cv::Scalar::all(-1)?cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
drawKeypoints(imageR?keyPointR?keyPointImageR?cv::Scalar::all(-1)?cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
//顯示窗口
cv::namedWindow(“KeyPoints?of?imageL“);
cv::namedWindow(“KeyPoints?of?imageR“);
//顯示特征點
cv::imshow(“KeyPoints?of?imageL“?keyPointImageL);
cv::imshow(“KeyPoints?of?imageR“?keyPointImageR);
//特征點匹配
cv::Mat?despL?despR;
//提取特征點并計算特征描述子
sift->detectAndCompute(imageL?cv::Mat()?keyPointL?despL);
sift->detectAndCompute(imageR?cv::Mat()?keyPointR?despR);
//Struct?for?DMatch:?query?descriptor?index?train?descriptor?index?train?image?index?and?distance?between?descriptors.
//int?queryIdx?–>是測試圖像的特征點描述符(?descriptor?)的下標,同時也是描述符對應特征點(keypoint)的下標。
//int?trainIdx?–>?是樣本圖像的特征點描述符的下標,同樣也是相應的特征點的下標。
//int?imgIdx?–>當樣本是多張圖像的話有用。
//float?distance?–>代表這一對匹配的特征點描述符(本質是向量)的歐氏距離,數值越小也就說明兩個特征點越相像。
std::vector?matches;
//如果采用?flannbased?方法?那么?desp通過orb的到的類型不同需要先轉換類型
if?(despL.type()?!=?CV_32F?||?despR.type()?!=?CV_32F)
{
despL.convertTo(despL?CV_32F);
despR.convertTo(despR?CV_32F);
}
cv::PtrriptorMatcher>?matcher?=?cv::DescriptorMatcher::create(“Flannbased“);
matcher->match(despL?despR?matches);
//計算特征點距離的最大值
double?maxDist?=?0;
for?(int?i?=?0;?i? {
double?dist?=?matches[i].distance;
if?(dist?>?maxDist)
maxDist?=?dist;
}
//挑選好的匹配點
std::vector?good_matches;
for?(int?i?=?0;?i? {
if?(matches[i].distance?0.5?*?maxDist)
{
good_matches.push_back(matches[i]);
}
}
cv::Mat?imageOutput;
cv::drawMatches(imageL?keyPointL?imageR?keyPointR?good_matches?imageOutput);
cv::namedWindow(“picture?of?matching“);
cv::imshow(“picture?of?matching“?imageOutput);
cv::waitKey(0);
return?0;
}
//?運行程序:?Ctrl?+?F5?或調試?>“開始執行(不調試)”菜單
//?調試程序:?F5?或調試?>“開始調試”菜單
//?入門使用技巧:
//???1.?使用解決方案資源管理器窗口添加/管理文件
//???2.?使用團隊資源管理器窗口連接到源代碼管理
//???3.?使用輸出窗口查看生成輸出和其他消息
//???4.?使用錯誤列表窗口查看錯誤
//???5.?轉到“項目”>“添加新項”以創建新的代碼文件,或轉到“項目”>“添加現有項”以將現有代碼文件添加到項目
//???6.?將來,若要再次打開此項目,請轉到“文件”>“打開”>“項目”并選擇?.sln?文件
- 上一篇:JT/T808、809模擬、壓測工具
- 下一篇:36個漂亮的各類型網站源代碼
評論
共有 條評論