Set rect focus in camera android - java

I am doing an Android application that uses camera. I want that camera focuses in faces. My dude is: Nexus 5 front camera only has "Fixed" in focus mode. Is there some way to use setRect areas or something like that.
I try to use facedetectionlistener and runs ok but when i also add a previewcallback to do some process stops running. (Issue with preview callback [ANDROID])
Thanks

You might want to take a look at Camera.Parameters. It has setFocusArea and setAutoFocus functions.
Check this one

Related

Android camera won't stop autofocusing

I am setting the focus mode to FocusModeAuto and then set the camera parameters.
Then I call Camera.AutoFocus(), get the result from the callback and start recording with a MediaRecorder.
The problem is that the camera keeps auto focusing on its own as if its in mode FocusModeContinuousVideo or FocusModeContinuousPicture.
I am having this issue on a LG K20 V phone, but I don't have this issue on older phones.
I tried setting the focus mode to FocusModeFixed after I get the focus I want to try and lock it in place, but that mode makes it jump the focus to a far distance and not the distance I auto focused to with my previous calls.
How can I lock the focus to the auto focus I previously obtained or set the focus directly so that I can have full control of it?
Also while it does the auto focuses I didn't request. The OnAutoFocus() callback is not being called.

How to use front and back camera at the same time?

I want to use both front and back cameras at the same time. I have used two surface views. I have tried to implement the code in following answer.
https://stackoverflow.com/a/24238301/6874315
The problem is that the camera API is now deprecated and the code was too old. I tried using the Camera 2 API in the same way but the camera instance won't open and i get a blank white screen.
I get the following two errors:
Camera 0 not available! java.lang.RuntimeException: Fail to connect to camera service
Camera 1 not available! java.lang.RuntimeException: Fail to connect to camera service
What i wanna do is capture picture from front and back camera simultaneously on a button click. But i'm not able to open both front and back cameras at the same time.
Is there anything that I do to use both cameras at same time?
Take a look at these answers:
https://stackoverflow.com/a/30444841/11338123
https://stackoverflow.com/a/52075569/11338123
I think it is possible in some devices and it is impossible in others
I don't sure that it is possible to use both cameras simultaneously. But, you could switching between two cameras like in this sample for short time interval.
Also you can modify you program to process camera images in the background thread in such way to avoid GUI freezing.
So, you may try to make a little changes in the sample to get front and back camera instances for testing your idea. Good luck!

Rotate whole android layout

Is it possoble to rotate the whole android userinterface on an eventlistener ?
For example an app which runs in the background and after putting the headphones in the whole interface turn 180° until you put it out again.
Yes it is possible to change layout programmatically (Although not sure about 180 degrees?).
See this link: Change Screen Orientation programmatically using a Button
The first answer he has explained how to change layout programmatically instead of setOnClickListner you can use your eventListener.
EDIT: Look at this:
https://developer.android.com/reference/android/content/Intent.html#ACTION_HEADSET_PLUG
Its the broadcast which takes place in the event a headset was plugged in.

Xamarin Android UI Update too slow

I'm developing an Android App with Xamarin.Android and try to update a View about 50 times per second. I used the RelativeLayout.LayoutParams to change the Margin of the View, so that it is moving around depending on the accelerometer values. Unfortunately this does not work well, because it seems like android does not redraw fast enought. Is there an alternative for LayoutParams, or how can I force Android to redraw my View faster?
The View is only a small ImageView. It should not be a lot of work to draw it to it's new position. So I don't know why this is a problem for Android.
Thanks in advance!
Ok, it seems like the problem was not the android performance. Had some thread based mistakes in my code. Sorry for that. By the way I like to tell you what the solution was.
I wrote a new class extending RelativeLayout and override the onDraw() Method. This class wrapped my other stuff which is needed for calculation and movement. To move the View I also had to call postInvalidate() Method.
Thanks!

Issue with my app after Android 5.0.1 update. "SurfaceView" turns into transparent mode

I use SlideMenu in my app. “Menu” in one fragment and “SurfaceView” in another. When opening “Menu”, preview disappears during camera movement and SurfaceView turns into transparent mode.
Using setZOrderOnTop(true) - SurfaceView doesn’t disappear, but overlaps a lot of elements, that should be over it.
Untill Android 5.0.1 update everything was fine.
Can you give me an advice?
Comment out the hardware acceleration in the manageLayers method of SlidingMenu. This seems to be the only solution since SurfaceViews don't work.
com.jeremyfeinstein.slidingmenu.lib.SlidingMenu
Edit function manageLayers:
//final int layerType = layer ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;
final int layerType = View.LAYER_TYPE_NONE;

Categories

Resources