Can you display the real-time output of the device's camera? - java

I am wondering if it is possible to show the output of the camera running on your device immediately on the screen. Just like the native camera app does.
I have to show the picture, that comes into the camera lens, and additionally add some graphics overlays. That's why I guess, starting an Intent to open the camera activity is not suitable.
I've found some SO Threads, Tutorials and documentation about using the Android Camera API, but they are all able to just take a picture and display it afterwards.
Is it possible at all?

Refer to this link Camera Tutorial for Android (using surfaceview)!
Use the SurfaceView to preview the camera output, then, you can add your graphics overlays as you wish.
Hope this helps :)

Related

How add mirror effect in camera preview screen using open camera android

I want to add mirror effect in live camera preview screen.im using open camera library.can anyone help me to achieve this I'm stuck last couple of days.

Set Rotation based on device sensor overriding rotation lock

I have been trying to use the ML Kit Vision Quickstart Sample App to develop a blink detection app.
For this, I have been using the Face Detector module with the CameraX library.
On installing the sample app on my Android phone, I found that rotating the device with Screen Rotation locked makes the app unable to detect faces, as expected.
I want to know how I should modify the code to override the Screen Rotation lock on the device, so that the app automatically rotates its orientation to detect faces.
To override the screen lock you may add the next tag to your target activity in the manifest:
android:screenOrientation="sensor"
Although this will only allow to rotate the activity regardless the screen lock. You still need to handle the orientation changes for the camera code. What I mean is that your camera lens is a fixed device and it doesn't rotate, therefore you need to handle image rotation by code.

Android inapp camera and video capture

I am trying to implement an in-app camera to my application, which will allow me to take either a still photo or a video, with the result being stored in a variable.
So basically the top tabs (HOME, GALLERY, CAMERA, EFFECTS) are all Fragments. Assuming we are currently on the "CAMERA" tab, inside this view you will have two further tabs at the bottom one for taking still shots and the other for video, the rest of the screen should be taken up by a camera interface showing the cameras view.
The Android developer documentation mainly talks about using androids built in camera and then saving the result in one of my own variables, which I dont want to do.
Resouces I have taken a look at
Android developer documentation
Random Google tutorials & stackoverflow
Android arsenal and 3rd party created libraries.
Material Camera looks good but as soon as I try and add its dependancy to my app, the build gradle throws an error, so that one doesn't work.
CWAC-Cam2 looks really complicated, I don't understand how to implement it.
This is the resource you couldn't find: Using Camera inside app
Basically for taking photo you'll need to access the camera resource through:
Camera.open()
Then create a class for showing the preview like the following:
public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback
For capturing you'll need a PictureCallback.
For video recording checkt the first source at the Capturing videos section; there you'll need a MediaRecorder.

How to avoid video stop when I scroll the screen using youtube API in an android app?

I'm building an app for Android using the YouTube API. The video is in a scroll widget, and when I scroll and the video goes up or down the screen, it stops. I want the video to continue even though isn't in the screen. How can I do that?
i went through the same problem, i open this question:
Android YouTube API video pause when rotate screen or hide player
see the comments to understand better. For the tests I did, the Youtube API knows when the player is not showing on the screen and just pause the video. As a workaround I changed my layout so that the player be fixed on the screen, just as is the official app from youtube.
I use this question as reference:
Scrolling Text Above Buttons, Buttons Fixed At Bottom

Capture Android screenshot without having the View

I have found a lot of examples like this:
how to Capture screen in android and covert it to image
I need to capture an screenshot of screen activity, but I'm developing an external library, so I can't get current activity of the application to get the View and then flush the bitmap into canvas. Is there another way to capture a screenshot?
If you are trying to save the image from Snapchat, you need to save the Bitmap in another way.
With a rooted phone you can access the apps storage and copy the image while the app shows it.
That way the app wont notice you took a "Screenshot" :)

Categories

Resources