Browse Source

Merge pull request #3735 from paroj:ovisup

ovis: force camera extent update to get correct bbox #3735

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake

---
fixes #3732
pull/3737/head
Pavel Rojtberg 1 year ago committed by GitHub
parent
commit
6b1faf0d9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      modules/ovis/CMakeLists.txt
  2. 14
      modules/ovis/samples/aruco_ar_demo.cpp
  3. 2
      modules/ovis/samples/aruco_ar_demo.py
  4. 1
      modules/ovis/src/ovis.cpp

2
modules/ovis/CMakeLists.txt

@ -24,7 +24,7 @@ ocv_glob_module_sources() @@ -24,7 +24,7 @@ ocv_glob_module_sources()
ocv_module_include_directories()
ocv_create_module()
ocv_add_samples(opencv_aruco)
ocv_add_samples(opencv_objdetect opencv_aruco)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-parameter)
ocv_target_link_libraries(${the_module} ${OGRE_LIBRARIES})

14
modules/ovis/samples/aruco_ar_demo.cpp

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
#include <opencv2/videoio.hpp>
#include <opencv2/ovis.hpp>
#include <opencv2/aruco_detector.hpp>
#include <opencv2/aruco.hpp>
#include <iostream>
@ -24,10 +24,12 @@ int main() @@ -24,10 +24,12 @@ int main()
const double focal_length = 800.0;
// aruco
Ptr<aruco::Dictionary> adict = aruco::getPredefinedDictionary(aruco::DICT_4X4_50);
//Mat out_img;
//aruco::drawMarker(adict, 0, 400, out_img);
//imshow("marker", out_img);
aruco::Dictionary adict = aruco::getPredefinedDictionary(aruco::DICT_4X4_50);
aruco::ArucoDetector detector(adict);
Mat out_img;
adict.generateImageMarker(0, 400, out_img);
imshow("marker", out_img);
// random calibration data, your mileage may vary
Mat1d cm = Mat1d::zeros(3, 3); // init empty matrix
@ -53,7 +55,7 @@ int main() @@ -53,7 +55,7 @@ int main()
while (ovis::waitKey(1) != KEY_ESCAPE) {
cap.read(img);
win->setBackground(img);
aruco::detectMarkers(img, adict, corners, ids);
detector.detectMarkers(img, corners, ids);
waitKey(1);

2
modules/ovis/samples/aruco_ar_demo.py

@ -3,7 +3,7 @@ import cv2 as cv @@ -3,7 +3,7 @@ import cv2 as cv
# aruco
adict = cv.aruco.getPredefinedDictionary(cv.aruco.DICT_4X4_50)
cv.imshow("marker", cv.aruco.drawMarker(adict, 0, 400))
cv.imshow("marker", adict.generateImageMarker(0, 400))
# random calibration data. your mileage may vary.
imsize = (800, 600)

1
modules/ovis/src/ovis.cpp

@ -588,6 +588,7 @@ public: @@ -588,6 +588,7 @@ public:
cam->setDebugDisplayEnabled(true);
cam->setNearClipDistance(1e-9);
cam->setFarClipDistance(zFar);
cam->getFrustumExtents(); // force update
_setCameraIntrinsics(cam, K, imsize);

Loading…
Cancel
Save