How to open camera with GLSurfaceView.Renderer - android

I'm trying to build a camera view as background.
I want to load my camera inside GLSurfaceView.Renderer class.
My class:
public class ModelRenderer implements GLSurfaceView.Renderer {
...
My question is, is it possible to load camera preview as background in GLSurfaceView.Renderer?
I'm using Android studio.

Well It isn't really adding the preview as a "background" but you certainly can draw the camera preview to the GLSurfaceView and attach a renderer to the surface to do the drawing. There are numerous examples of doing so. I would search around for them but I believe Grafika has what you are looking for.

Related

Draw Here MapsView into a GLSurfaceView

I got a problem with drawing a mapView from the here-api into a glSurfaceView (it should be a glSurfaceView as some external devices requeres it to ensure good performance).
The map draws into a normal SurfaceView just perfectly.
I do the following steps to create the map-view in the GLSurfaceView:
Extend my view from GLSurfaceView:
public class MapView extends GLSurfaceView
Setting the Renderer uppon initialisation in the ctors:
setRenderer(...)
Start rendering after the map has been initialized:
Renderer renderer = new MapOffScreenRenderer(getContext());
renderer.setMap(map); //mapView, not null
updateRendererSize(); //update the render size to the screen size
renderer.start(getHolder(), surfaceUpdatedListener); // HERE COMES THE CRASH
It seems like the MapOffscreenRenderer crashes if i try to tell him to draw the map into the glSurfaceView.
The crash is a generic error: "12291 EGL_BAD_ALLOC during rendering".
If i try to call the renderer.start() func (without the holder param), then everything is fine (the only bad thing is that the map is not being drawn).
The GlSurceView initialisation itself is fine as i am able to draw my own geometries into it.
Thank you very much for you help.
MapOffScreenRenderer internally uses a PBuffer backed surface and its own rendering thread and EGL context. It is not intended to be used to push into another GLSurfaceView surface. If you really want to do this then maybe create an independent OpenGL surface and share it between the GLSurfaceView and the MapOffScreenRenderer.
What use case are you try to accomplish using this type of design?

Android Camera Live Filter

What is the best way for Camera Live filters. I am recently using GPUImage Library from Link: https://github.com/CyberAgent/android-gpuimagelibrary.
Than I have found SurfaceView and GLSurfaceView.
Problem is:
How to apply live filter to camera using SurfaceView or GLSurfaceView.
Thanks in advance.
This link uses Texture View
https://github.com/google/grafika/blob/master/app/src/main/java/com/android/grafika/LiveCameraActivity.java
This uses surface view to play a movie..u can manipulate it for live camera
https://github.com/google/grafika/blob/master/app/src/main/java/com/android/grafika/PlayMovieSurfaceActivity.java
To choose on whether to use surfaceView or GLSurfaceView
take a look at this
Difference between SurfaceView and GLSurfaceView in Android

Android GLSurfaceView stuck

I use GLSurfaceView to show the camera's dataļ¼Œbut if I put camera static for a few minutes and then move it, the GLSurfaceView will not preview any more and stuck,but onDrawFrame() still has response.However if I change the program that GLES20 used, GLSurfaceView work well soon.I don't know where the problem is.Thank for help!

how to display yuv in android

In a camera preview function, I've been using yuv2rgb, and using the resulting bitmap.
This is slow, so I want to display the picture as it is.
I use example class
// public abstract class ViewBase extends SurfaceView implements
SurfaceHolder.Callback, Runnable{}
Not sure why you want to render the preview frames yourself, given that the OS already has optimized flow for the preview frame from the camera driver to the video driver.
However, if you need to do it yourself, you can use OpenGL to create a YUV texture and then blit it to a plane. Check this SO question for sample code.

How to Use Camera and SurfaceView in Background

iam currently using camera and surfaceview in my app to use Torch etc ... , im using these in an Activity ,
How to use Camera and SurfaceView in Background , ex . : I want to keep Torch/Led Flash On , i saw many Widget that work fine in Background , how they do it ?
Thanks .
Take a look here:
http://developer.android.com/guide/topics/media/camera.html
There is all the code you need to make an activity which shows the camera preview.
As the Camera API:
http://developer.android.com/reference/android/hardware/Camera.html#setPreviewDisplay%28android.view.SurfaceHolder%29
specifies...you need to use a SurfaceHolder for your preview. Thus you can only use a SurfaceView or a derived class for your automatic preview. Otherwise you can use for example a TextureView or an ImageView to draw your preview by yourself. You'll need though to implement the onFramePreview method to grab the frames from the preview and handle them by yourself. By using OpenGL or the ANI API you can also add effects to your frame. This is the only way, I know about, to also add effects directly on your preview, unless these effects can be achieved by overlaying a semi-transparent colored surface above your preview image.

Categories

Resources