mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-16 22:35:51 +08:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -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);
|
||||
|
@@ -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> &dictionary, int id, int sidePixels, OutputArray _img, int borderBits) {
|
||||
|
37
modules/shape/misc/python/test/test_shape.py
Normal file
37
modules/shape/misc/python/test/test_shape.py
Normal file
@@ -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()
|
@@ -48,6 +48,14 @@
|
||||
#include <fstream>
|
||||
#include <queue>
|
||||
|
||||
#ifdef HAVE_TESSERACT
|
||||
#if !defined(USE_STD_NAMESPACE)
|
||||
#define USE_STD_NAMESPACE
|
||||
#endif
|
||||
#include <tesseract/baseapi.h>
|
||||
#include <tesseract/resultiterator.h>
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace text
|
||||
|
@@ -47,12 +47,4 @@
|
||||
|
||||
#include "text_config.hpp"
|
||||
|
||||
#ifdef HAVE_TESSERACT
|
||||
#if !defined(USE_STD_NAMESPACE)
|
||||
#define USE_STD_NAMESPACE
|
||||
#endif
|
||||
#include <tesseract/baseapi.h>
|
||||
#include <tesseract/resultiterator.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user