CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
Add keypoints matching visualization for real-time pose estimation tutorial #13835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add keypoints matching visualization for real-time pose estimation tutorial #13835
Conversation
cv::FileStorage storage(path, cv::FileStorage::WRITE); | ||
storage << "points_3d" << points3dmatrix; | ||
storage << "points_2d" << points2dmatrix; | ||
storage << "keypoints" << list_keypoints_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modification to save keypoints and path to the training image. This way, during the detection it is possible to display the keypoints matching.
023db96
to
57d590c
Compare
cv::FileStorage storage(path, cv::FileStorage::READ); | ||
storage["points_3d"] >> points3d_mat; | ||
storage["descriptors"] >> descriptors_; | ||
if (!storage["keypoints"].empty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read keypoints and path to training image if node is not empty.
}; | ||
|
||
// Functions for Möller-Trumbore intersection algorithm | ||
cv::Point3f CROSS(cv::Point3f v1, cv::Point3f v2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functions declaration not needed here.
cv::Point2i pointZ = list_points2d[3]; | ||
|
||
drawArrow(image, origin, pointX, red, 9, 2); | ||
drawArrow(image, origin, pointY, blue, 9, 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix Y axis drawn in blue (should be green).
return ss.str(); | ||
} | ||
|
||
void createFeatures(const std::string &featureName, int numKeypoints, cv::Ptr<cv::Feature2D> &detector, cv::Ptr<cv::Feature2D> &descriptor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add possibility to use different types of features.
"{keypoints k |2000 | number of keypoints to detect }" | ||
"{ratio r |0.7 | threshold for ratio test }" | ||
"{iterations it |500 | RANSAC maximum iterations count }" | ||
"{error e |6.0 | RANSAC reprojection error }" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Increase RANSAC reprojection (2 pixel error seems too harsh, some valid points could be treated as outliers, especially with the incertitude errors about the intrinsic camera parameters and the camera distortion) threshold and RANSAC confidence.
I have put some comments to highlight the relevant changes since lots of the changes are whitespace related. |
a4abf48
to
5569465
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done! Thank you for the contribution 👍
|
||
string img_path = tutorial_path + "Data/resized_IMG_3875.JPG"; // image to register | ||
string ply_read_path = tutorial_path + "Data/box.ply"; // object mesh | ||
string write_path = tutorial_path + "Data/cookies_ORB.yml"; // output file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you try to use samples::findFile()
from here: #12354 ?
Perhaps "../../samples" prefix should be dropped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works with the updated changes (on Ubuntu).
…atures type. Add keypoints matching visualization. Auto format code.
5569465
to
3c92d40
Compare
opencv/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/main_detection.cpp
Lines 105 to 112 in 54a1bbe
It is not possible to get the same detection results with the provided image and video than in the tutorial video.
Beware of the Kalman filter formulation used (constant acceleration on Euler angles). Here what looks like a better formulation.
Some video results (unfortunately, YouTube applied too much compression):
Training pose: