gpt4 book ai didi

java - Android OpenCV HoughLinesP 崩溃

转载 作者:行者123 更新时间:2023-12-01 10:21:57 24 4
gpt4 key购买 nike

我正在尝试制作一个简单的应用程序来使用 OpenCV 检测线路

我的代码基于 opencv 示例代码

我只编辑了OnCameraFrame部分

这是我所拥有的:

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
Mat mRgba;
mRgba = inputFrame.rgba();

int thresh;
double min;
double max;

Mat lines = new Mat();
thresh = 50;
min = 20;
max = 20;
Imgproc.HoughLinesP(mRgba, lines, 1, Math.PI/180, thresh, min, max);
return mRgba;
}

应用程序崩溃了,但是

如果我删除这一行,它就可以正常运行:

Imgproc.HoughLinesP(mRgba, lines, 1, Math.PI/180, thresh, min, max);

这是我启动应用程序时得到的结果:

http://pastebin.com/swGn7ZVJ

最佳答案

此 Imgproc 函数中的第一个参数应该是(来自文档):

 8-bit, single-channel binary source image.

您的 mRgba 是 4 channel 图像(红、绿、蓝和 Alpha)。将其转换为灰色(例如 inputFrame.gray() )。

关于java - Android OpenCV HoughLinesP 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35538070/

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