diff --git a/modules/aruco/include/opencv2/aruco.hpp b/modules/aruco/include/opencv2/aruco.hpp index ba802a6fb..45a3f6c24 100644 --- a/modules/aruco/include/opencv2/aruco.hpp +++ b/modules/aruco/include/opencv2/aruco.hpp @@ -471,6 +471,8 @@ CV_EXPORTS_W void drawDetectedMarkers(InputOutputArray image, InputArrayOfArrays * * Given the pose estimation of a marker or board, this function draws the axis of the world * coordinate system, i.e. the system centered on the marker/board. Useful for debugging purposes. + * + * @deprecated use cv::drawFrameAxes */ CV_EXPORTS_W void drawAxis(InputOutputArray image, InputArray cameraMatrix, InputArray distCoeffs, InputArray rvec, InputArray tvec, float length); diff --git a/modules/aruco/src/aruco.cpp b/modules/aruco/src/aruco.cpp index 76cd9edb3..8022076cf 100644 --- a/modules/aruco/src/aruco.cpp +++ b/modules/aruco/src/aruco.cpp @@ -1731,30 +1731,12 @@ void drawDetectedMarkers(InputOutputArray _image, InputArrayOfArrays _corners, /** */ -void drawAxis(InputOutputArray _image, InputArray _cameraMatrix, InputArray _distCoeffs, - InputArray _rvec, InputArray _tvec, float length) { - - CV_Assert(_image.getMat().total() != 0 && - (_image.getMat().channels() == 1 || _image.getMat().channels() == 3)); - CV_Assert(length > 0); - - // project axis points - vector< Point3f > axisPoints; - axisPoints.push_back(Point3f(0, 0, 0)); - axisPoints.push_back(Point3f(length, 0, 0)); - axisPoints.push_back(Point3f(0, length, 0)); - axisPoints.push_back(Point3f(0, 0, length)); - vector< Point2f > imagePoints; - projectPoints(axisPoints, _rvec, _tvec, _cameraMatrix, _distCoeffs, imagePoints); - - // draw axis lines - line(_image, imagePoints[0], imagePoints[1], Scalar(0, 0, 255), 3); - line(_image, imagePoints[0], imagePoints[2], Scalar(0, 255, 0), 3); - line(_image, imagePoints[0], imagePoints[3], Scalar(255, 0, 0), 3); +void drawAxis(InputOutputArray _image, InputArray _cameraMatrix, InputArray _distCoeffs, InputArray _rvec, + InputArray _tvec, float length) +{ + drawFrameAxes(_image, _cameraMatrix, _distCoeffs, _rvec, _tvec, length, 3); } - - /** */ void drawMarker(const Ptr &dictionary, int id, int sidePixels, OutputArray _img, int borderBits) { diff --git a/modules/shape/misc/python/test/test_shape.py b/modules/shape/misc/python/test/test_shape.py new file mode 100644 index 000000000..f7a564f08 --- /dev/null +++ b/modules/shape/misc/python/test/test_shape.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +# Python 2/3 compatibility +from __future__ import print_function + +import os + +import cv2 as cv + +from tests_common import NewOpenCVTests + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +MODULE_DIR = os.path.join(SCRIPT_DIR, '../../../') + +class shape_test(NewOpenCVTests): + + def test_computeDistance(self): + + a = cv.imread(os.path.join(MODULE_DIR, 'samples/data/shape_sample/1.png'), cv.IMREAD_GRAYSCALE) + b = cv.imread(os.path.join(MODULE_DIR, 'samples/data/shape_sample/2.png'), cv.IMREAD_GRAYSCALE) + if a is None or b is None: + raise unittest.SkipTest("Missing files with test data") + + ca, _ = cv.findContours(a, cv.RETR_CCOMP, cv.CHAIN_APPROX_TC89_KCOS) + cb, _ = cv.findContours(b, cv.RETR_CCOMP, cv.CHAIN_APPROX_TC89_KCOS) + + hd = cv.createHausdorffDistanceExtractor() + sd = cv.createShapeContextDistanceExtractor() + + d1 = hd.computeDistance(ca[0], cb[0]) + d2 = sd.computeDistance(ca[0], cb[0]) + + self.assertAlmostEqual(d1, 26.4196891785, 3, "HausdorffDistanceExtractor") + self.assertAlmostEqual(d2, 0.25804194808, 3, "ShapeContextDistanceExtractor") + +if __name__ == '__main__': + NewOpenCVTests.bootstrap() diff --git a/modules/text/src/ocr_tesseract.cpp b/modules/text/src/ocr_tesseract.cpp index 07aad1ff7..d04c698e1 100644 --- a/modules/text/src/ocr_tesseract.cpp +++ b/modules/text/src/ocr_tesseract.cpp @@ -48,6 +48,14 @@ #include #include +#ifdef HAVE_TESSERACT +#if !defined(USE_STD_NAMESPACE) +#define USE_STD_NAMESPACE +#endif +#include +#include +#endif + namespace cv { namespace text diff --git a/modules/text/src/precomp.hpp b/modules/text/src/precomp.hpp index 7ccda150f..17a6427b1 100644 --- a/modules/text/src/precomp.hpp +++ b/modules/text/src/precomp.hpp @@ -47,12 +47,4 @@ #include "text_config.hpp" -#ifdef HAVE_TESSERACT -#if !defined(USE_STD_NAMESPACE) -#define USE_STD_NAMESPACE -#endif -#include -#include -#endif - #endif