Issue 1:
environment：

OpenCV(4.3.0)

language：python 3.6

1.load the data from txt files,and then convert type from float to int32.

a.txt

4.020161 0.372046

4.086024 0.548271

4.112598 0.539363

4.162546 0.522878

4.252789 0.684608

4.265030 0.681673

4.572025 0.757398

4.752093 0.743017

4.958206 0.821787

5.138208 0.807434

5.298540 0.906368

5.542401 0.878399

5.798231 1.013368

6.018507 1.075400

6.113993 1.135273

6.425354 1.265514

6.545009 1.264395

6.731231 1.205198

6.901707 1.293404

7.236600 1.293581

7.264717 1.276446

7.542284 1.294016

7.849143 1.123871

7.888957 0.818015

b.txt

0.558444 0.486612

0.590397 0.479795

0.637800 0.728716

0.688097 0.927678

0.911380 1.735989

0.946417 1.752804

1.247624 2.280543

1.341965 2.214138

1.552272 2.264075

1.891904 2.235193

1.943452 2.234293

2.129528 2.216326

2.370298 2.131144

2.654617 2.204402

2.769804 2.168312

2.967309 2.118495

3.258043 2.180414

3.386168 2.172515

3.582158 2.205668

3.909915 2.182819

3.998347 2.194714

4.266880 2.160797

4.344415 2.154483

4.714916 2.141987

4.798001 2.135526

4.965595 1.871750

5.199670 1.789360

5.334784 1.386364

5.574860 1.413061

5.858532 1.056488

exmaple:

v0=(np.loadtxt("vehicleOutline/vehicleOutline0.txt",dtype=float,delimiter=' ') * 1000).astype(np.int32)

2.then reshape to (length,1,2),excute the function computeDistance

example:

sd=cv2.createShapeContextDistanceExtractor()

a0 = arr[i].reshape(arr[i].shape[0],1,2)

a1 = arr[j].reshape(arr[j].shape[0],1,2)

print(i,"match",j,"=",sd.computeDistance(a0,a1))

3.result:

some of txt files went success,but others went wrong.top the data went wrong,i dont know how to slove it.

Issue 2:
Transferred from http://code.opencv.org/issues/4490

|| Do Bi on 2015-07-21 13:15
|| Priority: Normal
|| Affected: branch 'master' (3.0-dev)
|| Category: None
|| Tracker: Bug
|| Difficulty:
|| PR:
|| Platform: x86 / Windows

createShapeContextDistanceExtractor()->computeDistance throws exception for certain shaped

Using these two images

1) http://i.imgur.com/WKaFDl4.png
2) http://i.imgur.com/5ayU6qb.png

I get the following error

@OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)size.p[0] && (unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1<< 3) - 1))*4) & 15) == elemSize1()) in cv::Mat::at, file C:\builds\master_PackSlave-win32-vc12-static\opencv\modules\core\include\opencv2/core/mat.inl.hpp, line 894@

when running this code:

@#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/shape/shape.hpp"
#include <math.h>
#include <iostream>

using namespace cv;
using namespace std;

vector<Point> GetContour(const Mat& img)
{
cv::threshold(img, img, 128, 255, cv::THRESH_BINARY);
vector<vector<Point>> conts;
cv::findContours(img, conts, cv::RETR_LIST, cv::CHAIN_APPROX_SIMPLE);
if (conts.empty())
return vector<Point>();
return conts.front();
}

int main()
{
auto shape1 = GetContour(cv::imread("D:/shape1.png", cv::IMREAD_GRAYSCALE));
auto shape2 = GetContour(cv::imread("D:/shape2.png", cv::IMREAD_GRAYSCALE));
cout << createShapeContextDistanceExtractor()->computeDistance(shape1, shape2) << endl;
}@

in VC2013.

With other shapes or with createHausdorffDistanceExtractor instead of createShapeContextDistanceExtractor it does not crash.

History