I am able to display an image using OpenGL ES in android ndk. now I want to display 2 or four images using multithreading in OPENGL ES through android ndk.
I have done huge search for this and came to know a Surfaceview can only have one picture. Then what is the way to display multiple pictures on GLSurface view..
Can anybody please tell me how it can be done..
Thanks in Advance
It seems there are several issues here.
First of all, if you are trying to display "pictures" through OpenGL(ES), you mean textures (OpenGL readable format for "pictures" or "image"), right ? If you are not sure of what I am talking about, find some tutorial about displaying images using OpenGLES. Learn how to display juste 1 and you will be able to display 4.
a Surfaceview can only have one picture
You may have misunderstand something. A GLSurfaceView can draw as many textures as your video memory can handle.
Basically, to display your textures, you will draw 2 or 4 quads and bind the appropriate textures to them.
About the multithreading, I guess you gather your pictures asynchronously. Just wait for a complete picture, and while in the OpenGL thread, create a texture and bind it to a quad.
Related
Say you have a 20 second video (perhaps taken with the device camera) and you want to add an overlay in to the video.
(The overlay would simply be a normal raster image, i.e. an Android Image (doc).)
You want to create a new video, with the overlay as part of the video image, and save the video.
In fact, can MediaCodec SDK be used to do this job?
https://developer.android.com/reference/android/media/MediaCodec
In the past, you would usually use FFMPEG for such a problem, but that is a mess and slow.
Is MediaCodec possible here?
Since it is "new" I just can't find any information on this.....
this is possible using MediaCodec.
For a start, take a look at the DecodeEditEncode example from here
This example is shows how to resize a vide using a OpenGL ES shader. What you want to do is render your overlay over the video also using a OpenGL ES shader.
Another good source for examples on MediaCodec can be found here
Here you can find some examples on how to use basic rendering techniques. Look at the Hardware scaler exerciser.
When you have the video part up and running, this is probably where the actual struggle starts since there are no standard methods to render text in OpenGl ES. I'd probably just draw text to a Canvas and make a texture out of it, probably is slow though.
If you have a static overlay, like a watermark, you could create it beforehand and ship as a resource.
i am using GLES 3 to create 3D textures and render data in surface view. Is it possible to read this data from the screen/texture some how.
You can read what you've rendered with glReadPixels(), but that tends to be slow.
Depending on what you're trying to do, you may get better results by rendering to an FBO.
You can find some example code in Grafika; see for example EglSurfaceBase#saveFrame().
I found this post, but it's too slow for a smooth live wallpaper. Is it possible to do the same with OpenGL, which should be faster?
It is definitely possible with OpenGL. You would load your two textures and then decide which to show on a per pixel basis using a fragment shader. The actual OpenGL part wont be too complicated as your are effectleiy just drawing a screen aligned quad. For an idea of how to write the shaders i'd look here.
As for which would be faster its hard to say, although i'd think OpengGL would be faster.
I would like to reconstruct 3d images from a set of dicom images. I hope you are aware of dicom images. I am planning to use OpenGLES for generating 3d view of images. Like I have a set of images as an image stack or image array. I want to generate 3d view of those images in android. The images are the output of ct scan or MRI scan. I am planning to use 2.3 or 3.0 of android. So my first question is, is it possible in android to generate a 3D view from an array of images? Can you give me some hints. I am new to android and OpenGL. Please help.
well. will not be an easy task, but, first of all you have to decide what donyou whant to do,,
3D volumerender needs lot of cpu power, but there are some android devices that can do it, also a lot of memory, and that would be a problem.
surface rendering is far less requiring and you can benefit from ogl. but today medical application is on the 3d volume rendering side...
there are open source libraries like ued on Osirix viewer (mac) and other linux implementations (ie VTK) ,, you sould go that way...
I'm currently looking into creating an app that takes a picture using the phone's camera. The app will be used for clients that are pre-op for breast augmentation. The user will be able to take a picture of themselves then place two shperes over the picture, then with a slidebar manipulate the size of the spheres. This will give the user an idea which cup size they would like. I understand that there is something in photoshop that has the desired effect and this is what i'm trying to replicate but on the bitmap image.
Are there any suitable libraries out there that i can use. I'm looking into OpenGL as that is for 3D graphics.
Any ideas and input would be appreciated.
thanks Mat.
Java does have it's own 2D and 3D APIs. Hopefully you can these to achieve your goal?