Questions tagged [android-camera]

The Android framework includes support for various cameras and camera features available on devices, allowing you to capture pictures and videos in your applications.

The Android framework includes support for various cameras and camera features available on devices, allowing you to capture pictures and videos in your applications.

Official Android Camera documentation

To access the device camera, you must declare the CAMERA permission in your Android Manifest. Also be sure to include the manifest element to declare camera features used by your application. For example, if you use the camera and auto-focus feature, your Manifest should include the following:

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

The Android framework supports capturing images and video through the Camera API or camera Intent.

  • Camera This class is the primary API for controlling device cameras. This class is used to take pictures or videos when you are building a camera application.
  • SurfaceView This class is used to present a live camera preview to the user.
  • MediaRecorder This class is used to record video from the camera.
  • Intent An intent action type of MediaStore.ACTION_IMAGE_CAPTURE or MediaStore.ACTION_VIDEO_CAPTURE can be used to capture images or videos without directly using the Camera object.

The Camera class has been deprecated. It is recommend using the newer class camera2, which works on Android 5.0 (API level 21) or greater.

You can read more about camera2 on Android Official blog. For questions specifically related to camera2, use .

6513 questions
42
votes
5 answers

How to get the Correct orientation of the image selected from the Default Image gallery

I have gone through some of the links to get the correct image orientation of the image selected from the default image gallery to be worked standard in all devices the exif tag always returns 0. EXIF orientation tag value always 0 for image taken…
42
votes
2 answers

Ideas of Source of QualcommCameraHardware native_get_picture: MSM_CAM_IOCTL_GET_PICTURE Connection timed out error?

I am working on a library to make the Camera API easier for developers to consume. The Droid Incredible 2, in portrait mode, using the rear-facing camera, fails to take a picture. Specifically, I get this sequence in LogCat: 08-18 09:25:52.094:…
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
42
votes
20 answers

Rotate camera preview to Portrait Android OpenCV Camera

I am trying to use OpenCV 2.4.3.2 to create a camera app and do some opencv processing. I would like it to be able to have multiple UI orientations, not just Landscape. The problem is that when I change the orientation to portrait, the image comes…
Jameo
  • 4,507
  • 8
  • 40
  • 66
42
votes
4 answers

USB bulkTransfer between Android tablet and camera

I would like to exchange data/commands between a camera and an Android tablet device using the bulkTransfer function. I wrote this Activity, but the method bulkTransfer returns -1 (error status). Why does it return the error? public class…
cdr89
  • 958
  • 9
  • 18
41
votes
10 answers

Converting YUV->RGB(Image processing)->YUV during onPreviewFrame in android?

I am capturing image using SurfaceView and getting Yuv Raw preview data in public void onPreviewFrame4(byte[] data, Camera camera) I have to perform some image preprocessing in onPreviewFrame so i need to convert Yuv preview data to RGB data than…
Hitesh Patel
  • 2,868
  • 2
  • 33
  • 62
41
votes
5 answers

Android setFocusArea and Auto Focus

I've been battling with this feature for couple of days now... It seems, that camera is ignoring(?) focus areas that I've defined. Here is snippets of the code: Focusing: protected void focusOnTouch(MotionEvent event) { if (camera != null) { …
Martynas Jurkus
  • 9,231
  • 13
  • 59
  • 101
41
votes
4 answers

EXIF orientation tag value always 0 for image taken with portrait camera app android

I have a camera app in portrait mode which takes pictures from both front and back end cameras.I am saving the image in my sd card and try to find the corresponding exif value which gives 0 always.But i am getting the the expected exif orientation…
hacker
  • 8,919
  • 12
  • 62
  • 108
40
votes
3 answers

Can you launch the native Camera App from an Html 5 Web App?

I have a mobile website that allows users to upload photos using the file input type (Browse button). If possible, I would like to launch the Camera App of an Android device on click of the Browse button or any other HTML button. Is this…
shanabus
  • 12,989
  • 6
  • 52
  • 78
40
votes
2 answers

Android Camera Intent Saving Image Landscape When Taken Portrait

I have had a look around but there doesn't seem to be a solid answer/solution to the, very irritating, problem. I take a picture in portrait orientation and when I hit save/discard the buttons are in the correct orientation also. The problem is when…
StuStirling
  • 15,601
  • 23
  • 93
  • 150
40
votes
2 answers

How to capture and save an image using custom camera in Android?

How do I capture an image in custom camera and then save that image in android?
Vishnu
  • 1,029
  • 4
  • 14
  • 24
38
votes
8 answers

How to launch front camera with intent?

I'm using an intent to open the camera with the native application: Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Uri photoUri = Uri.fromFile(getOutputPhotoFile()); intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); …
Yaniv
  • 3,321
  • 8
  • 30
  • 45
38
votes
5 answers

Enable rear camera with HTML5

I'm working on a project with MVC ASP.Net 4 HTML5 (default browser is google-chrome v29.0.1547.57) I can interact with these tools and take photographs but only with front camera, How I could enable rear camera? the characteristic of the Tablet:…
raranibar
  • 1,247
  • 4
  • 23
  • 44
37
votes
4 answers

Widget for turning on/off camera flashlight in android

I am developing a widget for turning on/off camera led of phone. I have made a widget that can work like toggle button (on/off). Behavior is like follows : Sometimes the led light remains on when i enable the widget. But it doesnot turn on/off the…
37
votes
4 answers

Android 11 (R) return empty list when querying intent for ACTION_IMAGE_CAPTURE

Device: Emulator pixel 3a - Android 11 Code: final List cameraIntents = new ArrayList(); final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final List listCam = …
37
votes
6 answers

How to capture image from custom CameraView in Android?

i need to capture image from required portion of the screen. capture image from camera. at that time other screen content as it is. how is this possible?
Mr.Sandy
  • 4,299
  • 3
  • 31
  • 54