简体   繁体   English

给定形成网格的白线图像,如何使用opencv获取内部形状的蒙版?

[英]Given a image of white lines forming a grid, how to get masks of the interior shapes using opencv?

I am trying to determine if there are pills in different cells of a pillbox. 我正在尝试确定药盒的不同单元中是否有药。 I have a raspberry pi camera that takes pictures of a pillbox at regular intervals. 我有一个覆盆子pi相机,可以定期拍摄药盒的图像。 I would like to use computer vision using opencv and python to determine which of the 14 cells have pills in them. 我想通过opencv和python使用计算机视觉来确定14个单元中的哪个单元中有药丸。

I have gotten as far as isolating the borders of the cells. 我已经尽力隔离了单元格的边界。 How do I create opencv masks for the interiors of the cells? 如何为细胞内部创建opencv蒙版?

I tried running hough transform on the processed image, but it does not accurately find lines corresponding to each wall 我尝试在已处理的图像上运行霍夫变换,但是它无法准确地找到与每面墙相对应的线

Original image: 原始图片:

在此处输入图片说明

After Processing with cell walls isolated: 用隔离的细胞壁处理后:
在此处输入图片说明

You can try Hough Line detection one the image to detect line segments, and use the information to either close the gaps in your current result or simply detect the cells using only the line segments. 您可以尝试使用“霍夫线检测”来检测图像中的线段,然后使用该信息来填补当前结果中的空白,或者仅使用线段来检测单元格。

The advantage of using line detections is that once you have the parameters of the line, you can extend it below what actually appears in the image. 使用线条检测的优点是,一旦有了线条的参数,就可以将其扩展到图像中实际显示的下方。 So, even if a cell has a gap, you should be able to close it. 因此,即使一个单元格有间隙,您也应该能够将其关闭。

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

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