Skip to main content
2 of 8
added 82 characters in body

fatal python error: (pygame parachute) Segmentation Fault, vision system using simplecv

I am fairly new to both the raspberry pi and python. I have written a code to analyze an image, but I keep getting fatal python error: (pygame parachute) Segmentation Fault. It usually occurs between 15 minutes and an hour into my program. From what I have read, this is typically some sort of memory overreach problem. I haven't found any concrete answers that have been able to solve my problem. Here is my code. My memory usage never goes above 33% when I launch the program in the GUI. Please help. Any information on how to fix or debug this problem would be greatly appreciated.

import cv2
from SimpleCV import Image, Camera
import time
import os
import RPi.GPIO as GPIO

T = 1
z = 0

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(31, GPIO.OUT)
GPIO.setup(32, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

GPIO.output(31,GPIO.HIGH)
cam = Camera(prop_set={'width':320, 'height':240})
while(T):

    w = [0 in range(9)]

    if(GPIO.input(32)):
       start = 80
       pixel = 0
       end = 225
       time.sleep(0.32)
       img = cam.getImage()
       img.save('original.jpg')
       edges = cv2.imread('original.jpg')

       edges = cv2.Canny(edges,90,210)
       print("hola")
       for y in range (100,160):
           i = 0
           first = 0
           temp = 0
           last = 0
           for x in range (start, end):
               pixel = edges[y,x]

               if (pixel >=120 and first == 0):
                   first = x


               if (pixel >=120 and first != 0 and last < x):
                   last = x

           if last != 0:
               temp = last - first
               for x in range(start, end):
                   if ((x <= last) and (x >=first)):
                       edges[y,x] = 140;

       while(GPIO.input(32)):
           pass