×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    6

    Take a photo in MWS

    Hi all.

    I try to take a photo like what Camera function does in MWS. According to some advises in the other threads, "camera.take_photo()" should work fine with mod_python. After executing the following codes:
    Code:
    import camera
    image=camera.take_photo()
    filename=u'c:\\data\\camera.jpg'
    image.save(filename)
    Nothing happened! No camera.jpg in the file system. No error message.
    I wander that the mod_python in MWS does not support this function? If so, how the camera function in MWS does the job?
    Please help, thanks a lot.

  2. #2
    Registered User
    Join Date
    Dec 2003
    Posts
    20

    Re: Take a photo in MWS

    Hi.

    Which device are you using? What is the version of MWS and Python?

    There might be some issues in certain configurations. I managed to get that kind of script working in couple of devices, but on the other hand I once got into similar situation. The request was not answered at all as the script froze somewhere during the execution.

    The camera functionality in MWS has been done in a different way.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    6

    Re: Take a photo in MWS

    I use Nokia N82. The version of MWS is beta V14. And the python module is installed while installing MWS. I do not know the version number of python in MWS.

    Since the camera functionality in MWS works fine, can I write some Python codes like it to get the job done? Or should I upgrade the mod_python in MWS by myself?
    Thanks for any help.

    By the way, I installed Python 1.4.3 and Raccoon 2.0 in another device N93. The function "camera.take_photo()
    " works.

  4. #4
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,796

    Re: Take a photo in MWS

    Hi,

    camera.take_photo() should work with older PyS60 Releases as well.

    I would advice you to install the Python Script Shell from here and try the function there. Would surely work.

    Let me know if you have any further challenges.

    Best Regards,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    6

    Re: Take a photo in MWS

    Hi,

    While testing the function by the Python Script Shell, camera.take_photo() seems work. (The light next to the camera flashes) But there is no camera.jpg in the file system.

    On the other hand I test the same function in MWS, i.e., link an URL by a browser to execute the camera.py. The error messages are as followings. It seems that the camera module can not be imported in MWS.
    Code:
      File "c:\resource\mod_python\apache.py", line 356, in HandlerDispatch
        log=debug)
      File "c:\resource\mod_python\apache.py", line 629, in import_module
        module = imp.load_module(mname, f, p, d)
      File "C:/Data/Web server/htdocs/pdacamera/cameraHandler.py", line 10, in ?
        import camera
    File "C:\Data\Web server\htdocs\camera.py", line 5, in ?
        image=camera.take_photo()
    
    AttributeError: 'module' object has no attribute 'take_photo'

  6. #6
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,796

    Re: Take a photo in MWS

    Hi,

    First things, when you test it with the script shell, take.photo() function will click a photo, obliviously induces the flash, but to have the image saved you need to call the save function too

    Code:
    image=camera.take_photo()
    filename=u'c:\\data\\camera.jpg'
    image.save(filename)
    Secondly, I haven't tried this on MWS, but the problem doesn't seem to be about importing camera module... as its a attribute error. Could you have this code in the camera.py and test it with MWS...

    Code:
    import camera
    dir(camera)
    Let me know the output,

    Best Regards,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  7. #7
    Registered User
    Join Date
    Dec 2003
    Posts
    20

    Wink Re: Take a photo in MWS

    I tried now with N82 (SW ver 30.*) and MWS 1.4. It took and saved the picture correctly.

    Here is the code I used (webcam.py):

    Code:
    import camera
    
    def handler(req):
        from mod_python import apache
    
        req.content_type = 'text/html'
    
        photo = camera.take_photo(size = (640, 480))
        photo.save("C:\\Data\\Images\\webcam.jpg")
    
        output = "Picture taken"
        
        req.write(output)
        return apache.OK
    My ht.acl file looks like this:

    Code:
    Satisfy All
    
    AuthType Basic
    AuthName 'Camera'
    AuthBasicProvider file
    AuthUserFile conf/passwords.txt
    AuthGroupFile conf/groups.txt
    
    # If you want to give access to all users
    #Require valid-user
    
    # If you want to give access to only yourself or some groups (add all needed groups delimited with space)
    Require group admin
    
    # If you want to give access to some users (add all needed users delimited with space)
    #Require user visitor
    
    AddHandler mod_python .py
    PythonHandler webcam
    PythonDebug On
    I don't take responsibility of that ht.acl being reasonable, safe or anything, but it works for me...

    Could you try with that? Only difference I noticed there is that the path in my script is not defined in unicode like it was in yours, but it's probably irrelevant here.

    One possible reason is always the device firmware version that you are using. If you got older version, try updating. Sometimes it does wonders!

  8. #8
    Registered User
    Join Date
    Apr 2008
    Posts
    6

    Re: Take a photo in MWS

    Thanks jpusa. Your codes (webcam.py) worked very well.

    It seems similar with my original codes, except specifying the image size. Maybe this is the reason that caused the function failed.

    Also thanks for croozeus's help. The function "image.save(filename)" is called at that time, but no picture is saved.

    Thanks for all your help.

Similar Threads

  1. Using MWS and Context-Situation for Mobile Applications
    By ARJWright in forum Mobile Web Server
    Replies: 17
    Last Post: 2010-01-05, 02:35
  2. MIDlet upload photo problem
    By Kmcgivern in forum Mobile Java General
    Replies: 3
    Last Post: 2008-09-09, 09:21
  3. Problem in addind a photo to a contact
    By nroyer in forum Symbian
    Replies: 5
    Last Post: 2007-12-18, 14:15
  4. RaccoonOnMap and MWS
    By talakosk in forum Mobile Web Server
    Replies: 0
    Last Post: 2007-06-27, 11:52
  5. Problems when Importing vCard with Photo
    By yoadg in forum Mobile Java General
    Replies: 1
    Last Post: 2007-05-31, 16:45

Posting Permissions

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