Fits small cameras
This commit is contained in:
1 parent
a773166c91
commit
98ed2576c6
7 files changed
+526
-96
No files matched your search
+21
-4
@@ -16,12 +16,23 @@ int main(int argc, char** argv) {
|
||||
cv::resize(a, a, {}, scale, scale, cv::INTER_AREA);
|
||||
cv::resize(b, b, {}, scale, scale, cv::INTER_AREA);
|
||||
}
|
||||
cv::Mat af, bf, window;
|
||||
a.convertTo(af, CV_32F);
|
||||
b.convertTo(bf, CV_32F);
|
||||
cv::createHanningWindow(window, a.size(), CV_32F);
|
||||
double phase_response = 0.0;
|
||||
const cv::Point2d phase = cv::phaseCorrelate(af, bf, window, &phase_response);
|
||||
const double phase_dx = phase.x / a.cols;
|
||||
const double phase_dy = phase.y / a.rows;
|
||||
|
||||
auto orb = cv::ORB::create(2500, 1.2f, 8, 31, 0, 2, cv::ORB::HARRIS_SCORE, 31, 8);
|
||||
std::vector<cv::KeyPoint> ka, kb; cv::Mat da, db;
|
||||
orb->detectAndCompute(a, {}, ka, da);
|
||||
orb->detectAndCompute(b, {}, kb, db);
|
||||
if (da.empty() || db.empty()) {
|
||||
std::cout << "{\"valid\":false,\"reason\":\"not_enough_features\",\"overlap\":0}\n";
|
||||
std::cout << "{\"valid\":false,\"reason\":\"not_enough_features\",\"overlap\":0"
|
||||
<< ",\"phase_dx\":" << phase_dx << ",\"phase_dy\":" << phase_dy
|
||||
<< ",\"phase_response\":" << phase_response << "}\n";
|
||||
return 0;
|
||||
}
|
||||
std::vector<std::vector<cv::DMatch>> knn;
|
||||
@@ -31,7 +42,9 @@ int main(int argc, char** argv) {
|
||||
if (pair.size() == 2 && pair[0].distance < 0.75f * pair[1].distance) good.push_back(pair[0]);
|
||||
if (good.size() < 8) {
|
||||
std::cout << "{\"valid\":false,\"reason\":\"not_enough_matches\",\"good_matches\":"
|
||||
<< good.size() << ",\"overlap\":0}\n";
|
||||
<< good.size() << ",\"overlap\":0"
|
||||
<< ",\"phase_dx\":" << phase_dx << ",\"phase_dy\":" << phase_dy
|
||||
<< ",\"phase_response\":" << phase_response << "}\n";
|
||||
return 0;
|
||||
}
|
||||
std::vector<cv::Point2f> pa, pb;
|
||||
@@ -43,7 +56,9 @@ int main(int argc, char** argv) {
|
||||
if (h.empty() || inliers < 50 || inlier_ratio < 0.45) {
|
||||
std::cout << "{\"valid\":false,\"reason\":\"homography_failed\",\"good_matches\":"
|
||||
<< good.size() << ",\"inliers\":" << inliers
|
||||
<< ",\"inlier_ratio\":" << inlier_ratio << ",\"overlap\":0}\n";
|
||||
<< ",\"inlier_ratio\":" << inlier_ratio << ",\"overlap\":0"
|
||||
<< ",\"phase_dx\":" << phase_dx << ",\"phase_dy\":" << phase_dy
|
||||
<< ",\"phase_response\":" << phase_response << "}\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -63,6 +78,8 @@ int main(int argc, char** argv) {
|
||||
<< ",\"good_matches\":" << good.size()
|
||||
<< ",\"inliers\":" << inliers
|
||||
<< ",\"inlier_ratio\":" << inlier_ratio
|
||||
<< ",\"center_dx\":" << dx << ",\"center_dy\":" << dy << "}\n";
|
||||
<< ",\"center_dx\":" << dx << ",\"center_dy\":" << dy
|
||||
<< ",\"phase_dx\":" << phase_dx << ",\"phase_dy\":" << phase_dy
|
||||
<< ",\"phase_response\":" << phase_response << "}\n";
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user