From e778007d5da95962d6626b402d9bc3618bd37fec Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Mon, 26 Mar 2012 08:18:10 +0000 Subject: [PATCH] applied patch from #1655 (thanks to Changbo Zhou!) --- modules/contrib/src/chamfermatching.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/modules/contrib/src/chamfermatching.cpp b/modules/contrib/src/chamfermatching.cpp index fa2c599758..37c1d10733 100644 --- a/modules/contrib/src/chamfermatching.cpp +++ b/modules/contrib/src/chamfermatching.cpp @@ -952,20 +952,18 @@ void ChamferMatcher::Matching::computeDistanceTransform(Mat& edges_img, Mat& dis // set distance to the edge pixels to 0 and put them in the queue std::queue > q; - - for (int y=0;y(y,x); - if ( (edge_val!=0) ) { + // initialize + if (&annotate_img!=NULL) { + annotate_img.at(y,x)[0]=x; + annotate_img.at(y,x)[1]=y; + } + + uchar edge_val = edges_img.at(y,x); + if( (edge_val!=0) ) { q.push(std::make_pair(x,y)); dist_img.at(y,x)= 0; - - if (&annotate_img!=NULL) { - annotate_img.at(y,x)[0]=x; - annotate_img.at(y,x)[1]=y; - } } else { dist_img.at(y,x)=-1;