Comments (21)
I figure how resolve the problem. It's related with the optimal size of the preview in the method "getOptimalPreviewSize".
After the comment "Cannot find the one match the aspect ratio, ignore the requirement", and after the if statement put the code
optimalSize = sizes.get(0);
for(int i=0;i<sizes.size();i++)
{
if(sizes.get(i).width > optimalSize.width)
optimalSize = sizes.get(i);
}
if you want enable the focus, put the following code inside the if statement of the method "setCamera".
Camera.Parameters params = mCamera.getParameters();
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
mCamera.setParameters(params);
Note: I made this modifications for android tablet. i hope this help somebody.
from cordova-plugin-camera-preview.
The auto focus solution @fernandoTinelli posted will crash the app if it's not a supported focus mode for the device.
Here's the code I used to prevent this:
List<String> mFocusModes = mCamera.getParameters().getSupportedFocusModes();
Camera.Parameters params = mCamera.getParameters();
if (mFocusModes.contains("continuous-picture")) {
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
} else if (mFocusModes.contains("continuous-video")){
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
} else if (mFocusModes.contains("auto")){
params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
}
mCamera.setParameters(params);
This was in the setCamera()
function in CameraActivity.java
, within the if(mCamera != null)
check.
Issues #72 #33 and #83 could also be fixed by this.
from cordova-plugin-camera-preview.
The hotfix suggested by fernandoTinelli really works, thanks.
it took me some time to realize that the proper file which has to be edited is this one:
my_ionic_project/platforms/android/src/com/mbppower/CameraActivity.java
and not this one:
my_ionic_project/plugins/com.mbppower.camerapreview/src/android/com/mbppower/CameraActivity.java
from cordova-plugin-camera-preview.
@dinhtuan1991vt i solved the blur problem calling a function that refocus automaticallly before take the photo.
Here's the function
public void refocusCamera(){
Log.d(TAG, "################## refocus ######################");
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
mCamera.cancelAutoFocus();
mCamera.autoFocus(new Camera.AutoFocusCallback() {
@Override
public void onAutoFocus(boolean success, Camera camera) {
if (success){
takePicture(0,0);
}
}
});
}
});
}
Then have to add the function in execute method in camerapreview and in your js plugin for calling it
from cordova-plugin-camera-preview.
blhack my bad, the for loop is:
for(int i=0;i<sizes.size();i++)
from cordova-plugin-camera-preview.
Hi. i'm facing the same problem on iOS, help :)
from cordova-plugin-camera-preview.
+1
from cordova-plugin-camera-preview.
some update about that issue? i'm facing the same problem.
from cordova-plugin-camera-preview.
Any updates on this issue? I am facing the same problem.
from cordova-plugin-camera-preview.
fernandoTinelli is there an error in that code? (It looks like you didn't finish declaring the for loop).
from cordova-plugin-camera-preview.
I am facing the same problem.After taking a picture is blurred, and finally images are not square (the resolution is not the same width and height)
from cordova-plugin-camera-preview.
Hi everybody, thank yu very much for this plugin, it works fine for, the code of quality of the image also works fine, but please i have a problem with the focus, which means when i put code of focus my app crashes if i launch my camera. there is any help please ?
from cordova-plugin-camera-preview.
Yes please , me to . I really want to use this plugin, but with no way of auto focus it is unfortunately no use to me. It is probably one of the best plugins out there but really need it to work.
Sent from my iPhone
On 05 Dec 2015, at 11:41 AM, mustaphaaassab [email protected] wrote:
Hi everybody, thank yu very much for this plugin, it works fine for, the code of quality of the image also works fine, but please i have a problem with the focus, which means when i put code of focus my app crashes if i launch my camera. there is any help please ?
—
Reply to this email directly or view it on GitHub.
from cordova-plugin-camera-preview.
Thank you, iarry -- I was getting the crashing issue too.
from cordova-plugin-camera-preview.
@fernandoTinelli my problem is quite similar, but not the same.
I've just set autofocus for the camera(with fail but now is not my priority, replacing it with focusing always before take picture, for the moment).
My problem is that photo taked with camerapreview have a 1088x1920 resolution(wich is the max of Camera.sizes size) but photo taken with default application have a 1520x2048 resolution(for the actual settings).
I try to pass higher value of height and width to takephoto() function but this doesn't work.
Have you any idea how to solve this?
from cordova-plugin-camera-preview.
It's still very blur with Android. Anyone can solve this?
from cordova-plugin-camera-preview.
Are focus and optimal quality as well include in last commit?
from cordova-plugin-camera-preview.
Thanks, fernandoTinelli!
from cordova-plugin-camera-preview.
Can you create a new release which includes these changes and make it available on npm?
from cordova-plugin-camera-preview.
With the latest version on the master branch I still only get 1920x1080 images.
I call the takePicture method without parameters.
What am I missing?
from cordova-plugin-camera-preview.
in iOS, i'm facing the same problem, but I ended up by doing this:
And after invoke takePicture(), the image quality is getting better.
from cordova-plugin-camera-preview.
Related Issues (20)
- takeSnapshot return blank image HOT 1
- camera is taking entire screen height and flip and close,capture buttons are not visible in native device,Please let me know if anyone has solution for this,z index is already given same as in the code HOT 2
- is platform windows supported ? HOT 3
- is platform browser supported ? HOT 1
- error building with xcode 13.4.1 HOT 6
- How to add barcode scanning ability using another plugin?
- takePicture error only on Android 9
- How to disallow Screenshot
- Android Studio forces me to set android:exported="true" in AndroidManifest.xml HOT 1
- Image is saved as Base64 regardless of storeToFile setting
- Illegal Access HOT 1
- This plugin doesn't seem to install in Android 13, API 33 HOT 2
- takePicture does not resolve promise on iPhone 15 Pro HOT 4
- AVCaptureStillImageOutput' is deprecated: first deprecated in iOS 10.0 - Use AVCapturePhotoOutput instead.
- iPhone 13 Pro Max autofocus issue on close objects HOT 3
- Documentation wrong for takeSnapshot and takePicture
- Can not perform this action after onSaveInstanceState
- photos Android clearer
- how do i ? HOT 1
- devicesWithMediaType is deprecated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-camera-preview.