Is it possible to display two camera previews in same activity? We have two camera previews. One is placed top half of the activity window and other is placed in the bottom half of the activity window. Back camera preview is at the top and front camera preview is at the bottom.
Need to open only one camera at a time.
If it is possible how we can avoid the stretching of a specific sized camera preview? For eg. camera preview with size 200 x 200.
Related
I used this library https://github.com/pedrovgs/DraggablePanel and I have a youtube fragment at top side, a camera preview (inside a fragment) at bottom side.
I want my camera preview show only half bottom part of camera (I don't take pictures, I just preview the bottom part of the front camera is like a mirror)
How do I crop my camera preview? Thank you all the help!
I've tried set SurfaceView height=screenwidth and parentView height=my_height but my top fragment (youtube fragment) was displayed like a SurfaceView
set fix height (e.g. 200dp)to surfaceView and align it to the bottom of the parent(screen).
and set the camera preview size accordingly
Camera.Parameters params = camera.getParameters();
params.setPreviewSize(your_width,your_height);
camera.setParameters(params);
You cannot crop the camera preview image in a SurfaceView.
You can hide the upper half of a SurfaceView by simply overlaying it with some other view (normal XML layout feature). But be careful: SurfaceView does not behave exactly as a "real" view, and it does not always "play by the rules" of view hierarchy. Typically you can overcome these glitches by building the view hierarchy programmatically in onResume().
An alternative is to switch to TextureView, or use a SurfaceTexture directly and display it in an OpenGL context of your choice. In the latter case, you can partially overlay the camera preview texture with some other OpenGL object, e.g. display decoded video stream in the same OpenGL context.
For me adding enabling hardwareAccelerated in Manifest solved the problem of preview of CameraX coming in half portion although I set match_parent as height width of PreviewView
<activity
android:name=".ui.CameraActivity"
android:label="#string/camera"
android:hardwareAccelerated="true"/>
I have an activity with action bar, SurfaceView (fullScreen, Behind the action bar) and a capture button at the bottom of the screen but on the surfaceView.
in the SurfaceViewChange I'm scanning all the supported Picture Sizes and chosing the Highest, but when I'm putting the same values in the Preview the outcome is stretched and if I take a picture it look ok, If I'm using the device screen height and width for the preview than its not stretched but at the result picture there are thing that were off frame.
All I want is an activity that takes picture with the highest resolution supported and preview it fine and play around with the captured picture.
The activity is in portrait!
any ideas?
The aspect ratio of the SurfaceView needs to match the aspect ratio of the camera preview. You can do this with a custom FrameLayout class.
For an example, see AspectFrameLayout in Grafika. You can see it used in the "Show + capture camera" and "Continuous capture" activities. Note how it's used in the layouts. Once you have it set up, you make one call with the camera preview parameters to set the desired aspect ratio, and the layout adjusts to match.
I am trying to achieve a half screen camera preview similar to the one attached in the screen.
I tried nearly all camera preview examples, also tried my own but it either gets the SurfaceView resized to wrap preview sizes (so never half screen size) or it actually fits the half screen but the preview is stretched.
So, I have an application that uses a canvas and animated a moving block. What I would ultimately like to do is have the camera running capturing the user's face without showing the camera screen on the app or have a box at the bottom right of my screen that showing what the camera sees.
Is it possible to have a mini screen at the bottom right of my app that is displaying the camera or does the camera have to take the full screen?
Or if it is possible just to quickly snap a picture and display a bitmap without losing my application, that would be fine also.
Any help would be great!
Thanks.
Is it possible to have a mini screen at the bottom right of my app that is displaying the camera or does the camera have to take the full screen?
It is possible, See the 1st Screenshot here. Theirs is in top left instead of bottom right, but it should work just the same. In this Qik application the full screen shows the other person you are talking with, and the small box shows the live view from your camera.
I wouldn't know how they did that, but I imagine if you follow along with Building a Camera App in the docs it would get you most the way there. You just need to adjust the size of the preview canvas, and figure out how to use the front camera instead of back.
I am Using a onCLick over a button to capture an image but when we see the preview it is upside down in vertical mode where as when the same preview is seen through horizontal preview renders correctly.
Please let me know what tweaks are necessary to readjust the preview.
You have to take into account, that camera preview image origin is on top right corner if in portait mode, and axes are swapped - and it does not depend on phone orientation. You will have to flip image to display it in portrait mode properly.
take a look at
android.hardware.Camera.setDisplayOrientation
http://developer.android.com/reference/android/hardware/Camera.Parameters.html
and
android.hardware.Camera.Parameters.setRotation
http://developer.android.com/reference/android/hardware/Camera.html