You Are Here:

Community: Developer Discussion Boards

#1 Old Exclamation Camera code Error: 'TypeError: an Integer is required' - 2009-03-04, 08:02

Join Date: Feb 2009
Posts: 13
itmediaconnect's Avatar
itmediaconnect
Offline
Registered User
Hi,

I'm trying to write a python script/app which can take pictures simultaneously from both the front and rear camera of the device if it has two devices or else just take picture from the rear camera.
When I test with Nokia N70 2nd Ed Fp3 which has two cameras, I get error in line 43 saying 'TypeError: an Integer is required', only the rear camera is started and the picture is not saved. I do not have a picture with the same name at the location. Please help me debug...
I'm getting error in this line:
photo = _my_camera.take_photo('RGB',(640, 480),0,'none','auto','auto',1)

My code is
import appuifw, e32, camera
import _camera
import graphics

_my_camera=_camera.Camera(0)
#_finder_camera=_camera.Camera(0)
no_of_cameras = _my_camera.cameras_available()
#no_of_cameras = cameras_available()

print no_of_cameras

camera_position=0
if no_of_cameras>1:
camera_position=1

print camera_position
temp = int(camera_position)

app_lock = e32.Ao_lock()
#Define the exit function
def quit():
#Close the viewfinder
camera.stop_finder()
#Release the camera so that other programs can use it
camera.release()
app_lock.signal()
appuifw.app.exit_key_handler = quit

#Function for displaying the viewfinder
def vf(im):
appuifw.app.body.blit(im)

#Function for taking the picture
def take_picture():

if _my_camera.taking_photo():
raise RuntimeError, "Photo request ongoing"
#Take the photo
#take_photo(mode='RGB16',size=(640, 480),zoom=0,flash='none',
# exposure='auto',white_balance='auto',position=0):
if no_of_cameras>1:
#photo = camera.take_photo('JPEG_Exif', (2592, 1944),'none','0','auto','auto','1')
photo = _my_camera.take_photo('RGB',(640, 480),0,'none','auto','auto',1)
photo1 = _my_camera.take_photo('RGB',(640, 480),0,'none','auto','auto',0)

#_my_camera.take_photo('RGB',(1024, 768),0,'none','auto','auto',1)
else:
photo = _my_camera.take_photo('RGB',(640, 480),0,'none','auto','auto',0)
#photo = camera.take_photo('RGB', (1024, 768),camera_position)
#photo = camera.take_photo('RGB', (640, 480),camera_position)
#Save it at maximum quality
photo.save(photo_savepath, quality = 100)
photo1.save(photo_savepath1, quality = 100)
#Save it
#f = open(photo_savepath, "w")
#f.write(photo)
#f.close()
#f = open(photo_savepath1, "w")
#f.write(photo1)
#f.close()


#Restart the viewfinder
camera.stop_finder()
camera.start_finder(vf)

photo_savepath = u"E:\\System\\Apps\\Python\\my\\photo.jpg"
photo_savepath1 = u"E:\\System\\Apps\\Python\\my\\photo1.jpg"
#This is the path and name for storing the photo

#Set the application's body to Canvas
appuifw.app.body = appuifw.Canvas()

#Start the viewfinder
camera.start_finder(vf)

#Set the application's menu with the option to take the photo
appuifw.app.menu=[(u"Take photo", take_picture)]

#Wait for the user to request the exit
app_lock.wait()


Thanks and Regards
Neeraj
Reply With Quote

#2 Old Smile Re: Camera code Error: 'TypeError: an Integer is required' - 2009-03-04, 08:21

Join Date: Nov 2008
Posts: 73
xiaobu
Offline
Regular Contributor
Quote:
Originally Posted by itmediaconnect View Post
Hi,

I'm trying to write a python script/app which can take pictures simultaneously from both the front and rear camera of the device if it has two devices or else just take picture from the rear camera.
When I test with Nokia N70 2nd Ed Fp3 which has two cameras, I get error in line 43 saying 'TypeError: an Integer is required', only the rear camera is started and the picture is not saved. I do not have a picture with the same name at the location. Please help me debug...
I'm getting error in this line:
photo = _my_camera.take_photo('RGB',(640, 480),0,'none','auto','auto',1)

My code is
import appuifw, e32, camera
import _camera
import graphics

_my_camera=_camera.Camera(0)
#_finder_camera=_camera.Camera(0)
no_of_cameras = _my_camera.cameras_available()
#no_of_cameras = cameras_available()

print no_of_cameras

camera_position=0
if no_of_cameras>1:
camera_position=1

print camera_position
temp = int(camera_position)

app_lock = e32.Ao_lock()
#Define the exit function
def quit():
#Close the viewfinder
camera.stop_finder()
#Release the camera so that other programs can use it
camera.release()
app_lock.signal()
appuifw.app.exit_key_handler = quit

#Function for displaying the viewfinder
def vf(im):
appuifw.app.body.blit(im)

#Function for taking the picture
def take_picture():

if _my_camera.taking_photo():
raise RuntimeError, "Photo request ongoing"
#Take the photo
#take_photo(mode='RGB16',size=(640, 480),zoom=0,flash='none',
# exposure='auto',white_balance='auto',position=0):
if no_of_cameras>1:
#photo = camera.take_photo('JPEG_Exif', (2592, 1944),'none','0','auto','auto','1')
photo = _my_camera.take_photo('RGB',(640, 480),0,'none','auto','auto',1)
photo1 = _my_camera.take_photo('RGB',(640, 480),0,'none','auto','auto',0)

#_my_camera.take_photo('RGB',(1024, 768),0,'none','auto','auto',1)
else:
photo = _my_camera.take_photo('RGB',(640, 480),0,'none','auto','auto',0)
#photo = camera.take_photo('RGB', (1024, 768),camera_position)
#photo = camera.take_photo('RGB', (640, 480),camera_position)
#Save it at maximum quality
photo.save(photo_savepath, quality = 100)
photo1.save(photo_savepath1, quality = 100)
#Save it
#f = open(photo_savepath, "w")
#f.write(photo)
#f.close()
#f = open(photo_savepath1, "w")
#f.write(photo1)
#f.close()


#Restart the viewfinder
camera.stop_finder()
camera.start_finder(vf)

photo_savepath = u"E:\\System\\Apps\\Python\\my\\photo.jpg"
photo_savepath1 = u"E:\\System\\Apps\\Python\\my\\photo1.jpg"
#This is the path and name for storing the photo

#Set the application's body to Canvas
appuifw.app.body = appuifw.Canvas()

#Start the viewfinder
camera.start_finder(vf)

#Set the application's menu with the option to take the photo
appuifw.app.menu=[(u"Take photo", take_picture)]

#Wait for the user to request the exit
app_lock.wait()
-----------------------------------
hi,
i think the parameter sequence is wrong.
may be like this:
photo = _my_camera.take_photo('RGB',(640, 480),'none',0,'auto','auto',1)
Reply With Quote

#3 Old Question Re: Camera code Error: 'TypeError: an Integer is required' - 2009-03-04, 08:36

Join Date: Feb 2009
Posts: 13
itmediaconnect's Avatar
itmediaconnect
Offline
Registered User
Hi xiaobu,

I changed the parameter sequence as you suggested to:
photo = _my_camera.take_photo('RGB',(640, 480),'none',0,'auto','auto',1)

but I'm still getting the same error at the same place

Thanks


Thanks and Regards
Neeraj
Reply With Quote

#4 Old Re: Camera code Error: 'TypeError: an Integer is required' - 2009-03-04, 09:20

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Online
Forum Nokia Champion
Quote:
Originally Posted by itmediaconnect View Post
Hi xiaobu,

I changed the parameter sequence as you suggested to:
photo = _my_camera.take_photo('RGB',(640, 480),'none',0,'auto','auto',1)

but I'm still getting the same error at the same place

Thanks
hello neeraj

i will advice you that whenever you are posting any code in the dibo please use the code tags(#) avilable in your editor box so that we can easily get your code with indentation.

enjoy Pythoning
Gaba88


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
[defect report] carbide.cpp code formatter can't produce code conforming to s60 style simo.salminen Carbide.c++ IDE and plug-ins 2 2008-10-27 11:56
carbide-error upendersolanki Carbide.c++ IDE and plug-ins 5 2008-02-06 12:09
problems displaying video gorsken Mobile Java Media (Graphics & Sounds) 6 2006-06-21 18:18
Is it possible to use same source code for 7610 & 6600 Camera module? ppiggy General Symbian C++ 1 2004-08-04 14:30

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia