3

I am working on a project where I need to program a Raspberry Pi to grab an image from a webcam, search that image for a box and identify what box it is by it's size ratio. The boxes will be a unique color to the rest of the environment. It would also be good to identify the distance from the box and angle to the box.

Everything I've seen seems to indicate that this should be possible, but after several days of searching I have yet to find anything that really helps me to do this. This project is my first experience using Python, so I'm pretty newbish. Any help even with how to do little portions of this would be greatly appreciated.

Here's my working code so far. It's not much, all it does is grab an image from a webcam :/

import imgproc
from img imgproc *
camera = Camera(160, 120)
viewer = Viewer(160, 120)
n = 1
while (n > 0):
     img = camera.grabImage()
     viewer.displayImage(img)
4

2 回答 2

2

这不是一个完整的解决方案,但是关于如何开始的一些好主意:)

首先,有用于 OpenCV 的 Python 绑定,这是一个最初用 C 语言编写的开源免费计算机视觉库:http: //opencv.willowgarage.com/documentation/python/index.html

解决计算机视觉问题时,您要做的第一件事就是预处理。特别是,知道盒子是不同的颜色有很大帮助——这意味着我们可以通过颜色进行阈值化,并创建一个图像,在没有盒子的地方是黑色的,在盒子所在的地方是白色的,使用诸如http 之类的技术: //aishack.in/tutorials/thresholding/

然后,您将遵循类似于本博客中描述的数独抓取器/求解器的过程 - 您进行 blob 提取 ( http://en.wikipedia.org/wiki/Blob_extraction ) 然后进行霍夫变换以获取线条,然后您可以比较线条之间的距离以确定框的比率。http://aishack.in/tutorials/sudoku-grabber-with-opencv-plot/

几乎只是阅读人们的 OpenCV 数独求解器,直到你了解它是如何完成的,因为有很多很好的教程,它是计算机视觉项目如何进行的简单说明:https: //www.google.com.au /search?q=sudoku+opencv&aq=f&oq=sudoku+opencv&aqs=chrome.0.57j60l3j0l2.1506&sourceid=chrome&ie=UTF-8

于 2013-03-17T22:28:34.187 回答
0

您可能想尝试从 github存储库安装SimpleCV 。使用 SimpleCV,您应该能够使用 Image.hueDistance 命令获取 blob 的颜色。如果您使用 findBlobs 命令查找框,则每个 blob 都应将其纵横比作为参数。我们刚刚在这里发布了关于 SimpleCV 的完整 PyCon 教程。您可以在此处仅查看幻灯片。我们听说在 RaspberryPi 上安装 PyGame(SimpleCV 依赖项)存在一些问题。本演练可能会解决这些问题

于 2013-03-17T23:02:05.520 回答