Repository navigation
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.
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.
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.
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.
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.
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.
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
alalek
left a comment
There was a problem hiding this comment.
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.
Could you try to use samples::findFile() from here: #12354 ?
Perhaps "../../samples" prefix should be dropped.
There was a problem hiding this comment.
This works with the updated changes (on Ubuntu).
…atures type. Add keypoints matching visualization. Auto format code.
5569465 to
3c92d40
Compare
…eypoints_matching
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: