PDA

View Full Version : python app crashes after launch



gr8gui
June 27th, 2012, 01:24 PM
when i run:

#!/usr/bin/env python

import pygame, sys
import pygame.camera
from pygame.locals import *

pygame.init()
pygame.camera.init()

screen = pygame.display.set_mode((640,480))

cam =pygame.camera.Camera("/dev/video0",(640,480))
cam.start()

while 1:
image = cam.get_image()
screen.blit(image,(0,0))
pygame.display.update()
for event in pygame.event.get():
if event.type ==pygame.QUIT:
sys.exit()
__________________________________________________ _______________
window opens and then crashes returning:
(pygame parachute) Segmentation Fault
Aborted (core dumped)

Vaphell
June 27th, 2012, 03:52 PM
use
tags, especially when you paste code. Indentation, especially in case of python, is crucial.
This one is not complicated so it's easy to guess but you shouldn't make it harder than necessary for people willing to help.

MG&TL
June 27th, 2012, 03:58 PM
Obvious question...you do have a webcam, and its device name is /dev/video0, right?

gr8gui
June 27th, 2012, 04:04 PM
I see the webcam stream for a fraction of a second.

MG&TL
June 27th, 2012, 04:09 PM
Hm. Okay, what happens if you substitute "pygame.display.update()" with "pygame.display.flip"? To quote their manual, pygame.display.update() on pygame.OPENGL displays will "cause an exception".

gr8gui
June 27th, 2012, 04:14 PM
same thing. now it lasts a little more but still crashes

MG&TL
June 27th, 2012, 05:00 PM
Sorry, no idea.

Hopefully someone else has an idea, or you could try one of the pygame forums.

greenpeace
June 28th, 2012, 10:20 AM
Your code works fine on my machine...

...does your webcam work well with cheese or any other webcam application?

Bodsda
June 28th, 2012, 12:35 PM
It would be useful to have the traceback and any messages that are printed to stdout

MG&TL
June 28th, 2012, 12:36 PM
It would be useful to have the traceback and any messages that are printed to stdout

"(pygame parachute) Segmentation Fault
Aborted (core dumped)"

;)

gr8gui
June 29th, 2012, 11:38 AM
yes my webcam works well in cheese. I will try another webcam and seeifit works