Blurring live camera preview with OpenGL 2.0 on Android - java

I have properly set up the Camera preview using SurfaceTexture and OpenGL.
After days of research with trial and error, I'm unable to blur the pixels, there seems to be very little documentation on this.
The desired effect is blurring and dimming the camera while opening DrawerLayout.
So far all the apps and guides that I've found blur a bitmap.
Can someone help me out or point me in the right direction?

You will have to use a fragment shader and apply your blurring filter over there. So for your use case you will have to keep one flag inside shader which determines whether blur has to be applied or not. Say when your drawer is about to open or starting to close you can set and unset that flag.
a simple google search will point you to many further readings on this topic.

Related

How To make Video Background transparent In ExoPlayer Android

I want to remove background color of video in exoplayer or make it transparent i.e if video background color is red then make it transparent and view behind exoplayer must be visible.
Note : I don't want to make changes in Exoplayer background only remove video background which is playing in ExoPlayer
I have made lots of search in google but unfortunate did't got right answer, Please let me know its possible or not and its possible using any other way please direct me.
Thanks in Advance
Exoplayer is not really designed to modify a video file like this while displaying it.
Given that the background may change from frame to frame, I suspect you may find it hard to find any solution that will be able to do this quickly enough on any regular Android device, as there will likely be quite a bit of video processing involved.
If your background is static, like the room behind the speaker in a Zoom or similar conference call, then it may be a bit easier and you could look at OpenCV background substitution techniques:
https://opencv24-python-tutorials.readthedocs.io/en/latest/py_tutorials/py_video/py_bg_subtraction/py_bg_subtraction.html
Most of the examples will be in Python so you will have to explore support in Android OpenCV, which is usually a subset and can be a little tricky to set up (check Q&A on SO for this). Android OpenCV also still uses Eclipse rather than Studio in the documentation at the time of writing, which is something to be aware of.
If you have the luxury of removing the background on the server side before you stream the video to the Android device then things will be easier and you should be able to find up to date example using Python and the OpenCV techniques linked above.
If you use case is a 'Greenscreen' background example, then ffmpeg can also provide you filters to change the background as you wish, including making it transparent. The documentation is here: https://ffmpeg.org/ffmpeg-filters.html#toc-chromakey
It includes an example to change the green screen to transparent in an image (png image in this example):
ffmpeg -i input.png -vf chromakey=green out.png

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.

Which resource qualifier to use for the android layout screen?

I am a beginner in android and is going to finish my first app, but encountering a problem that my screen layout does not fits all screen sizes,currently I have created different layouts for different screen sizes using 'size' resource qualifier. Should I use 'density' qualifier also along with size?
or ratio qualifier.I am having too much confusion. Please anybody reading this help me out.
My app will be focusing only mobile phones not any other device.
Please help.Thanks
use this android sdk from screen density pixel works for all the screen sizes with percentage of the screen ratio its a life saver
https://github.com/intuit/sdp

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

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 :)

Programming For Various Screen Sizes in Android

I'm using the Canvas and the SurfaceView. I've explicitly mentioned the coordinates for various objects and fonts on the screen. The app runs perfectly on Samsung Galaxy S Advance but the objects are out of scope on smaller screens such as that of Samsung Galaxy Fit or Pop. How do i make it compatible for all screen sizes and pixel densities.
Using dpis seems out of the question as I'm not using any xml layouts.
Thanks in advance.
I think you should get screen resolution at run time and set pixels according to that.
According to the developer guidelines it is discouraged to do so (work with explicit coordinates). Please refer to the android design guidelines for how to do it better. If you cannot avoid it, you'll need to take into account the screen size and density and compute your coordinates accordingly.

Categories

Resources