android-camera

Flashlight control in Marshmallow

为君一笑 提交于 2019-12-20 18:28:21
问题 I have a problem regarding the camera in the most recent Marshmallow build, more specifically the flashlight. On any pre-Marshmallow version all I need to do to turn the flash on/off was the following: private void turnFlashOn(final Camera camera, int flashLightDurationMs) { if (!isFlashOn()) { final List<String> supportedFlashModes = camera.getParameters().getSupportedFlashModes(); if (supportedFlashModes != null && supportedFlashModes.contains(Camera.Parameters.FLASH_MODE_TORCH)) { mParams

Flashlight control in Marshmallow

谁都会走 提交于 2019-12-20 18:28:18
问题 I have a problem regarding the camera in the most recent Marshmallow build, more specifically the flashlight. On any pre-Marshmallow version all I need to do to turn the flash on/off was the following: private void turnFlashOn(final Camera camera, int flashLightDurationMs) { if (!isFlashOn()) { final List<String> supportedFlashModes = camera.getParameters().getSupportedFlashModes(); if (supportedFlashModes != null && supportedFlashModes.contains(Camera.Parameters.FLASH_MODE_TORCH)) { mParams

How to get id of front facing camera using Camera2?

自古美人都是妖i 提交于 2019-12-20 18:07:10
问题 How can I get id of front facing camera using new Camera2 library? I can't find it anywhere in documentation. 回答1: I have found solution, i could get camera characteristics by calling getCameraCharacteristics(cameraId); on CameraManager object. String getFrontFacingCameraId(CameraManager cManager){ for(final String cameraId : cManager.getCameraIdList()){ CameraCharacteristics characteristics = cManager.getCameraCharacteristics(cameraId); int cOrientation = characteristics.get

Enabling Camera Flash While Recording Video

送分小仙女□ 提交于 2019-12-20 16:24:32
问题 I need a way to control the camera flash on an Android device while it is recording video. I'm making a strobe light app, and taking videos with a flashing strobe light would result in the ability to record objects that are moving at high speeds, like a fan blade. The flash can only be enabled by starting a video preview and setting FLASH_MODE_TORCH in the camera's parameters. That would look like this: Camera c = Camera.open(); Camera.Parameters p = c.getParameters(); p.setFlashMode(Camera

Record, save and play a video in Android

牧云@^-^@ 提交于 2019-12-20 15:23:07
问题 I am trying to make an app that records a video using the camera app, and then saves that video on SD card so I can play it. I have some code but I'm lost on how to continue as I'm a beginner in Android. My Activity: public class Camcorder extends Activity { private CamcorderView camcorderView; private boolean recording = false; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //irrelevant code

Camera.open() blocking UI thread

淺唱寂寞╮ 提交于 2019-12-20 10:53:35
问题 I've looked at all the SO articles I could find on this but none of the solutions work for me. When called Camera.open(), there is a 3 second (give or take) delay where the UI thread is blocked. I have attempted to put that in a background thread. I'm currently using the solution found here (pasted below) but the 'wait' method is synchronous so it blocks the UI thread too. What I'm looking to do is load this fragment, show a progress spinner until the camera is good to go, then show the

Android Camera Preview Rotation

ε祈祈猫儿з 提交于 2019-12-20 10:06:29
问题 According to Android Developer Site: after android 2.2 there is the function " setDisplayOrientation " to adjust the camera preview rotation. And also according to the Android Developer Site , we can find following source code. android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); android.hardware.Camera.getCameraInfo(cameraId, info); int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); int degrees = 0 ; switch ( rotation ) { case Surface

Draw Rectangle on SurfaceView

一个人想着一个人 提交于 2019-12-20 09:24:28
问题 I would like to know how to draw a rectangle in specific position and size. I tried a couple of trials and examples here and on web, but nothing worked for me. I'm using a SurfaceView and SurfaceHolder to hold the camera preview. I just want to draw a rectangle when the user touch on the screen. I don't want to use external library and When I'm trying to get the canvas from the holder I'm getting null. For now there is no code, cause nothing work for me, if someone has a clue how to do it, I

ACTION_IMAGE_CAPTURE onActivityResult has empty intent with empty data

丶灬走出姿态 提交于 2019-12-20 08:04:34
问题 After reading this documentation https://developer.android.com/training/camera/photobasics I want to take a photo and to store the uri of the photo into a given variable. The problem is that I'm storing the variable name and the uri into the intent with takePictureIntent.putExtra(Constants.INTENT_EXTRA_VARNAME, variable) and takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI) , but in onActivityResult the intent data is empty, and neither the variable and the uri stored are empty. I

take photo from camera in service

时间秒杀一切 提交于 2019-12-20 07:25:48
问题 How can Take picture from front camera in service without showing camera on screen. I have service class public class PhotoTakingService extends Service { //Camera variables //a surface holder private SurfaceHolder sHolder; //a variable to control the camera private Camera mCamera; //the camera parameters private Parameters parameters; boolean mPreviewRunning = false; /** * Called when the activity is first created. */ @Override public void onCreate() { super.onCreate(); } @Override public