gpt4 book ai didi

python - 使用SimpleCV库findBlob函数时Pygame Segmentation错误

转载 作者:太空狗 更新时间:2023-10-30 00:57:28 25 4
gpt4 key购买 nike

我一直在使用 SimpleCV 查找要与自动驾驶机器人一起使用的 Blob 。问题是当我在 SimpleCV 中调用 findBlobs 命令时。当我完全挡住 Kinect 相机的镜头时,PyGame 崩溃并给我这个错误:

致命的 Python 错误:(pygame parachute) Segmentation Fault

有时它可以工作,有时它会崩溃,即使镜头未被遮挡。当我运行它超过大约三十秒时,它几乎总是会崩溃。我已经重新安装并修复了 SimpleCV 中的许多问题,并尝试重新安装 Pygame,但它似乎根本没有帮助。另外,我使用 X-Box kinect 作为我的相机源。我正在使用 Ubuntu 11.04。

这是我的确切代码:

from SimpleCV import *
from SimpleCV.Display import *
from time import sleep
k = Kinect()
dis = Display()

while 1:
depth = k.getDepth()
depth = depth.invert()
depth = depth.erode()
blobs = depth.findBlobs(threshval=127, minsize=10, maxsize=0)
if blobs:
blobs.draw()
depth.save(dis)
sleep(0)

最佳答案

Kat 在这里,我编写了 SimpleCV blob 库。

在发布 1.1 版本后,我们发现 blob 库存在一些问题。两个大问题是 blob 库会达到 python 最大递归深度并退出。第二个源于实际的底层 OpenCV 包装器,并在 blob 制造商未检测到任何 blob 时导致 pygame 错误。

现在的解决方案是使用我们 github 存储库的 master 分支中的版本。补丁版本也将在本月晚些时候发布的新 SimpleCV 1.2 版本中可用。如果您想手动修复代码,我已在下面粘贴了修复的代码段:

在 BlobMaker.py 中第 55 行左右

    def extractFromBinary(self,binaryImg,colorImg, minsize = 5, maxsize = -1):
#fix recursion limit bug
sys.setrecursionlimit(1000000)

if (maxsize <= 0):
maxsize = colorImg.width * colorImg.height

retVal = []
#fix all black image bug
test = binaryImg.meanColor()
if( test[0]==0.00 and test[1]==0.00 and test[2]==0.00):
return FeatureSet(retVal)


seq = cv.FindContours( binaryImg._getGrayscaleBitmap(), self.mMemStorage, cv.CV_RETR_TREE, cv.CV_CHAIN_APPROX_SIMPLE)

retVal = self._extractFromBinary(seq,False,colorImg,minsize,maxsize)
del seq
return FeatureSet(retVal)

关于python - 使用SimpleCV库findBlob函数时Pygame Segmentation错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7699704/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com