Code Monkey home page Code Monkey logo

Comments (21)

fernandoTinelli avatar fernandoTinelli commented on July 18, 2024 8

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.

iarry avatar iarry commented on July 18, 2024 6

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.

petervojtek avatar petervojtek commented on July 18, 2024 4

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.

andrea-86 avatar andrea-86 commented on July 18, 2024 2

@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.

fernandoTinelli avatar fernandoTinelli commented on July 18, 2024 1

blhack my bad, the for loop is:

for(int i=0;i<sizes.size();i++)

from cordova-plugin-camera-preview.

goariel10 avatar goariel10 commented on July 18, 2024 1

Hi. i'm facing the same problem on iOS, help :)

from cordova-plugin-camera-preview.

marty-krishner avatar marty-krishner commented on July 18, 2024

+1

from cordova-plugin-camera-preview.

fernandoTinelli avatar fernandoTinelli commented on July 18, 2024

some update about that issue? i'm facing the same problem.

from cordova-plugin-camera-preview.

Divya-A avatar Divya-A commented on July 18, 2024

Any updates on this issue? I am facing the same problem.

from cordova-plugin-camera-preview.

blhack avatar blhack commented on July 18, 2024

fernandoTinelli is there an error in that code? (It looks like you didn't finish declaring the for loop).

from cordova-plugin-camera-preview.

jiwufeiyang avatar jiwufeiyang commented on July 18, 2024

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.

mustaphaaassab avatar mustaphaaassab commented on July 18, 2024

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.

RichardBoyder avatar RichardBoyder commented on July 18, 2024

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.

blhack avatar blhack commented on July 18, 2024

Thank you, iarry -- I was getting the crashing issue too.

from cordova-plugin-camera-preview.

andrea-86 avatar andrea-86 commented on July 18, 2024

@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.

dinhtuan1991vt avatar dinhtuan1991vt commented on July 18, 2024

It's still very blur with Android. Anyone can solve this?

from cordova-plugin-camera-preview.

erperejildo avatar erperejildo commented on July 18, 2024

Are focus and optimal quality as well include in last commit?

from cordova-plugin-camera-preview.

dan-alarcon avatar dan-alarcon commented on July 18, 2024

Thanks, fernandoTinelli!

from cordova-plugin-camera-preview.

felschr avatar felschr commented on July 18, 2024

Can you create a new release which includes these changes and make it available on npm?

from cordova-plugin-camera-preview.

felschr avatar felschr commented on July 18, 2024

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.

Snowbases avatar Snowbases commented on July 18, 2024

in iOS, i'm facing the same problem, but I ended up by doing this:

image

And after invoke takePicture(), the image quality is getting better.

from cordova-plugin-camera-preview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.