Example of pycamera
With the recent launch of Nokia Computer Vision pylib. We can take photos and play around it with a greater range of functionalities. The code below shows how to take a photo using the pycamera (NokiaCV and utilities).
Recently we all came to know about a bug using the take_photo of the camera module so this new feature will help a lot in that case.
import e32
import pycamera
import sysinfo
print "Constructing camera object 0"
cam = pycamera.Camera(0)
print "Reserving camera"
cam.Reserve()
print "Powering on"
cam.PowerOn()
print "Preparing to capture"
# (640, 480), (1024, 768), (1600, 1200)
cam.SetResolution((2592, 1944))
# EFormat16bitRGB444 , EFormat16BitRGB565, EFormat32BitRGB888 , EFormatFbsBitmapColor16M
# EFormatFbsBitmapColor16MU , EFormatFbsBitmapColor4K , EFormatFbsBitmapColor64K , EFormatJpeg , EFormatMonochrome , EFormatUserDefined
# EFormatYUV420Interleaved,EFormatYUV420Planar,EFormatYUV420SemiPlanar,EFormatYUV422,EFormatYUV422Reversed,EFormatYUV444
cam.SetFormat(pycamera.EFormatExif)
# 5 to 101
cam.SetJpegQuality(101)
# 0(Auto) , 50, 100, 200, 400, 800, 1600
cam.SetISO(50)
# EExposureManual , EExposureAperturePriority , EExposureAuto,EExposureBacklight,EExposureBeach,EExposureCenter,EExposureInfra,EExposureNight,EExposureProgram,EExposureShutterPriority,EExposureSnow,EExposureSport,EExposureSuperNight,EExposureVeryLong
cam.SetExposureMode(pycamera.EExposureCenter)
# - 8 to 9 by step of 0.25
cam.SetExposureCompensation(-4)
# EWBAuto , EWBBeach , EWBCloudy , EWBFlash , EWBFluorescent , EWBManual , EWBShade , EWBSnow , EWBTungsten,
#cam.SetWBMode(EWBDayLight)
# EFlashAuto , EFlashFillIn,EFlashForced , EFlashLManual , EFlashRedEyeReduce , EFlashSlowFrontSync , EFlashSlowRearSync
#cam.SetFlash(EFlashNone)
cam.PrepareForCapture()
lock = e32.Ao_lock()
photo = None
def photo_callback(arg):
global photo
print "photo received!"
print type(arg)
photo = arg
lock.signal()
cam.SetPhotoCallback(photo_callback)
def viewfinder_callback(arg):
print "viewfinder frame!"
cam.SetViewfinderCallback(viewfinder_callback)
print "Starting viewfinder"
cam.StartViewfinder()
e32.ao_sleep(1)
K = 1
import appuifw
for i in range(K):
print "Taking photo", i
print "Free memory: ", sysinfo.free_ram()
cam.TakePhoto()
lock.wait()
canvas = appuifw.Canvas(event_callback = lambda ev: None,
redraw_callback = lambda ev: None)
oldBody = appuifw.app.body
appuifw.app.body = canvas
im = pycamera.DecodeJpeg(photo)
canvas.blit(im)
e32.ao_sleep(1)
appuifw.app.body = oldBody
print "Stopping viewfinder"
cam.StopViewfinder()
print "Powering off"
cam.PowerOff()
print "Releasing"
cam.Release()
print "Deleting camera object"
del cam
Thank you for reading this post. You can now Leave A Comment (0) or Leave A Trackback.
Post Info
This entry was posted on Wednesday, July 2nd, 2008 and is filed under Blogroll.You can follow any responses to this entry through the Comments Feed. You can Leave A Comment, or A Trackback.
Previous Post: Groups seek drilling halt near sage grouse habitat »
Next Post: Google wins source code ruling against Viacom »
- Would-be Japanese space tourist wants $21M back
- NASA scales back flagship Mars mission
- Bulgarian archaeologists unearth ancient chariot
- Witnesses: Large meteor streaks across Canada sky
- Solar panels on graves give power to Spanish town
- Fuel from food? The feast is over
- Fabulous flippers: Dolphins have quite the kick
- Whales rescued from Australian beach join pod
- Siberian quake triggers false US seismic reports
- Pirates sign Indian _ not Cleveland _ pitchers

