×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    18

    process image captured by the camera

    I got the image data from the camera like this:
    byte[] imageArray=videoControl.getSnapshot(null),

    Then I read the pixels and processed the data:
    readBarcode(imageArray);
    public void readBarcode(byte[] array){
    ...
    gray=(array[4*imageWidth*yPos+3]*11+
    array[4*imageWidth*yPos+2]*59+
    array[4*imageWidth*yPos+1]*30 )/100;
    ...
    }

    I ran the program on my mobile phone nokia 6120c and it return 'error 0' at the line 'gray=(array[4*imageWidth*yPos+3]*11+
    array[4*imageWidth*yPos+2]*59+array[4*imageWidth*yPos+1]*30 )/100'

    What`s wrong with it?

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: process image captured by the camera

    I'd guess you're getting an IndexOutOfBoundsException. Are you sure the byte[] is as big as you think?

    Graham.

  3. #3
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: process image captured by the camera

    Hi,
    Try to put the code inside the try-catch block and as grahm suggested that please check that there is no exception,BTW what you are looking for and expect from the line gray = .....?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  4. #4
    Registered User
    Join Date
    Sep 2009
    Posts
    18

    Re: process image captured by the camera

    Quote Originally Posted by grahamhughes View Post
    I'd guess you're getting an IndexOutOfBoundsException. Are you sure the byte[] is as big as you think?

    Graham.
    It seems it`s an IndexOutOfBoundsException, but why?
    I think the size of the imageArray is imageWidth*imageHeight*4 byte,isn`t it?

  5. #5
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: process image captured by the camera

    Have you asked it how big it is?

  6. #6
    Registered User
    Join Date
    Sep 2009
    Posts
    18

    Re: process image captured by the camera

    Quote Originally Posted by grahamhughes View Post
    Have you asked it how big it is?
    I have checked the size.

    The screen size is 240*320. I set the video size like this:
    videoControl.setDisplaySize(getWidth( )-10,getHeight( )-10);
    The size of the canvas is 240*235, so the size of the video should be 230*225.

    But when I created an image with the imageArray as following:
    Image image=Image.createImage(imageArray, 0, imageArray.length);
    I found that image.getWidth( ) and image.getHeight( ) return 320 and 240. The imageArray.length is approximately 170000 and it`s changing every time I captured an image.

    I thought imageArray.length=image.getWidth( )*image.getHeight( )*4 and image.getWidth( )*image.getHeight( )=230*225. But it seems it`s wrong. Why`s that?

  7. #7
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: process image captured by the camera

    The byte[] is not in a "raw" format. It is probably JPEG encoded data. You need to convert the data to an Image (as you have already), and work from the Image object.

    You might find this example useful.

    Graham.

Similar Threads

  1. how to save image captured by camera
    By abdelbakiguesmi in forum Symbian Media (Closed)
    Replies: 17
    Last Post: 2009-05-29, 02:38
  2. Replies: 2
    Last Post: 2009-03-13, 09:25
  3. image on camera Canvas
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 29
    Last Post: 2008-09-29, 08:52
  4. Capturing image from secondary camera problem
    By michaelnewyork in forum Symbian
    Replies: 7
    Last Post: 2008-09-08, 08:09
  5. HELP: Mutable Image to Immutable Image?
    By rj_cybersilver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-03-26, 09:58

Posting Permissions

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