diff --git a/modules/python/test/test_shape.py b/modules/python/test/test_shape.py deleted file mode 100644 index 1c9f07b7d4..0000000000 --- a/modules/python/test/test_shape.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -import cv2 as cv - -from tests_common import NewOpenCVTests - -class shape_test(NewOpenCVTests): - - def test_computeDistance(self): - - a = self.get_sample('samples/data/shape_sample/1.png', cv.IMREAD_GRAYSCALE) - b = self.get_sample('samples/data/shape_sample/2.png', cv.IMREAD_GRAYSCALE) - - 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/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index c3786aaf74..131681e61c 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -15,7 +15,6 @@ set(OPENCV_CPP_SAMPLES_REQUIRED_DEPS opencv_calib3d opencv_stitching opencv_videostab - opencv_shape ${OPENCV_MODULES_PUBLIC} ${OpenCV_LIB_COMPONENTS}) ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS}) diff --git a/samples/cpp/shape_example.cpp b/samples/cpp/shape_example.cpp deleted file mode 100644 index 6269a942ef..0000000000 --- a/samples/cpp/shape_example.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * shape_context.cpp -- Shape context demo for shape matching - */ - -#include "opencv2/shape.hpp" -#include "opencv2/imgcodecs.hpp" -#include "opencv2/highgui.hpp" -#include "opencv2/imgproc.hpp" -#include -#include -#include - -using namespace std; -using namespace cv; - -static void help() -{ - printf("\n" - "This program demonstrates a method for shape comparison based on Shape Context\n" - "You should run the program providing a number between 1 and 20 for selecting an image in the folder ../data/shape_sample.\n" - "Call\n" - "./shape_example [number between 1 and 20, 1 default]\n\n"); -} - -static vector simpleContour( const Mat& currentQuery, int n=300 ) -{ - vector > _contoursQuery; - vector contoursQuery; - findContours(currentQuery, _contoursQuery, RETR_LIST, CHAIN_APPROX_NONE); - for (size_t border=0; border<_contoursQuery.size(); border++) - { - for (size_t p=0; p<_contoursQuery[border].size(); p++) - { - contoursQuery.push_back( _contoursQuery[border][p] ); - } - } - - // In case actual number of points is less than n - int dummy=0; - for (int add=(int)contoursQuery.size()-1; add cont; - for (int i=0; i("@input"); - if (!parser.check()) - { - parser.printErrors(); - help(); - return 1; - } - if (indexQuery < 1 || indexQuery > 20) - { - help(); - return 1; - } - cv::Ptr mysc = cv::createShapeContextDistanceExtractor(); - - Size sz2Sh(300,300); - stringstream queryName; - queryName< contQuery = simpleContour(query); - int bestMatch = 0; - float bestDis=FLT_MAX; - for ( int ii=1; ii<=20; ii++ ) - { - if (ii==indexQuery) continue; - waitKey(30); - stringstream iiname; - iiname< contii = simpleContour(iiIm); - float dis = mysc->computeDistance( contQuery, contii ); - if ( dis