本文整理匯總了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);
}