資源簡介
OpenCV3.1版本 Visual Studio 2015版本 把兩幅殘缺的眼底視網膜圖像拼接成一副完整的(程序運行時間有點長,耐心等待)
代碼片段和文件信息
#include?
#include?
#include?
using?namespace?std;
using?namespace?cv;
using?namespace?cv::xfeatures2d;
int?main()
{
Mat?img1?img2;
img2?=?imread(“001.png“);
img1?=?imread(“002.png“);
int?minHessian?=?1000;
//Ptr?detector?=?SIFT::create(minHessian);
Ptr?detector?=?SIFT::create(200030.000000000410.01.5);
vector?keypoint1;
vector?keypoint2;
Mat?descriptor1?descriptor2;
//detector->detect(img1?keypoint1);
detector->detectAndCompute(img1?Mat()?keypoint1?descriptor1);
????detector->detectAndCompute(img2?Mat()?keypoint2?descriptor2);
//Mat?copy_img1?=?img1.clone();
//Mat?copy_img2?=?img2.clone();
Mat?img_keyPoint1;
//Mat?img_keyPoint2;
drawKeypoints(img1?keypoint1?img_keyPoint1?Scalar::all(-1)?DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
resize(img_keyPoint1?img_keyPoint1?Size(1280?960));
imshow(“jieguo“?img_keyPoint1);
//特征匹配
double?t?=?(double)getTickCount();
FlannbasedMatcher?matcher;
vector?matches;
matcher.match(descriptor1?descriptor2?matches);
double?minDist?=?1000;
double?maxDist?=?0;
for?(int?i?=?0;?i?riptor1.rows;?i++)
{
double?dist?=?matches[i].distance;
if?(dist? ?minDist=dist;
if?(dist?>?maxDist)
maxDist?=?dist;
}
printf(“minDist?Distance:?%f\n“?minDist);
printf(“maxDist?Distance:?%f\n“?maxDist);
vector?goodMatches;
for?(int?i?=?0;?i?riptor1.rows;?i++)
{
double?dist?=?matches[i].distance;
if?(dist?>?(5*?minDist)?&&?dist?<(maxDist/2))
goodMatches.push_back(matches[i]);
}
Mat??matchesImg;
//drawMatches(img1?keypoint1?img2?keypoint2?goodMatches?matchesImg?Scalar(-1)?Scalar(-1)?vector()?DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
drawMatches(img1?keypoint1?img2?keypoint2?goodMatches?matchesImg?Scalar::all(-1)?Scalar::all(-1)?vector()?DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
t?=?(double)getTickCount()?-?t;
printf(“execution?time?=?%gms\n“?t*1000.0?/?getTickFrequency());
Mat?copymatchesImg?=?matchesImg.clone();
resize(copymatchesImg?copymatchesImg?Size(1280?480));
imshow(“Flann?Matching?Result“?copymatchesImg);
std::vector?obj;
std::vector?scene;
for?(int?i?=?0;?i?(int)goodMatches.size();?i++)
{
obj.push_back(keypoint1[goodMatches[i].queryIdx].pt);
scene.push_back(keypoint2[goodMatches[i].trainIdx].pt);
}
//直接調用ransac計算單應矩陣
Mat?H?=?findHomography(obj?scene?CV_RANSAC);
std::vector?obj_corners(4);
std::vector?scene_corners(4);
obj_corners[0]?=?Point(0?0);
obj_corners[1]?=?Point(img1.cols?0);
obj_corners[2]?=?Point(img1.cols?img1.rows);
obj_corners[3]?=?Point(0?img1.rows);
perspectiveTransform(obj_corners?scene_corners?H);
//--?Draw?lines?between?the?corners?(the?mapped?object?in?the?scene?-?image_2?)
Point2f?offset((
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.?????36352??2018-05-09?11:18??視網膜圖片拼接\.vs\FLANN?match\v14\.suo
?????文件????7895268??2014-07-22?13:41??視網膜圖片拼接\FLANN?match\001.png
?????文件????7565546??2014-07-22?13:41??視網膜圖片拼接\FLANN?match\002.png
?????文件???????7380??2018-04-08?10:13??視網膜圖片拼接\FLANN?match\FLANN?match.vcxproj
?????文件????????945??2018-04-08?10:13??視網膜圖片拼接\FLANN?match\FLANN?match.vcxproj.filters
?????文件???????5347??2018-07-05?14:37??視網膜圖片拼接\FLANN?match\main.cpp
?????文件???????1189??2018-07-05?14:40??視網膜圖片拼接\FLANN?match\x64\Debug\FLANN?match.Build.CppClean.log
?????文件???????1076??2018-07-05?14:40??視網膜圖片拼接\FLANN?match\x64\Debug\FLANN?match.log
?????文件????????770??2018-07-05?14:40??視網膜圖片拼接\FLANN?match\x64\Debug\FLANN?match.tlog\CL.command.1.tlog
?????文件??????37710??2018-07-05?14:40??視網膜圖片拼接\FLANN?match\x64\Debug\FLANN?match.tlog\CL.read.1.tlog
?????文件????????796??2018-07-05?14:40??視網膜圖片拼接\FLANN?match\x64\Debug\FLANN?match.tlog\CL.write.1.tlog
?????文件????????247??2018-07-05?14:40??視網膜圖片拼接\FLANN?match\x64\Debug\FLANN?match.tlog\FLANN?match.lastbuildstate
?????文件???????3444??2018-07-05?14:40??視網膜圖片拼接\FLANN?match\x64\Debug\FLANN?match.tlog\li
?????文件???????9844??2018-07-05?14:40??視網膜圖片拼接\FLANN?match\x64\Debug\FLANN?match.tlog\li
?????文件????????782??2018-07-05?14:40??視網膜圖片拼接\FLANN?match\x64\Debug\FLANN?match.tlog\li
?????文件?????978077??2018-07-05?14:40??視網膜圖片拼接\FLANN?match\x64\Debug\main.obj
?????文件????1141760??2018-07-05?14:40??視網膜圖片拼接\FLANN?match\x64\Debug\vc140.idb
?????文件????2289664??2018-07-05?14:40??視網膜圖片拼接\FLANN?match\x64\Debug\vc140.pdb
?????文件???????4209??2018-07-05?14:38??視網膜圖片拼接\FLANN?match\x64\Release\FLANN?match.log
?????文件????????790??2018-07-05?14:38??視網膜圖片拼接\FLANN?match\x64\Release\FLANN?match.tlog\CL.command.1.tlog
?????文件??????37710??2018-07-05?14:38??視網膜圖片拼接\FLANN?match\x64\Release\FLANN?match.tlog\CL.read.1.tlog
?????文件????????600??2018-07-05?14:38??視網膜圖片拼接\FLANN?match\x64\Release\FLANN?match.tlog\CL.write.1.tlog
?????文件????????249??2018-07-05?14:38??視網膜圖片拼接\FLANN?match\x64\Release\FLANN?match.tlog\FLANN?match.lastbuildstate
?????文件??????????2??2018-07-05?14:38??視網膜圖片拼接\FLANN?match\x64\Release\FLANN?match.tlog\li
?????文件??????????2??2018-07-05?14:38??視網膜圖片拼接\FLANN?match\x64\Release\FLANN?match.tlog\li
?????文件??????????2??2018-07-05?14:38??視網膜圖片拼接\FLANN?match\x64\Release\FLANN?match.tlog\li
?????文件??????????0??2018-07-05?14:38??視網膜圖片拼接\FLANN?match\x64\Release\FLANN?match.tlog\unsuccessfulbuild
?????文件????3757216??2018-07-05?14:38??視網膜圖片拼接\FLANN?match\x64\Release\main.obj
?????文件????1953792??2018-07-05?14:38??視網膜圖片拼接\FLANN?match\x64\Release\vc140.pdb
?????文件???????1315??2018-04-08?09:24??視網膜圖片拼接\FLANN?match.sln
............此處省略21個文件信息
評論
共有 條評論