Now I am testing C270 again, this time adding small objects of 5mm screws, washers, and nuts.
.END
ftwebcam.TestWebcamCamera09(cameraNumber = 0, imageSize = (1280, 720), imageCount = 3000, timerSecond = 0.25, fileName = "file20130618hkt1725.bmp")
ef TestWebcamCamera10(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 ***")
# *** sample call ***
# ftwebcam.TestWebcamCamera09(cameraNumber = 1,
# imageSize = (1280, 720),
# imageCount = 10,
# timerSecond = 1,
# fileName = "file20130618hkt1725.bmp")
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 ***")
def TestWebcamCamera08(cameraNumber, imageSize, imageCount, timerSecond):
ftprint.PrintDoubleSpaceLine("*** Sample run begin - TestWebCamCamera09() 2013jun18hkt16:48 ***")
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
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) or
(event.type == KEYDOWN and event.key == K_x)):
webCamCamera.stop()
pygame.quit()
return
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 ***")
.END2
No comments:
Post a Comment