1 | initial version |
I will try to add more information about the concepts behind the tutorial. This way, you will be able to tweak the code and adapt it to your needs. Probably the tutorial code needs some improvements.
The main concept is pose estimation. You can find some references in the OpenCV doc:
solvePnP()
But the main idea is to estimate the transformation between the object frame and the camera frame:
That is:
The PnP problem involves to solve for the rotation and the translation that minimize the back-projection error between the set of 3D points expressed in the object frame and the corresponding set of projected 2D image points, assuming a calibrated camera.
Since camera pose estimation needs a set of 3D object points, we need to find a way to compute these coordinates.
This is what is done in example_tutorial_pnp_registration
:
solvePnP()
) with the 2D/3D correspondences done manuallyIn example_tutorial_pnp_detection
, the first steps are roughly:
solvePnP()
The tutorial code does also the following things:
solvePnP()
, the pose can be predicted)I have observed some issues when the ORB features are detected on multiple levels with solvePnP()
. I don't know why but this can be workaround by using only one pyramid level:
Ptr<Feature2D> orb = ORB::create();
orb.dynamicCast<cv::ORB>()->setNLevels(1);
This should be done both in example_tutorial_pnp_registration
and in example_tutorial_pnp_detection
.
You can extract an image of the video and launch example_tutorial_pnp_registration
on this image to have a new cookies_ORB.yml
file.
If you launch example_tutorial_pnp_detection
with the newly cookies_ORB.yml
file, you should see that it works more or less, depending on the current object view. Indeed, probably when the current object view is too different than the one used during the training/learning step, the matching is not good.
You can find a cookies_ORB.yml
file here that should allow you to test the tutorial code. But you should do the example_tutorial_pnp_registration
step yourself since I dit it quickly and not very accurately.
Video of the results: https://youtu.be/ZuEbQ5my8Dg.
Some improvements that could be done:
example_tutorial_pnp_registration
2 | No.2 Revision |
I will try to add more information about the concepts behind the tutorial. This way, you will be able to tweak the code and adapt it to your needs. Probably the tutorial code needs some improvements.
The main concept is pose estimation. You can find some references in the OpenCV doc:
solvePnP()
But the main idea is to estimate the transformation between the object frame and the camera frame:
That is:
The PnP problem involves to solve for the rotation and the translation that minimize the back-projection error between the set of 3D points expressed in the object frame and the corresponding set of projected 2D image points, assuming a calibrated camera.
Since camera pose estimation needs a set of 3D object points, we need to find a way to compute these coordinates.
This is what is done in example_tutorial_pnp_registration
:
solvePnP()
) with the 2D/3D correspondences done manuallyIn example_tutorial_pnp_detection
, the first steps are roughly:
solvePnP()
The tutorial code does also the following things:
solvePnP()
, the pose can be predicted)I have observed some issues when the ORB features are detected on multiple levels with solvePnP()
. I don't know why but this can be workaround by using only one pyramid level:
Ptr<Feature2D> orb = ORB::create();
orb.dynamicCast<cv::ORB>()->setNLevels(1);
This should be done both in example_tutorial_pnp_registration
and in example_tutorial_pnp_detection
.
You can extract an image of the video and launch example_tutorial_pnp_registration
on this image to have a new cookies_ORB.yml
file.
If you launch example_tutorial_pnp_detection
with the newly cookies_ORB.yml
file, you should see that it works more or less, depending on the current object view. Indeed, probably when the current object view is too different than the one used during the training/learning step, the matching is not good.
You can find a cookies_ORB.yml
file here that should allow you to test the tutorial code. But you should do the example_tutorial_pnp_registration
step yourself since I dit it quickly and not very accurately.
Video of the results: results: https://youtu.be/ZuEbQ5my8Dg.
Some improvements that could be done:
example_tutorial_pnp_registration