【发布时间】:2015-02-16 00:31:30
【问题描述】:
我是 OpenCV 的新手,所以这可能是一个愚蠢的问题。
我只是想让一些基本的东西启动并运行——我想直接在传入的图像上绘制 Canny 算法检测到的边缘。我目前有这个:
我直接显示来自 Canny 的边缘数据,但现在我想在正在处理的图像上去掉黑色,只显示白色。
我尝试过在谷歌上搜索“使用二进制图像作为 alpha 掩码”之类的内容,但是在阅读了一天的教程并尝试了我能找到的所有内容之后,我仍然不确定我是否知道发生了什么。 OpenCV 似乎非常强大,所以这可能是一件很容易做到的事情,所以我希望有人能指出我正确的方向。
这是我正在使用的代码,其中大部分是从示例中复制的:
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
Mat rgba = inputFrame.rgba();
org.opencv.core.Size sizeRgba = rgba.size();
Mat rgbaInnerWindow;
int rows = (int) sizeRgba.height;
int cols = (int) sizeRgba.width;
int left = cols / 8;
int top = rows / 8;
int width = cols * 3 / 4;
int height = rows * 3 / 4;
//get sub-image
rgbaInnerWindow = rgba.submat(top, top + height, left, left + width);
//create edgesMat from sub-image
Imgproc.Canny(rgbaInnerWindow, edgesMat, 100, 100);
//copy the edgesMat back into the sub-image
Imgproc.cvtColor(edgesMat, rgbaInnerWindow, Imgproc.COLOR_GRAY2BGRA, 4);
rgbaInnerWindow.release();
return rgba;
}
编辑:我还在 OpenCV 论坛 here 上发布了这个问题。
【问题讨论】: