简体   繁体   English

如何使用opencv4android分割图像

[英]How can i segment an image using opencv4android

I am developing an application on the android platform. 我正在android平台上开发一个应用程序。 The app basically needs to capture an image using the camera, and then analyse the captured image to see where does red and blue color ends and the next step is to make a contour arround twi shape cirle and triangle.(already done ) Now i Have to move to the next step : segmentation Can you help me how to segment this images. 该应用程序基本上需要使用相机捕获图像,然后分析捕获的图像,看看红色和蓝色的颜色在哪里结束,下一步是制作一个轮廓为twi形状的圆形和三角形。(已经完成)现在我有了转到下一步:分段你能帮我分析这些图像吗? Any ideas? 有任何想法吗?

Assuming c is your contour: 假设c是你的轮廓:

Rect roi = Imgproc.boundingRect(c);
Mat newMat = mRgba.submat(roi);
Bitmap bmp1 = Bitmap.createBitmap(newMat.width(), newMat.height(),
            Bitmap.Config.ARGB_8888);
Utils.matToBitmap(newMat, bmp1);

bmp1 should then hold the image you want. 然后bmp1应该保存你想要的图像。

This will however give you a rectangular image that shows the bounding area of your original object, so if it was a circle you have detected, you will get the circle plus all the other parts of the image contained in the bounding box. 但是,这将为您提供一个矩形图像,显示原始对象的边界区域,因此如果它是您检测到的圆圈,您将获得圆圈以及包含在边界框中的图像的所有其他部分。 If you just want the detected object and have the rest of the content as transparent then that is a slightly harder problem. 如果您只是想要检测到的对象并将其余内容视为透明,那么这是一个稍微难以解决的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM