Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 16:34, 30 June 2008.

Example of pycamera

From Forum Nokia Wiki


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
Related Discussions
Thread Thread Starter Forum Replies Last Post
findbox problem with dialog? palak_shah_23 Symbian User Interface 6 2006-07-14 02:32
Developing SMS application vishwakanand PC Suite API and PC Connectivity SDK 2 2003-08-12 13:44
Some exceptions in RemoteCam sample application. susanto_waluyo General Symbian C++ 5 2003-11-03 06:38
Nokia 6600 phone memory access GattusoMatrazzi General Symbian C++ 12 2007-12-02 20:46
migrating makefile -D to mmp steverino2 Carbide.c++ and CodeWarrior Tools 4 2007-05-09 04:02
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZpythonQ
     qfnZtopicQUqfnTopicZseriesE5f60Q
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX
     
    
            
            RDF Facets:
            
            
                        qfnZuserE5ftagQSxviewfinderX