Pages

Tuesday, June 11, 2013

Webcam testing notes

I tidied up the test web cam function, ran it, but still got the same error message of unsupported format.


*** Start Program - FongToy v1.7 tlfong01 2013jun10 ***

*** Sample run begin - Test web cam 2013jun11hkt11:15 ***

List of available cameras =  ['/dev/video0']
Traceback (most recent call last):
  File "fongtoy.py", line 77, in <module>
    ftwebcam.TestWebcam()
  File "/home/pi/fongtoy/ftwebcam.py", line 46, in TestWebcam
    webCam.start()
SystemError: ioctl(VIDIOC_S_FMT) failure: no supported formats


# ftwebcam v0.2 tlfong01 2013jun11

# *****************************************************************************
# Module - ftwebcam.py
# Description - Test Logitech webcam C920 and C270 
# Reference
#   Pygame.camera Reference - http://www.pygame.org/docs/ref/camera.html
#   Pygame.camera Turorial -  http://www.pygame.org/docs/tut/camera/CameraIntro.html
# Notes
#   Image zise 2MP 16:9 = 1920 * 1080 = 2,073,600
# *****************************************************************************

# *****************************************************************************
# Imports
# *****************************************************************************

import time

import pygame
import pygame.camera
from pygame.locals import *

import ftprint

# *****************************************************************************
# Function - TestWebcam()
# Description - 
#   Test Webcam 
# *****************************************************************************

def TestWebcam():

    ftprint.PrintDoubleSpaceLine("*** Sample run begin - Test web cam 2013jun11hkt11:15 ***")    
    
    webCamWidth  = 640
    webCamHeight = 480

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

    webCamList = pygame.camera.list_cameras()
    if webCamList:
        print "List of available cameras = ", webCamList
        webCam = pygame.camera.Camera(webCamList[0],(webCamWidth, webCamHeight))

    webCam.start()
    image = webCam.get_image()

    webcam.stop()
    pygame.quit()

    ftprint.PrintDoubleSpaceLine("*** Sample run end ***")

    sys.exit()

# .END

No comments:

Post a Comment