gpt4 book ai didi

android - OpenCV错误:templmatch.cpp中的断言失败CvException

转载 作者:行者123 更新时间:2023-12-02 17:14:22 27 4
gpt4 key购买 nike

有人可以向我解释logcat中的此错误是什么意思?

 06-19 11:52:56.198: ERROR/cv::error()(8272): OpenCV Error: Assertion failed (corrsize.height <= img.rows + templ.rows - 1 && corrsize.width <= img.cols + templ.cols - 1) in void cv::crossCorr(const cv::Mat&, const cv::Mat&, cv::Mat&, cv::Size, int, cv::Point, double, int), file /home/reports/ci/slave/50-SDK/opencv/modules/imgproc/src/templmatch.cpp, line 70
06-19 11:52:56.208: ERROR/AndroidRuntime(8272): FATAL EXCEPTION: Thread-2151
CvException [org.opencv.core.CvException: /home/reports/ci/slave/50-SDK/opencv/modules/imgproc/src/templmatch.cpp:70: error: (-215) corrsize.height <= img.rows + templ.rows - 1 && corrsize.width <= img.cols + templ.cols - 1 in function void cv::crossCorr(const cv::Mat&, const cv::Mat&, cv::Mat&, cv::Size, int, cv::Point, double, int)
]
at org.opencv.imgproc.Imgproc.matchTemplate_0(Native Method)
at org.opencv.imgproc.Imgproc.matchTemplate(Imgproc.java:7226)
at com.micaela.myapp.Eye.match(Eye.java:256)
at com.micaela.myapp.Eye.access$100(Eye.java:22)
at com.micaela.myapp.Eye$3.run(Eye.java:146)
at java.lang.Thread.run(Thread.java:856)

在这段代码中调用此异常:
 Mat res;
if ((roi.height() > MainActivity.tpl.height()) && (roi.width() > MainActivity.tpl.width())) {
res = new Mat(new Size(roi.cols() - MainActivity.tpl.cols() + 1, roi.rows() - MainActivity.tpl.rows() + 1), CvType.CV_32FC1);
Imgproc.matchTemplate(roi, MainActivity.tpl, res, Imgproc.TM_SQDIFF);
if (left) {
return new Point((eyeRect.x + this.roi.width() - matchRect.x - Math.round(Core.minMaxLoc(res).maxLoc.x + (MainActivity.tpl.width() / 2))),
(Math.round(Core.minMaxLoc(res).maxLoc.y + (MainActivity.tpl.height() / 2)) + matchRect.y + eyeRect.y));
} else {
return new Point((Math.round(Core.minMaxLoc(res).maxLoc.x + (MainActivity.tpl.width() / 2)) + matchRect.x + eyeRect.x), (Math.round(Core.minMaxLoc(res).maxLoc.y + (MainActivity.tpl.height() / 2)) + matchRect.y + eyeRect.y));
}
}

在:
Imgproc.matchTemplate(roi, MainActivity.tpl, res, Imgproc.TM_SQDIFF);

我正在使用最新版本的opencv4android库在Android中编程。

最佳答案

您的模板大小似乎小于1x1像素。 OpenCV无法处理空模板。

关于android - OpenCV错误:templmatch.cpp中的断言失败CvException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17188419/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com