How to capture image without showing preview - android

Can anyone help to remove camera preview of open default camera.
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, 100);

That is not possible. There are hundreds, if not thousands, of camera apps that support ACTION_IMAGE_CAPTURE. This includes dozens that are pre-installed ("default camera") on the thousands of different Android device models. Approximately zero of them offer this "feature", because ACTION_IMAGE_CAPTURE does not include that in its protocol.

No, it is not possible using the default camera using ACTION_IMAGE_CAPTURE as you are using. The API simply doesn't support that.
But if you really want to capture images without a preview, you have to do it yourself or use this library. This library does exactly what you are asking for. You can also check the code (it's pretty simple) and implement it yourself.

Related

Android camera, how to set default format?

I want to capture image and upload to server from android client. The supported formats are jpeg,jpg and png. I am not making a custom camera in my application and am calling the camera using below code snippet:-
Intent intent = new Intent();
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri);
startActivityForResult(intent, REQUEST_CAMERA);
My doubts :-
Is there any guaranteed format(s) in which the native camera captures the picture?
Is there any way to command the camera to take image in a particular format?
(NB:- I know that I can achieve this by making a custom camera, but I dont want to do that)
Is there any guaranteed format(s) in which the native camera captures the picture?
No. Usually, it will be JPEG, as that is all that many camera apps know about. Possibly, the camera app might examine the MIME type associated with your Uri (e.g., via file extension) and do something based upon that.
But, please understand that there are ~2 billion Android devices, spread across thousands of device models. Those devices ship with hundreds of different pre-installed camera apps, and users can install others from the Play Store and elsewhere. The behavior of camera apps will vary widely, including having bugs.
Is there any way to command the camera to take image in a particular format?
No.

Image overlay in android native camera

I am new into the android development environment. I want to know if there is a way to overlay an image into the android native camera, so I do not have to program an custom camera, just call the native camera, but into preview an image will be showed. I have tried many ways, but none of them seems to work.
Here is the code I use to shoot the picture and save the image:
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File pictureDirectory = new File(Environment.getExternalStorageDirectory() + "/myPics");
String pictureName = getPictureName();
File imageFile = new File(pictureDirectory, pictureName);
Uri pictureUri = Uri.fromFile(imageFile);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, pictureUri);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
Something like this face grid, but on top of the native camera:
!https://lh6.ggpht.com/8_x6orazogmW3sU9pnev2EzOalJkKi8ext1qzNTbbHdFCP5W0eKdVJk3KnMijf0nQw=h900
Thank You!
I want to know if there is a way to overlay an image into the android native camera, so I do not have to program an custom camera, just call the native camera, but into preview an image will be showed. Something like this face grid, but on top of the native camera
No.
First, there are thousands of Android device models. These devices will have dozens, if not hundreds, of "android native camera" apps, as many device manufacturers frequently ship a customized camera app.
Second, your code is not invoking an "android native camera" app. Your code is invoking the user's choice of what camera app to use, among the camera apps that the user has installed that support ACTION_IMAGE_CAPTURE. The user can easily choose to use some other camera app, if they prefer that camera app to the one that shipped with their device. So now you have hundreds, if not thousands, of additional camera apps to consider. Any of those could be what a given user is using.
Third, there is no requirement that all camera apps have an identical user interface. The size and position of the camera preview can vary. Not only will they vary between apps, but even the same app might vary the size and position of the camera preview between versions of that app, as apps can and do get updated.
Fourth, you have no good way of determining when any of these camera apps happens to be in the foreground.

Camera crashes due to crop code one line, how to crop in standard way

My app crashes due to camera.putExtra("crop", "true"); Im assuming this is due to some stupid inconsistent vendor camera drivers or something... joys of fragmented market i guess.
How can i crop if this doesn't work? preferably have crop square on screen to guide user. Is there a standard ~99% proof method?
Give a look at the below mentioned link.
Android intent with multiple option i.e , Pick image from gallary and capture image using front camera
if you won't go to intent use crop library
https://github.com/jdamcd/android-crop
There is no crop intent in Android !!
From https://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html
Many developers are calling startActivity() on an Intent with an action of com.android.camera.action.CROP. They are doing this to crop an image.
This is a really bad idea.
In this specific case, this Intent action is supported by the AOSP Camera app. That app does not exist on all devices. Devices lacking this app will not respond to this undocumented Intent action, and your app will crash.
Further reads: Explanation of Android Code Camera Intent + Croping Images
In essence, the above intent will crash on some devices.
I bet if commonsware's Author see this post , he could explain it even better.
Im assuming this is due to some stupid inconsistent vendor camera drivers or something... joys of fragmented market i guess.
Primarily, it is because that is not part of the Android SDK. There is no requirement for any camera app to support random Intent extras.
How can i crop if this doesn't work?
Use a library. Or write your own image cropping engine.

Slightly modify the Camera intent

I need to slightly modify the default camera intent in android - for example I want to start the camera in 360p quality, when starting front camera to be the active one and to be oriented in landscape. I have done a research and find some put extra options that could be used but it seems they do not work properly. So i think that the best way to do this is to find the build in camera intent code and do some modifications.
Where I can find the source of the build in camera intent and also the meta data part in the manifest(if there are some specific options to start the intent)?
I need to slightly modify the default camera intent in android - for example I want to start the camera in 360p quality, when starting front camera to be the active one and to be oriented in landscape.
I am going to guess that by "default camera intent" you mean an Intent for ACTION_IMAGE_CAPTURE.
I have done a research and find some put extra options that could be used but it seems they do not work properly.
For ACTION_IMAGE_CAPTURE, there is no extra to force 360p, and not all cameras support that resolution. There is no extra to force a front-facing camera, and not all devices have a front-facing camera. I am skeptical that EXTRA_SCREEN_ORIENTATION will do what you want, and there is no requirement that any camera app must support EXTRA_SCREEN_ORIENTATION.
So i think that the best way to do this is to find the build in camera intent code and do some modifications.
I am going to assume that by "build in camera intent code" you mean "built-in camera app".
Where I can find the source of the build in camera intent and also the meta data part in the manifest(if there are some specific options to start the intent)?
Few manufacturers ship the AOSP camera app. They replace it with their own. The source code for their own camera apps will be in their offices.

Restricting Android camera

Avoiding having to create a whole camera app myself, I am calling up:
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
this.startActivityForResult(camera, PICTURE_RESULT);
However, the camera is very advanced and beautiful :) but not for my purposes. :(
Is there a way to restrict the camera to control size, resolution, disable setup button, flash, face recognition, etc...?
Sorry but you will be unable to change all these features using the Intents system. For this level of control you will have to create you own camera program.
http://developer.android.com/reference/android/hardware/Camera.html
You can change the autofocus and flash however using the uses tag in the manifest.xml

Categories

Resources