1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
Description: gcc-6 build fixes, cherry-picked from Fedora
From: https://pkgs.fedoraproject.org/cgit/rpms/opencv.git/commit/?id=ca7da00ea608b62859a640493a1cd6c0f5802550
Author: Sérgio M. Basto <sergio@serjux.com>
Last-Update: 2016-10-04
--- opencv-2.4.9.1+dfsg.orig/modules/contrib/src/chamfermatching.cpp
+++ opencv-2.4.9.1+dfsg/modules/contrib/src/chamfermatching.cpp
@@ -966,10 +966,8 @@ void ChamferMatcher::Matching::computeDi
for (int y=0;y<h;++y) {
for (int x=0;x<w;++x) {
// initialize
- if (&annotate_img!=NULL) {
- annotate_img.at<Vec2i>(y,x)[0]=x;
- annotate_img.at<Vec2i>(y,x)[1]=y;
- }
+ annotate_img.at<Vec2i>(y,x)[0]=x;
+ annotate_img.at<Vec2i>(y,x)[1]=y;
uchar edge_val = edges_img.at<uchar>(y,x);
if( (edge_val!=0) ) {
@@ -1013,10 +1011,8 @@ void ChamferMatcher::Matching::computeDi
dist_img.at<float>(ny,nx) = dist;
q.push(std::make_pair(nx,ny));
- if (&annotate_img!=NULL) {
- annotate_img.at<Vec2i>(ny,nx)[0]=annotate_img.at<Vec2i>(y,x)[0];
- annotate_img.at<Vec2i>(ny,nx)[1]=annotate_img.at<Vec2i>(y,x)[1];
- }
+ annotate_img.at<Vec2i>(ny,nx)[0]=annotate_img.at<Vec2i>(y,x)[0];
+ annotate_img.at<Vec2i>(ny,nx)[1]=annotate_img.at<Vec2i>(y,x)[1];
}
}
}
@@ -1107,26 +1103,22 @@ ChamferMatcher::Match* ChamferMatcher::M
float cost = (sum_distance/truncate_)/addr.size();
+ float* optr = orientation_img.ptr<float>(y)+x;
+ float sum_orientation = 0;
+ int cnt_orientation = 0;
- if (&orientation_img!=NULL) {
- float* optr = orientation_img.ptr<float>(y)+x;
- float sum_orientation = 0;
- int cnt_orientation = 0;
-
- for (size_t i=0;i<addr.size();++i) {
+ for (size_t i=0;i<addr.size();++i) {
- if(addr[i] < (orientation_img.cols*orientation_img.rows) - (offset.y*orientation_img.cols + offset.x)){
- if (tpl->orientations[i]>=-CV_PI && (*(optr+addr[i]))>=-CV_PI) {
- sum_orientation += orientation_diff(tpl->orientations[i], (*(optr+addr[i])));
- cnt_orientation++;
- }
+ if(addr[i] < (orientation_img.cols*orientation_img.rows) - (offset.y*orientation_img.cols + offset.x)){
+ if (tpl->orientations[i]>=-CV_PI && (*(optr+addr[i]))>=-CV_PI) {
+ sum_orientation += orientation_diff(tpl->orientations[i], (*(optr+addr[i])));
+ cnt_orientation++;
}
}
+ }
- if (cnt_orientation>0) {
- cost = (float)(beta*cost+alpha*(sum_orientation/(2*CV_PI))/cnt_orientation);
- }
-
+ if (cnt_orientation>0) {
+ cost = (float)(beta*cost+alpha*(sum_orientation/(2*CV_PI))/cnt_orientation);
}
if(cost > 0){
|