本文整理汇总了Java中org.opencv.imgproc.Imgproc.TM_SQDIFF属性的典型用法代码示例。如果您正苦于以下问题:Java Imgproc.TM_SQDIFF属性的具体用法?Java Imgproc.TM_SQDIFF怎么用?Java Imgproc.TM_SQDIFF使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.opencv.imgproc.Imgproc
的用法示例。
在下文中一共展示了Imgproc.TM_SQDIFF属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: match
public MatchResult match(Mat scene, Mat templ, Method method, Mat img) {
int result_cols = scene.cols() - templ.cols() + 1;
int result_rows = scene.rows() - templ.rows() + 1;
Mat result = new Mat(result_rows, result_cols, CV_32FC1);
Imgproc.matchTemplate(scene, templ, result, method.ordinal());
//Core.normalize(result, result, 0, 1, 32,-1,new Mat());
MinMaxLocResult mmr = Core.minMaxLoc(result);
Point matchLoc;
double maxVal;
if (method.ordinal() == Imgproc.TM_SQDIFF
|| method.ordinal() == Imgproc.TM_SQDIFF_NORMED) {
matchLoc = mmr.minLoc;
maxVal = mmr.minVal;
}
else {
matchLoc = mmr.maxLoc;
maxVal = mmr.maxVal;
}
MatchResult currResult = new MatchResult(matchLoc.x +(templ.cols()/2),matchLoc.y +(templ.rows()/2),0,maxVal);
return currResult;
}
示例2: getBestMatched
public static Pair<Point, Double> getBestMatched(Mat tmResult, int matchMethod, float threshold) {
TimingLogger logger = new TimingLogger(LOG_TAG, "best_matched_point");
// FIXME: 2017/11/26 正交化?
// Core.normalize(tmResult, tmResult, 0, 1, Core.NORM_MINMAX, -1, new Mat());
Core.MinMaxLocResult mmr = Core.minMaxLoc(tmResult);
logger.addSplit("minMaxLoc");
double value;
Point pos;
if (matchMethod == Imgproc.TM_SQDIFF || matchMethod == Imgproc.TM_SQDIFF_NORMED) {
pos = mmr.minLoc;
value = -mmr.minVal;
} else {
pos = mmr.maxLoc;
value = mmr.maxVal;
}
logger.addSplit("value:" + value);
logger.dumpToLog();
return new Pair<>(pos, value);
}