Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    41

    Angry Problem with LWUIT and Capturing image specified resolution on s40

    Hi Experts!

    I have a need to capture an image using the phone's camera in my application. I am using LWUIT for my UI and so I start the view finder like so as suggested by the documentation:

    Code:
    m_videoComponent = VideoComponent.createVideoPeer("capture://image");
    m_player = (Player) m_videoComponent.getNativePeer();					
    m_player.realize();
    m_player.prefetch();
    m_videoComponent.start();
    To capture the image, I do:
    Code:
    VideoControl videoControl = (VideoControl) m_castedForm.getPlayer().getControl("VideoControl");
    byte[] img = videoControl.getSnapshot(null);
    Now this works ok. However, my requirement is to capture an image using a higher resolution that is supported by the device. However, from what I have noticed, the getSnapshot method seems to only return an image the size of the device screen (as if it was just taking a screenshot) as opposed to a higher image resolution that is supported by the device. I've read in some forums that it is possible to set the desired capture resolution like this:

    Code:
    cameraControl = (CameraControl)player.getControl("CameraControl"); 
    cameraControl.setStillResolution(1);
    or by passing it as an argument in the getSnapshot like this
    Code:
    byte[] imageData = vc.getSnapshot(“width=120&height=90”);
    However, none of them seemed to work. Getting the CameraControl would always return null and passing the size argument in the getSnapshot method would throw an exception saying that it is not supported.

    So my question is, can LWUIT's video component capture an image of a higher resolution? If so, how can this be done?

    Thank you in advance!

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: Problem with LWUIT and Capturing Image with specified resolution on S40 devices

    What is the exception you are getting and what are the arguments you are trying to pass as width and height?
    remember that Asha device have limit heap space so lets say an image of 240x320 when loaded to memory as bytes takes 320x240x4 bytes which is 307200 bytes if you are trying a VGA image size 480x640 is actually 1228800 bytes which is roughly 1.2MB which you might dont have enough heap space (depanding on what else your app have)

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    41

    Re: Problem with LWUIT and Capturing Image with specified resolution on S40 devices

    I am not passing any arguments at the moment since as I have mentioned in my post, any attempts to pass argument either through the getSnapshot method or via VideoControl object does not work for me. The image that I get depends on what device I use. For Asha 311, the image returned has a resolution of 240x400 and for Asha 303, it's 240x320. There seems to be a correlation between the screen size and the resolution returned by the VideoComponent.

    So from your reply, are you suggesting that the resolution returned by the VideoComponent is influenced by the amount of heap available in the program? Also, how do you properly request for a resolution size that you want? Let's say for the sake of argument, I have unlimited memory and any resolution that I pass is supported - Is the code that I posted below the correct way? If so, do you know why it is not working?

    Anyway, I wonder how the native camera app does it. On Asha 311, it can capture up to 2048x1536 but from your reply, it looks quite difficult just to get 480x640 as you will already be hitting 1.2mb of heap which is almost close to the limit of what most Asha devices can support. Also, I don't understand why the native camera app cannot be launched via platformrequest or any similar mechanism - life would definitely be easier if that is supported

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: Problem with LWUIT and Capturing Image with specified resolution on S40 devices

    the correct way i use is VideoControl.getSnapshot("width=<width>&height=<height>");
    Note that if your request resolution is not supported then the nearest supported resolutioin will be used (isnt effected by heap space, that thing will only cause an OOM).
    You still havent wrote what type of exception and/or message you got when trying with those parameters.

  5. #5
    Registered User
    Join Date
    Feb 2013
    Posts
    41

    Re: Problem with LWUIT and Capturing Image with specified resolution on S40 devices

    I get this exception whenever I pass the width and height parameter to the getSnapshot function:

    javax.microedition.media.MediaException: Invalid locator: capture://video?width=240&height=320

    I did see it working in some devices but it works on all if I pass null on it. Is there anyway that I can query whether the with and height parameters are supported?

  6. #6
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: Problem with LWUIT and Capturing Image with specified resolution on S40 devices

    I'm not sure how you got this exactly the width and height shouldnt be part of the connector string
    it should be passed in the getSnapshot of the VideoControl.
    look at my code below this is exactly how you should do it
    you can also try capture://Image in your connector it works for some devices (i dont remember for which, maybe symbians)
    you can query which locators you can use with capture with this code Manager.getSupportedContentTypes("capture")

Similar Threads

  1. preview problem of high resolution image.
    By sumeshchakra in forum Mobile Java Networking & Messaging & Security
    Replies: 7
    Last Post: 2010-06-23, 09:08
  2. HELP ME!!!! Problem example capturing image
    By ele.alberti in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2008-10-27, 21:24
  3. Problem with capturing the second image
    By apashya in forum Streaming and Video
    Replies: 1
    Last Post: 2006-07-01, 10:53

Posting Permissions

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