Pages

Tuesday, June 18, 2013

C920 testing notes






























Now I am using the test function to get a C920 image of HD720 (1280 x720) and then cropped it to 800 x 600 pixels.

.END

def TestWebcamCamera09(cameraNumber, imageSize, imageCount, timerSecond, fileName):

    ftprint.PrintDoubleSpaceLine("*** Sample run begin - TestWebCamCamera08() 2013jun18hkt10:54 ***")    

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

    webCamList = pygame.camera.list_cameras()
    webCamCount = len(webCamList)
    print "Number of cameras found = ", webCamCount
    print "Camera used = ", cameraNumber
    print "Image size = (", imageSize[0], ", ", imageSize[1], ")"
    print "Number of images to get = ", imageCount
    print "Time between images (in seconds) = ", timerSecond

    imageSize = Size1280x720 # debug only !!!

    webCamCamera = pygame.camera.Camera(webCamList[int(cameraNumber)], imageSize)
    webCamCamera.start()

    pygame.display.init()
    webCamDisplay = pygame.display.set_mode(imageSize, 0)

    webCamSurface = pygame.surface.Surface(imageSize, 0, webCamDisplay)   

    for count in range(imageCount):

        for event in pygame.event.get(): # Escape key from local keyboard, NOT PuTTY!!!
   if (event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE)):                                  
                webCamCamera.stop()
                pygame.quit()
return

   if (event.type == KEYDOWN and event.key == K_x):                                  
                webCamCamera.stop()
                pygame.quit()
return

   if (event.type == KEYDOWN and event.key == K_s):  
       fullPathFileName = os.path.join('/home/pi/fongtoy/', fileName)
                pygame.image.save(webCamSurface, fullPathFileName)
print "Image saved"          

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

        time.sleep(timerSecond)
print "Image number = ", count

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

    print "File name of last image = /home/pi/fongtoy/testImage.bmp", 

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

.END



No comments:

Post a Comment