Is it possible to draw the camera in just a portion of the SurfaceView?
or draw different things on the same SurfaceView?
What do you want to achieve by that? You cannot send the camera preview to a portion of a SurfaceView, but you can adjust the size of this View, and put other views around it or even on top of it. The latter is an alternative to drawing different things on the same SurfaceView.
Related
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
I want to achieve this kind of feature.
My initial camera preview:
Now I want to break this camera preview in two parts:
What I have tried:
Create a surface view to hold preview of camera.[Done]
Shift half of the surface view out off the screen[Done] now half of the surface view shift from out off the screen and only half is visible.
The problem is camera writes it's complete preview only on visible portion of surface view so the preview gets shrink in half of the screen.
Can anybody help me how can I achieve this?
Send the camera preview to a SurfaceTexture, then draw two rects with GLES, one with the left part of the preview, one with the right. Use a single SurfaceView for display.
You can find sample code in Grafika's "texture from Camera" Activity, which manipulates the camera output in various ways. Note in particular the "zoom" feature works by displaying a progressively smaller area of the preview while keeping the output rect the same size.
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).
I want to make an application that shows a camera preview on a surface view. the SurfaceView fills the screen, but I want to show the preview only on a certain position of the screen, in a smaller square. I want to draw other things later on the surfaceview too, around the preview. My problem is that the preview fills the whole surfaceview. Is there a way to resolve this problem? I read that I can't use more than one SurfaceView at the same time to separate the preview and the drawing.
Thank you for your help!
I want to draw some thing on the view which we get when our camera is on in android mobile.
I do not want to take picture nor record video just that view from camera and then draw some thing on screen.
Drawing on screen will not be and issue but when we turn on camera which view we get and how can we use that view in our application?
You'll want to check androids camera-API.
You can get the preview to display in a SurfaceView or your own View-subclass, which can then be used to draw on. Some more knowledge might be found here.
You can use a RelativeLayout to put other views aligned with the surfaceView used for camera preview