Skip to content
Snippets Groups Projects
Commit f0c1f686 authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

Add average computing times

parent 9a47e8d0
No related branches found
No related tags found
No related merge requests found
......@@ -153,6 +153,11 @@ int main(int argc, char** argv)
KeyPointVector keypoints_1 = det_ptr->detect(image_buffer.back());
cv::Mat descriptors_1 = des_ptr->getDescriptor( image_buffer.back(), keypoints_1);
clock_t tStart, tDet, tDesc, tMatch, tFilter, tFund;
double t_det(0), t_desc(0), t_match(0), t_filter(0), t_fund(0);
const int CLOCKS_PER_MSEC = (CLOCKS_PER_SEC/1000);
int n_iter = 0;
while(1)
{
capture >> img;
......@@ -167,15 +172,22 @@ int main(int argc, char** argv)
DMatchVector good_matches, inlier_matches;
PointVector inliers_1, inliers_2;
tStart = clock();
// detect and describe in new image
KeyPointVector keypoints_2 = det_ptr->detect(img);
tDet = clock();
if (keypoints_2.size()>0)
{
image_buffer.add(img);
cv::Mat descriptors_2 = des_ptr->getDescriptor( image_buffer.back(), keypoints_2);
tDesc = clock();
unsigned int max_dist = 0;
unsigned int min_dist = 512;
......@@ -185,6 +197,8 @@ int main(int argc, char** argv)
//-- Step 3: Matching descriptor vectors using FLANN matcher
mat_ptr->match(descriptors_1,descriptors_2,des_ptr->getSize(),matches);
tMatch = clock();
//-- Quick calculation of max and min distances between keypoints
for (int ii = 0; ii < descriptors_1.rows; ii++)
{
......@@ -215,13 +229,17 @@ int main(int argc, char** argv)
}
}
tFilter = clock();
// Compute the Fundamental matrix F and discard outliers through ransac in one go
if (good_matches.size() > 20) // Minimum is 8 points, but we need more for robustness
{
// find fundamental matrix using RANSAC, return set of inliers as bool vector
cv::Mat F = findFundamentalMat(matched_1, matched_2, cv::FM_RANSAC, 3.0, 0.98, inliers_bool);
cv::Mat F = findFundamentalMat(matched_1, matched_2, cv::FM_RANSAC, 2.0, 0.98, inliers_bool);
std::cout << "F = " << F << std::endl;
std::cout << "F = " << F << std::endl;
// Recover the inlier matches
for (unsigned int ii = 0; ii < good_matches.size(); ii++)
......@@ -229,11 +247,22 @@ int main(int argc, char** argv)
inlier_matches.push_back(good_matches[ii]);
}
std::cout << "Matches: initial " << matches.size() << " | good " << good_matches.size() << " | inliers "
tFund = clock();
std::cout << "Matches: initial " << matches.size() << " | good " << good_matches.size() << " | inliers "
<< inlier_matches.size() << std::endl;
std::cout << "kp1: " << keypoints_1.size() << " kp2: " << keypoints_2.size() << " inliers:" << inlier_matches.size() << std::endl;
n_iter ++;
t_det += double( tDet - tStart )/CLOCKS_PER_MSEC;
t_desc += double( tDesc - tDet )/CLOCKS_PER_MSEC;
t_match += double( tMatch - tDesc )/CLOCKS_PER_MSEC;
t_filter += double(tFilter - tMatch )/CLOCKS_PER_MSEC;
t_fund += double( tFund - tFilter)/CLOCKS_PER_MSEC;
std::cout << "det: " << t_det/n_iter << "ms - desc: " << t_desc/n_iter << "ms - match: " << t_match/n_iter << "ms - filter: " << t_filter/n_iter << "ms - fund: " << t_fund/n_iter << "ms" << std::endl;
std::cout << "+++++++++++++++" << std::endl;
// Draw RANSAC inliers
......
detector:
type: "AGAST"
threshold: 10
threshold: 8
nonmaxSuppression: true
detection type: 3 # AGAST_5_8=0, AGAST_7_12d=1, AGAST_7_12s=2, OAST_9_16=3, THRESHOLD=10000, NONMAX_SUPPRESSION=10001
detection type: 0 # AGAST_5_8=0, AGAST_7_12d=1, AGAST_7_12s=2, OAST_9_16=3, THRESHOLD=10000, NONMAX_SUPPRESSION=10001
descriptor:
type: "BRIEF"
bytes: 32
bytes: 16
use_orientation: false
matcher:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment