2011-10-08 17 views
5

我一直在使用SimpleCV來查找與自動駕駛機器人一起使用的blob。問題是當我在SimpleCV中調用findBlobs命令時。當我完全封鎖Kinect的攝像頭的鏡頭,pygame的崩潰給我這個錯誤:使用SimpleCV庫時Pygame分割錯誤findBlob函數

致命的Python錯誤:(pygame的降落傘)分段錯誤

有時它的工作原理,它只是崩潰其他時候,鏡頭即使被暢通無阻。當我運行時間超過三十秒時,它幾乎總是會崩潰。 我重新安裝並修復了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) 

回答

0

Fatal Python error: (pygame parachute) Segmentation Fault

這意味着一些代碼墜毀,現在你需要調試它來發現問題。我假設你正在學習一些東西;不妨學習如何調試;-)

Sometimes it works and other times it just crashes, even when the lens is unblocked. It will almost always crash when i run it for longer than about thirty seconds.

這些是堆損壞或數據競爭的典型症狀。

I have re-installed and fixed many problems in SimpleCV and tried re-installing Pygame and it doesn't seem to help.

你爲什麼會這麼想?你的問題並不是在所有的看起來像一個安裝問題。

所以這裏是你要做的:在Linux上調試堆損壞問題的工具是valgrind。像這樣運行:

valgrind python your-code.py 

不幸的是,默認的Python安裝不Valgrind的友好,和上面的命令可能會產生大量的「初始化內存中讀取」錯誤。你會想要使用這種抑制file來抑制其中的大部分。

可能會專注於包含非Python部分(特別是SimpleCV)的錯誤。您正在尋找invalid {read,write} ... N bytes after block ...

如果您發現這樣的錯誤,您可以嘗試使用GDB進一步調試它,或將其報告給SimpleCV開發人員並希望獲得最佳效果。

如果您沒有找到該錯誤,您可以構建一個適用於Valgrind的Python版本(instructions),然後重試。

如果上面的運行是Valgrind-clean,那麼你可能有比賽而不是堆腐敗。重複ThreadSanitizer

2

安東尼這裏SimpleCV開發商之一: 你可以嘗試改變最後一行:

sleep(0.01) 

只是爲了看看有沒有打算在哪裏它不能處理速度不夠快一些類型的問題。我最近升級到了Ubuntu 11.04,並且我認爲自10.10以來,我需要壓縮一些python bug。

此外,如果你可以張貼這對我們的問題隊列我將不勝感激:這裏 http://github.com/ingenuitas/SimpleCV/issues

5

吉,我寫的SimpleCV BLOB庫。

在我們發佈1.1版後,我們發現了blob庫的一些問題。兩個大的問題是blob庫會達到python max遞歸深度並保留。第二個源自實際的底層OpenCV包裝,並在blob製造商沒有檢測到blob時導致pygame錯誤。

現在的解決方案是使用我們github倉庫主分支中的版本。補丁版本也將在本月晚些時候推出的新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) 
0

只是代替你的斑點閾值「-1」;我有同樣的問題,並修復了這個問題。