Y.S*_*Y.S 7 android opencv android-bitmap gaussianblur
我正在开发一个 Android 应用程序,它使用背景Service以编程方式捕获当前屏幕上任何内容的屏幕截图。我将屏幕截图作为Bitmap.
接下来,我成功地将OpenCV导入到我的 Android 项目中。
我现在需要做的是模糊该图像的一个子集,即不是整个图像本身,而是图像内的 [矩形] 区域或子区域。我有一组Rect对象,代表我需要在屏幕截图中模糊的矩形区域。
我一直在寻找有关在 Java 中使用 OpenCV 执行此操作的教程,但我还没有找到明确的答案。在Mat和Imgproc类是明显的利益的,而还有的Mat.submat()方法,但我一直无法找到能完成这一操作清晰,简单的教程。
我在谷歌上搜索了很多,我发现的例子都不是完整的。我需要在 Java 中在 Android 运行时中执行此操作。
我需要的是:
Bitmap>>>Mat>>>Imgproc>>>Rect>>>BitmapROI 模糊。
这里有任何经验丰富的 OpenCV 开发人员,你能指出我正确的方向吗?这是我唯一坚持的事情。
相关:
kar*_*lip 13
下面分享了用于完成此任务的 C++ 代码,并附有注释和示例图像:
// load an input image
Mat img = imread("C:\\elon_tusk.png");
Run Code Online (Sandbox Code Playgroud)
图片:
// extract subimage
Rect roi(113, 87, 100, 50);
Mat subimg = img(roi);
Run Code Online (Sandbox Code Playgroud)
子图像:
// blur the subimage
Mat blurred_subimage;
GaussianBlur(subimg, blurred_subimage, Size(0, 0), 5, 5);
Run Code Online (Sandbox Code Playgroud)
模糊子图像:
// copy the blurred subimage back to the original image
blurred_subimage.copyTo(img(roi));
Run Code Online (Sandbox Code Playgroud)
图片:
安卓等效:
Mat img = Imgcodecs.imread("elon_tusk.png");
Rect roi = new Rect(113, 87, 100, 50);
Mat subimage = img.submat(roi).clone();
Imgproc.GaussianBlur(subimg, subimg, new Size(0,0), 5, 5);
subimg.copyTo(img.submat(roi));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
495 次 |
| 最近记录: |