Cropping the Android camera - android

I'm developing an Android app that uses ZBar as a QR code library, and things are going sweet. Now, however, I'm building the interface for the app, and it requires that I show only a certain portion of the camera's feed at the bottom of the screen, something like this:
The camera view below should be full-sized, i.e. a cropped view and not a resized one. However setting the width and height of the FrameLayout has caused it to resize and squash the entire image into the tiny frame.
Is there a way to crop it? I know I could probably place an overlay over the original image, but how does one create a transparent square in the middle to display what I need?Besides, the QR reader would catch anything the camera captures, so if the user brought the QR code in front of the camera and it captured it "off screen" (by the part that's actually covered by the overlay), it would be extremely confusing.
So I guess what I'm saying is, I can't use an overlay to "crop" the picture. Is there any other way to do it?

As far my knowledge one cannot crop camera view but what you can do is re-size the frame and then capture the image.
Still i would suggest to refer this post

The first thought that comes to mind is to put your CameraPreview in a view inside a FrameLayout. Then add more views on top of the CameraPreview view to hide the parts that you do not want to be visible.
Or Perhaps just one view super-imposing the camera preview view with a PNG which covers everything with "cropped" area set as transparent.

Related

How to change transparency of an imageview in certain area?

I'm trying to make a page of cropping profile picture. I have a crop frame which you can drag along. The image is transparent, or blurred, but within the frame, it is clear. The area within the frame will be your profile picture. I know how to set alpha, but I haven't come up with a way to set alpha within the crop frame. So this is the effect I want:
Any help would be great. Thanks!
You should probably think about having two ImageViews. One rectangular for the blurred photo and one circular placed on top of the first one for the crop preview.
When user selects a photo, you would create the blurred copy. It seems you already know how to move the photo within the ImageWiew, and so doing couple of calculations with the widths and heights of the ImageViews and the photo, should give you the correct positioning of the photos in both of the ImageViews to make them align.
Lastly when dragging on either of the ImageViews, adjust the position of the photo in both ImageViews.
This looks promising for circular ImageViews
ImageView in circular through xml
This might have something for efficient image blurring How to blur background images in Android
If you want a different approach, using OpenGL ES, you might be able to achieve realtime blurring outside of the circle with a pixel shader Shader for Android OpenGL ES. Possibly a more elegant solution, but probably not as simple.
I'm not exactly sure if you want blurring or transparency, but the solution will be very similar.

Using default camera application in Android Fragment

I have a fragment which takes up the whole screen. Within this fragment I would like to enable the camera feature using the default camera application, rather than create a custom camera. I only want the camera to take up half the screen, below which I have buttons and other text. How can I do this?
You have to make Custom Camera. As If you use Intent for Camera then you will get a full screen by default. You cannot use it. You want something like facebook uses in Messenger. Try this. This camera is in a Fragment. Replace the Fragment where required. Divide device height of surface view and fragment view.
https://github.com/googlesamples/android-Camera2Basic
Try this sample.You can use default camera app,
http://www.androidhive.info/2013/09/android-working-with-camera-api/
Default android cam app will take full screen cant use half screen for taking images.
For this half screen with cam view and half with your widgets you have to create your own cam view you can use this open source library for this.

How to retrieve the visible part of a SurfaceView in Android

I have a layout where the top part is used to display some data (eg. simple UI widgets) and the bottom part has a SurfaceView where I display a CameraPreview.
In order for this SurfaceView to extend the whole width of the screen and at the same time maintain a correct aspect ratio, the SurfaceView actually goes offscreen which is fine since I actually want the app to be divided evenly between the top part and the bottom part.
The problem is that I now want to retrieve only the visible part of the SurfaceView (ideally as a bitmap) but if I try to do it by setting a PictureCallBack, the aspect ratios of the picture data returned are just not quite the same as the ones shown in the SurfaceView (I've tried with all of the available getSupportedPictureSizes).
Any ideas how to tackle this problem? I've attached an image which better illustrates this problem.
https://code.google.com/p/zxing/downloads/list
it contains a barcode scanner project in that they have used a rectangle and capture particular area from the surfaceview it will be useful for u .. Hope so they use viewFinderView class to capture the area from the surface

screen shot of a specific screen area in android

I was trying to take screen shot of a specific area of a Android screen programatically, i can take screen shot of a particular view, but is there any way to capture a specific area of a screen or view. I was trying with Surface view and want to capture specific co-ordinates.
Thanks
is there any way to capture a specific area of a screen or view
Capture something larger, then cut out the "specific area" into a separate Bitmap, probably using one of the createBitmap() methods.

how to create a box at the bottom right of my application that runs the android camera

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.

Categories

Resources