Management with RenderScrip - android

I would like to handle the frame from YUV to RGB using the ScriptIntrinsecYUVtoRGB in the method ImageReader.OnImageAvailableListener().
It can be done? Until now I have done so:
I remaining with image white and the preview does not start anymore.
Suggestions?

You're not adding your TextureView surface to the capture session or the capture request anymore. Only the ImageReader Surface is being added to the outputSurfaces list and to captureRequestBuilder.addTarget().
So the camera is not drawing anything to the TextureView. Add it back in to both.

Related

Android custom camera scope (TextureView)

I have a fragment in which I'm using a TextureView, and I'm using the following link as a reference:
https://github.com/googlesamples/android-Camera2Basic
Is there a way to modify the scope of the camera to take a "landscape" (it's not really a landscape, just a different scope) picture, even though I'm on portrait mode?
I'm attaching a photo of what I'm trying to achieve. I have a round white frame, I want to the scope of the camera/TextureView to be in that frame, and I want to add a button that takes exactly what's in that frame (with rounded corners). Is that possible?
It is feasible.
You can use opengl to achieve it.
First, draw camera frame to a external gl texture, then draw the frame in the gl texture to the screen.
Crop the frame during the process of drawing to screen with modifying the texture coordinate and you will get your effect.
the way is here:
Crop video before encoding with MediaCodec for Grafika's "Continuous Capture" Activity
And the round corner effect can be also implement through modifying the texture coordinate. the way is here:
How to make TextureView play video with round corners and bubble effect

Clearing last frame preview on TextureView

I've displayed a camera stream using TextureView. When switching camera (stopPreview() called before switching), front-to-back or vice-versa, the view paused at the last frame drawn on the TextureView. I want to display a blank screen while the "switching" is happening. How can I achieve it?
The easiest solution is to define a black view that overlays your camera preview surface. Set it's visibility "gone" while camera preview is working, and "visible" when you stopPreview and until the switch is over. With the deprecated camera API you can use setPreviewCallbackOnce() to get the indication that it's time to hide the overlay again.

GLSurfaceView camera preview is scrambled after resize

I use a GLSurfaceView to render camera preview output whilst simultaneously encoding it with the MediaCodec.
At some point, I want to resize the GLSurfaceView to show a larger camera preview. I do this by pausing the camera preview, applying new layout params to the GLSurfaceView and then restarting the camera preview.
The GLSurfaceView resizes successfully but the preview inside is the same size as before. The rest of the GLSurfaceView is filled with scrambled data (see attached image).
For anyone who find this, I never did manage to resolve my issue.
I had to tear down the whole view, camera and encoder and rebuild everything.

capturing image of multiple surfaceviews

I have two surfaces views in a frame layout, which also contains a linear layout with some buttons. One of the buttons should be able to capture and save an image of the two surfaceviews. One surfaceview is a camera preview and the other is an opengl surface with a square in it. How would you go about taking the picture and saving it?
You can't read data back from a SurfaceView Surface. See e.g. this answer.
The way that you "capture" it is by rendering it to something you can read the pixels from. In your case, you'd grab a frame from the camera, render that to an offscreen pbuffer, then render the square with OpenGL ES onto the same pbuffer, and then grab that with glReadPixels(). Essentially you perform the Surface composition yourself.

Crop camera preview

I want to run android camera preview with a 640x480 resolution but display just 480x360. Right now I'm getting a stretched preview, even though I've tried to put the surface view in a frame layout or srollview. Can anyone tell me how this can be done?
A similar question has been asked before: How to crop camera preview?, but nobody answered.
Thanks
This can be achieved by using TextureView for camera preview. See https://developer.android.com/reference/android/view/TextureView.html.
Unlike SurfaceView, TextureView does not create a separate window but behaves as a regular View. This key difference allows a TextureView to be moved, transformed, animated, etc. For instance, you can make a TextureView semi-translucent by calling myView.setAlpha(0.5f).

Categories

Resources