I want to take a picture of a rectangle shaped object. If the camera preview have a bounding rectangle i can take the picture by placing the object inside the bounding box. I need only that specified(inside the box) area of the image.Now I have developed a Camera App(Using Camera API Not INTENT) which can take pictures and store the pic like the inbuilt camera App.
How to draw a rectangle on the camera preview? and how to crop before saving?
I am using android 2.2
You have to add an camera overlay to achieve this. Take a look at the Samples at samples/ApiDemos/src/com/example/android/apis/graphics/CameraPreview. You can have your own layout over the preview area and add your graphic to it.
Check: http://android-er.blogspot.in/2010/12/add-overlay-on-camera-preview.html
and Android: Crop an Image after Taking it With Camera with a Fixed Aspect Ratio for more samples.
Related
Is it possible to show a rectangle in the camera that captures the image only the rectangular part of the camera and skips all other parts?
I don't want to use any third-party library. I want to use simple CameraX.
You can take a picture of the whole FOV then crop it.
The challenge is that the Preview and ImageCapture usually have different resolution, rotation and mirroring. To do that, you will need to transform your Preview crop rect into ImageCapture coordinate system.
You can take a look at the CoordinateTransform API provided by CameraX.
I want to open the camera with a rectangle border over it. And capture only the rectangle area image. The rectangle border can resize as per the user's choice.
Tried with many SO link but still no answer.
Below is the SO link that I want to achieve.
Display a rectangular bounding box (overlay) on custom Camera2 API so only the image inside the box is captured
I want to display a camera preview in a circular shape using the camera2 api. I want to display the preview in a circular shape, but I dont't want the image to be captured in a circular shape.
The captured image would be a face( later want to implement face detection and auto capture). I did have a look at few questions already asked, but none of them are with the new camera2 api's and most of them talk about having an overlay image cropped with a transparent circle. But this will not work in a case where I need to auto detect a face(as the face may appear out side the cropped circular image).
Is there any way I can implement this ? I did try an example with TextureView and set it to a LinearLayout with fixed width and height, but the preview appeared a bit squeezed and in a square shape.
I don't see why face detection matters here - if you enable the camera API's face detector, it'll run on the full image no matter what you do in drawing it inside a circle.
You can either use a circle overlay on top of a correctly-shaped TextureView or SurfaceView, or do your own OpenGL rendering of a circle with the camera preview as a EGL texture.
The latter you'll probably want a GLSurfaceView for the OpenGL drawing context, and a SurfaceTexture to send camera data to and expose it as a EGL texture.
JPEGs captured will still be full-FOV, and the camera API will know nothing about your circular preview drawing, so face detection and everything else will work on the full field of view.
I am using a standard Android camera/surface area. I am not using the full screen, and have implemented the preview surface area with a height of 200dp. However, when I save the photo, it is saved as if the preview/surface area is the full screen.
Is there a way for me to save to a jpeg exactly what is displayed on the preview/surface area?
Some context for the question, I am using the camera to capture the text of a street sign, so I only need a very small image.
In my OCR applications I capture preview, and then extract subimages for further processing based on position of ROI ( determined by some surface overlay ).
See android demo code ( demos/ ) :
http://sourceforge.net/projects/javaocr/
I'm not aware of interface allowing ti capture only subimage
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