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

Although the documentation suggests that you can set which format the image data should arrive from the camera in, in practice you often have a choice of one: NV21, a YUV format. For lots of information on this format see http://www.fourcc.org/yuv.php#NV21 and for information on the theory behind converting it to RGB see http://www.fourcc.org/fccyvrgb.php. There … Read more

Android M Camera Intent + permission bug?

I had the same issue and find this doc from google: https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE “Note: if you app targets M and above and declares as using the CAMERA permission which is not granted, then atempting to use this action will result in a SecurityException.” This is really weird. Don’t make sense at all. The app declares Camera … Read more

Use camera flashlight in Android

Every device is a bit different. Samsung especially likes to make things complicated for app developers. On the Galaxy Tab you should be good with: Camera cam; void ledon() { cam = Camera.open(); Parameters params = cam.getParameters(); params.setFlashMode(Parameters.FLASH_MODE_ON); cam.setParameters(params); cam.startPreview(); cam.autoFocus(new AutoFocusCallback() { public void onAutoFocus(boolean success, Camera camera) { } }); } void ledoff() … Read more

android camera surfaceview orientation

The way I implemented it: private Camera mCamera; private OrientationEventListener mOrientationEventListener; private int mOrientation = -1; private static final int ORIENTATION_PORTRAIT_NORMAL = 1; private static final int ORIENTATION_PORTRAIT_INVERTED = 2; private static final int ORIENTATION_LANDSCAPE_NORMAL = 3; private static final int ORIENTATION_LANDSCAPE_INVERTED = 4; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // force Landscape layout … Read more

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

If the image(photo) was taken by a program made by you, you must set Parameters.setRotation with the correct rotation value. This, depending of camera drive, rotates the image before save or save the rotation value to exif TAG_ORIENTATION. Therefore, if TAG_ORIENTATION is null or zero, the image are in the correct orientation, otherwise you must … Read more

Get Path of image from ACTION_IMAGE_CAPTURE Intent

This is how it works on 2.2 (different than on previous versions). When starting intent String fileName = “temp.jpg”; ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, fileName); mCapturedImageURI = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI); startActivityForResult(intent, CAPTURE_PICTURE_INTENT); you need to remember mCapturedImageURI. When you capture image, in onActivityResult() use that URI to obtain … Read more

How to capture an image and store it with the native Android Camera

Here was the final product in case anyone is still visiting this thread: public class CameraCapture extends Activity { protected boolean _taken = true; File sdImageMainDirectory; protected static final String PHOTO_TAKEN = “photo_taken”; @Override public void onCreate(Bundle savedInstanceState) { try { super.onCreate(savedInstanceState); File root = new File(Environment .getExternalStorageDirectory() + File.separator + “myDir” + File.separator); root.mkdirs(); … Read more