Re: [londroid] Android NDK & Image processing

From: David C.
Sent on: Tuesday, March 20, 2012 3:58 PM
Hi Neil,

If you go the NDK route, you may find this tutorial (and its second part) usefulĀ http://imrannazar.com/Augmented-Reality-with-the-Android-NDK:-Part-1

Renderscript should be much faster than processing in Java. This article on levels gives an example of processing with Renderscrip: http://android-developers.blogspot.co.uk/2012/01/levels-in-renderscript.html

I don't know whether Renderscript will be faster than OpenGL or not.

Dave


On 19 March[masked]:55, Gianluca Cancelmi <[address removed]> wrote:
Hi Neil,

the trick to get speed is to use the GLSL (ES) shaders to manipulate the image.

The NDK won't give you any real advantage in terms of speed as the GPU will be processing pixels anyway.

To manipulate the image pixels with a shader you need to copy the camera feed into a texture somehow.
On android >= 3.0 there is a function to get the camera image directly as an opengl texture.
Check:
http://developer.android.com/reference/android/hardware/Camera.html#setPreviewTexture(android.graphics.SurfaceTexture)
for more info.

On android < 3.0 it gets more complicated as you need to create and upload the texture yourself and convert the image from YUV to RGB using a shader (something like http://www.mdk.org.pl/2007/11/17/gl-colorspace-conversions).

Once you have the camera feed in a texture you can manipulate the pixels in the fragment shader using texture2D.

Hope it helps,

Gianluca


On 19/03/12 19:16, Neil Glenister wrote:
Hi all,


I've been pulling my hair out over some problems with an image processing app and wondered if any of you would be able to help/give advice...

The app essentially takes the live camera feed and applies a simple filter to it (e.g. yellow tint). The problem is that it runs far too slow. The app MUST run without any lag at all for it to be usable.

I've been told that the only viable option is to use the NDK (based on info from tight lipped companies who have achieved this) which I have tried and so far I haven't managed to get it to work. What I'm currently trying to do is push the two intensive parts through the NDK:

1/ Converting the camera image format from YUV to RGB
2/ Applying the filters

The filters and YUV>RGB is readily available in Java so it's "simply" a case of porting it to the NDK. I've tried http://nhenze.net/?p=253 but it doesn't work and I can't get a hold of the developer.

I guess my questions are:

a) Has anyone ever used the NDK with image processing?
b) Is there another way that's been tested and proven?

Thanks a lot in advance for any feedback!


Neil

-----------------------------------------------------
Neil Glenister
Technical Creative & MD
-----------------------------------------------------
232
              Studios Ltd
Viral Media | Games | Apps | Interactive

118 Cavendish Road, London, SW12 0DE
M:[masked] | T:[masked]
Follow us: @232studios

-----------------------------------------------------





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Neil Glenister ([address removed]) from The London Android Group - Londroid.
To learn more about Neil Glenister, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Gianluca Cancelmi ([address removed]) from The London Android Group - Londroid.
To learn more about Gianluca Cancelmi, visit his/her member profile

Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]

Our Sponsors

  • Novoda

    Organising speakers, dates, attendees and advocating attendance.

  • SkillsMatter

    Offers use of their meeting areas and recording facilities

  • Google

    Offering Pizza & Beer to attendees at key events.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy