Pages

Friday, June 14, 2013

Logitech C270 live streaming OK




Now I am testing Logitech C270.  I am also doing live streaming instead of taking just 1 picture each program execution.


    while True:
        if webCam.query_image():
            webCamSurface = webCam.get_image(webCamSurface)
            webCamDisplay.blit(webCamSurface, (0,0))
            pygame.display.flip()

.END


def TestWebcam04():

    ftprint.PrintDoubleSpaceLine("*** Sample run begin - TestWebCam04() 2013jun14hkt21:13 ***")    
       
    Size640x480 = (640, 480)
    Size1280x1024 = (1280, 1024)
    Size1920x1024 = (1920, 1024)

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

    webCamList = pygame.camera.list_cameras()
    if webCamList:
        print "List of available cameras = ", webCamList
    else:
        print "!!! No camera!!! "

    # webCam = pygame.camera.Camera(webCamList[0], Size1280x1024)
    webCam = pygame.camera.Camera(webCamList[0], Size640x480)
    webCam.start()

    pygame.display.init()
    # webCamDisplay = pygame.display.set_mode(Size1280x1024, 0)
    webCamDisplay = pygame.display.set_mode(Size640x480, 0)

    # webCamSurface = pygame.surface.Surface(Size1280x1024, 0, webCamDisplay)     
    webCamSurface = pygame.surface.Surface(Size640x480, 0, webCamDisplay)   

    while True:
        if webCam.query_image():
            webCamSurface = webCam.get_image(webCamSurface)
            webCamDisplay.blit(webCamSurface, (0,0))
            pygame.display.flip()

    # pygame.image.save(webCamSurface, "/home/pi/fongtoy/testImage.bmp")

    webCam.stop()
    pygame.quit()

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

.END













No comments:

Post a Comment