Small frontal camera preview (not fullscreen)? - android

is there a way to have a small camera preview inside a view? Not the classic fullscreen preview, I mean.
My idea is to create an app that allows the user to take pics of himself with the frontal camera, when it's dark.
Basically, I thought to put a small preview of the camera on the corner of the screen and setting the remaining part to full brightness (to use it like a "self flash").
Well, I don't have problems actually to set a view to a full brightness value, but I don't have any idea how to resize the frontal camera preview.
I hope you understood my intention...
Any help would appreciated!

I don't believe this idea will hold water, because the brightness of the screen may not be enough. But the technical question you ask is not very hard: you can put the ViewSurface for your preview in the main activity's xml with any size you choose (you can use the usual WISIWYG layout editor in ADS or AndroidStudio).

Related

Camera2 API preview aspect is broken

I am using the Camera2 API to setup an imagecapture fragment. I only want to use the camera in portrait mode. So i have set this line in the manifest in the fragment's parent activity:
android:screenOrientation="portrait"
Which locks the camera preview to portrait. However, the image aspect is just wrong. When the image is captured, there is no issues with the aspect, and the image looks as it should, but is still not in full screen. I suspect the camera output is stretched to fill the screen in my preview. How do i make both the preview and the captured image fill the entire screen and keep its aspect ratio like Snapchat does it?
I have been using the Google sample as my reference, and changed the AutoFitTextureView to match_parent in the XML layout file.
this is how it looks in normal portrait
and this is how it looks when i rotate the phone and is still in portrait mode
AutoFillTextureView attempts to keep the aspect ratio correct, but if you're changing its layout parameters, it may not be able to.
Do things work correctly if you don't make it 'match_parent'?
In general, Android UI elements will fill themselves with the input data, so you need to set the View's size to the right aspect ratio to avoid stretching.
For anyone who has been facing this issue like I was and if you have been using the google sample from before Jun 2017, then tweaking a line in your AutoFitTextureView should fix the preview's aspect ratio. It's as simple as changing "<" to ">" which you can see here.

Android Camera Preview not Full Screen

I am developing a camera app but the camera is not full screen. I am using common "CameraPreview" class to open camera. it includes Surfaceview and Determining Optimal Size for camera. In tablet and phones, camera is not full screen. For example, tablet size is 1280x728 but camera size is 1024x768. It is shown in FrameLayout for which layout widht and height is FillParent. I could not understand and solve this issue. I wanna open camera in full screen without stretching.
Is there anybody got this issue and fix it?
Judging by the code here:(which you can use actually), you can use the method getSupportedPreviewSizes() and see what are the supported resolutions, 1024x768 could easily be the highest one available for this preview and as you found out, it is really the highest supported.
So those are the supported resolutions, there's no way you can get higher than the supported. You must find a workaround for this, like to put the preview in the center and surrond it with black frame or something like that.

Cropping the Android camera

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.

Overriding android default camera/activities

I have requirement where in I have to overlay a header and footer over the camera. There is a set of three button which will handle the even of camera like (click/retake).
As of now i create a surface to use as preview and add jpegcallback and picture callback to take picture and store it. I manually handle android camera hardware and parameter configuration. As all of us know there has issues around camera and picture orientation. I have worked around this by setting camera orientation and also by rotating my captured image. Though the approach looks ugly i am able to achieve the end goal.
It would be great if we have a way of overriding the android default camera activity as any of the above steps are not required. I come from a Java/Java EE background and as per my understanding we should be able to create a custom Activity and override the behaviors and properties.
My Question:
Can we override the activities for android.provider.MediaStore.ACTION_IMAGE_CAPTURE and also com.android.camera.action.CROP.
If so which package of android has the java class for this activities.
Hopefully I am not misunderstanding your question but it sounds like you want to use the camera in your app. You want to view what the camera is seeing while having a header and footer above and below the camera preview. Then you want these buttons to do things like take a picture, etc.
If I am wrong I apologize.
Just look at the Camera implementation in the docs.
http://developer.android.com/guide/topics/media/camera.html#custom-camera
You can create your own activity layout with any buttons/text above, below, or on top of a preview view that you use to display the camera feed. Then just use the on click events for the buttons or whatever to do the things you want. Majority of this is in the documentation in the link.

Programmatically make wallpaper fit each screen and not scroll

I want to programmatically set a wallpaper to be an exact fit of the current screen.
Android fits the image to scroll as you change windows by defalt and so you never see the whole image on any one screen.
Applications like Wallpaper Wizardrii perform the function of setting the image to a single screen for the user, but I have never seen an answer on any forum that suggests how this is done.
Can any Android guru out there help - this problem has been doing my head in for nearly a week now!
You need to write a Live Wallpaper so you can render your image to the screen exactly how you want. If you just set a static image, the launcher app (or anything else showing the wallpaper) will be free to adjust it and resize and scroll. By writing a live wallpaper, you get to receive the requests from launcher about what it wants to happen to the wallpaper, and follow or ignore them as you want.
Also conceptually "make the wallpaper an exact fit for the current screen" is not even possible, because there is only one wallpaper, but two orientations (landscape and portrait) it can be shown in. That one wallpaper just fundamentally can't exactly fit both orientations.

Categories

Resources