I want to take a picture with my app, but I want to run the camera inside a fragment in a frame. Is it possible to accomplish that?
Any help appreciated..
It is Possible to Write your Own Camera Module using SurfaceView see the Android Documentation
for Building a Camera App, Example
If you want to add a frame to the picture taken, you must post-process the captured image, whatever method you choose - be it via intent, or Camera.takePicture().
If you want the preview to appear inside a rectangular frame, you simply create an xml layout to your liking, frame included, and a surfaceView positioned where you need it.
If your frame has some curls or curves on the inside, your preview surface should be z-ordered under this frame (which will include transparent areas).
Related
I am using camera2 in a Texture View. I wish to add some kind of image or text on top of the live camera. for eg. the way snapchat adds the time or speed on top of the live View.
when i click a picture i want to capture the live camera image as well as the text or imageview on top of the camera.
I cannot seem to find any reference online
In theory if the base layout is a FrameLayout and then set the texture preview on the view with an index of 0, the rest of the components added after should now be on top.
i am a beginner on android.
My question is simple, i need to capture a video frame from my device but i need to capture just a part of the entire camera view. For example, if my camera view display my frame on the entire screen i need to cut half frame to display.
I did this with opencv through image processing (image cropping) but i wanna know if this is possible also specifing the layout parameters. I need know if this is possible because i working with a video frame not with simple image and i need to ease the entire processing.
Thank you for all advices.
i want to crop a image during capture not after capture.
like this image.
just replace save button with capture.
the rectangle should be realizable.just like the crop activity.
the thing i was doing was.
1st=capture image.
2nd=crop.
now i want to crop image during capture.
any help???
This is possible, Just think a different approach. Make a trick with camera preview. Taking a picture usually requires that your users see a preview of their subject before clicking the shutter. To do so, you can use a SurfaceView to draw previews of what the camera sensor is picking up. Now create a viewFinder for your camera capture activity. Now your make the compatible code to change the viewFinder size dynamically, which allow you to select the region. And finally save the Image from bitmap view inside ViewFinder. This is exactly what you want.
Please ask if you have not got my point. Best of luck.
My app is showing the camera preview on one of my activities. I would like to show the camera preview but not taking the full screen, just inside a small box.
The problem is that right now the image that i get from the camera is smaller that I want. For example, when I open it I can only see there my eyes and nose, but I would like to see my whole face.
It's like my surfeceView is acting like a window in a house that only allows me to see part of the views outside. The idea is that in the surfaceView (that does not take the whole screen space) I get the whole camera output but resized in order to fit the surfaceView.
Is that a problem with the camera preview size? Or should I somehow resize the camera output?
Thanks in advance
You should give us some code to find the problem, at least the layout.xml file and the class that uses SurfaceView and SurfaceHolder.Callbacks. For now, you can try the following if you didn't.
In the onSurfaceChanged method use the two int parameters width and height to calculate the best size for your preview. You do this with setPreviewSize and getSupportedPreviewSize.
If you can't fix the issue in an easy way you can also try to use an ImageView or a TextureView and paint on them the image that you are given from the onPreviewFrame callback.
I need a little help with getting my camera to work right.
What I'm trying to do is have the user take a picture that will then be used in another activity as the view's background. It is important not to have any skewing, and ideally the image would fill the entire background with the highest resolution possible.
I've been having a heck of a time trying to get the outputted picture of my camera to be oriented properly and be the same aspect of the display. So I took some time to think of exactly what I needed to do, and I don't think I need the normal saved image at all.
What I came up with is that I need a surface view to display the preview, and an overlay for some text and a capture button. When the user "takes the picture" it should autofocus, and then I need to capture the preview (under the screen overlays) to a bitmap to use in the other activity.
*Should I extend a SurfaceView for my preview and add it to a XML layout that contains the overlays?
*How do I save the SurfaceView's image to a bitmap?
Thanks.
Matt,
One basic question ,and excuse my naivety, wouldnt it just be easier to use the built in camera to the Android through an Intent? It is doable, I've done it before.
Apparently, there is no good way to convert the image format of the preview frames to a jpeg, so I ended up selecting the size for the camera to take by going through each of the camera's supported resolutions and getting the closest match the the screen aspect with the highest resolution.
Because the camera.setRotation method doesn't seem to do anything, I just rotate the image 90 with a matrix before saving it to the card if I am in portrait mode.