Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CaptureImage doesn't work most of the time on android #533

Open
Tsabary opened this issue Apr 9, 2019 · 39 comments
Open

CaptureImage doesn't work most of the time on android #533

Tsabary opened this issue Apr 9, 2019 · 39 comments

Comments

@Tsabary
Copy link

Tsabary commented Apr 9, 2019

Is this a bug report?

(write your answer here)
Yes

Have you read the Contributing Guidelines?

Yes
(Write your answer here.)

Environment

Android Studio emulator / OnePlus 5t

Steps to Reproduce

(Write your steps here:)

  1. Implement captureImage
  2. Try to take a photo

Expected Behavior

(Write what you thought would happen.)

A photo would be taken

Actual Behavior

(Write what happened. Add screenshots!)

The action doesn't kick in at all. I've entered a few Logs, the first being immedietly after calling to capture image, but whenever that issue exists (which is almost always for me both at the emulator and OnePlus device, that Log never prints.

Reproducible Demo

https://stackoverflow.com/questions/55526362/capture-image-action-only-works-sometimes-without-clear-reason-why

You could see here the relevant part of the code. The log that should print "image captured" almost never prints (and a photo isn't taken). When a photo is taken, the log of course prints, but there is no reasoning behind when it would or wouldn't work. It seems that it is more likely to work on the emulator.

@drogeek
Copy link

drogeek commented Apr 17, 2019

I've the same problem and have noticed it would take a picture if I obstruct the lens with for instance my finger.

@Tsabary
Copy link
Author

Tsabary commented Apr 18, 2019

It wouldn't be a good solution, but it doens't work for me anyway.
I've been pushing this fix to the end because I really want to avoid changing to Fotoapparat (moved it from there to CameraKit before), but looks like I'll have to. Really hoping for an update soon that'll fix it.

@Akshshr
Copy link

Akshshr commented Apr 18, 2019

Yes, noticing the same...CaptureImage doesnt do anything at least on
1.0.0-beta3.11'

@Tsabary
Copy link
Author

Tsabary commented Apr 18, 2019

is there a previous version in which you know it did work? I don't mind downgrading for now, my camera request is super simple

@arsenii-repository
Copy link

Experiencing same problem. Anyone have forced CameraKit work properly?

@Tsabary I also moved from Fotoapparat to CameraKit in hope it will work. (Fotoapparat seems doesn't work on API 17)

@austinkettner
Copy link
Member

Hey guys, can you be more specific about the versions of CK you are using? This isn't a known widespread issue but obviously is affecting you. We will look into it once we know more!

@austinkettner austinkettner added this to the 1.0.0-beta3.12 milestone Apr 18, 2019
@arsenii-repository
Copy link

arsenii-repository commented Apr 18, 2019

build.gradle

    implementation 'com.camerakit:camerakit:1.0.0-beta3.11'
    implementation 'com.camerakit:jpegkit:0.1.0'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0'

Also no errors/info in logcat. No error in CameraKitView.ErrorListener.

@Akshshr
Copy link

Akshshr commented Apr 18, 2019

Here are my details
Gradle

 implementation 'com.camerakit:camerakit:1.0.0-beta3.10'
    implementation 'com.camerakit:jpegkit:0.1.0'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0'

I think the root of a lot of these issues are that the sample app has very deprecated code. Would be nice to have that on V1

@Tsabary
Copy link
Author

Tsabary commented Apr 18, 2019

I am using 3.11 now but the problem still existed when i was on 3.10.

I am running my app on the emulator and on a OnePlus 5t.

This is how my code is structured:

 captureButton.setOnClickListener {

        Log.d("photoActivity", "button clicked")

        cameraKitView.captureImage(){ _, p1 ->
            Log.d("photoActivity", "image captured")
    }
}

I've also tried instead of captureImage() to have it captureImage or captureFrame. The current setp seems to be the most consistent and I was just able to make it work with my OnePlus as well (literally for the first time as I was writing this) but it is still not consistent.

button clicked is always printed, where image captured almost never does (it rarely happens and inly on the emulator).

@Tsabary
Copy link
Author

Tsabary commented Apr 18, 2019

Update: as per Murphy's law, things might actually be working for me now. It seems to be more consistent after I've added the empty brackets. I am still running tests but it is deffinitely working much better than it did before.

@Tsabary
Copy link
Author

Tsabary commented Apr 26, 2019

Update: it stops working again. I can't get it to be stable.
Before calling it an issue, I think it would be best if you can provide with the proper way to capture an image using Kotlin, because currently I can't tell if it is nor consistent because of the library or because I am doing something wrong (though I have tried quit a few different options)

@Uplink03
Copy link

Uplink03 commented Apr 27, 2019

I was trying to debug this, but Android Studio claimed that the bytecode didn't match the source code for CameraKitView, so I've cloned branch v1.0.0-beta4, added the camerakit directory to my project and, with some effort, made it build as a subproject just like the demo app does in this repository instead of using the pre-built release.

Good news: with the integrated project this works. So my guess is that the published build is out of date.

I'm not sure I'd be able to tell you how I did the subproject integration, as it was quite a bit of trial and error (I'm new to Android development), using the gradle files in this repository as reference each time I had an error.

@leokvw
Copy link

leokvw commented May 6, 2019

Same problem here in my Google Pixel 1. I have implemented the captureImage function as instructed and Logcat didn't print anything strange...and that's strange hhhh.

@gabrielbatta
Copy link

Same problem

@tycallen
Copy link

tycallen commented May 7, 2019

same problem

@wintermoon9
Copy link

Any insights? Dealing with this too...

@fireb86
Copy link

fireb86 commented May 8, 2019

same problem, only with 3.11

@chintan-mishra
Copy link

Here is what I have found while testing on some devices:
Moto G4+:

  • No image can be captured
  • toggleCamera() fails

Xiaomi Mi A10:

  • TODO: I will update this within 24 hours.

OnePlus 6:

  • Low light results in no image capture and toggleCamera() method doesn't work
  • Proper lighting leads to one successful image capture however subsequent image callbacks are never triggered. The same happens with toggleCamera() method.
  • When the device is placed on a flat surface then any number of photos can be captured. toggleCamera() works each time.

@PORTB
Copy link

PORTB commented May 12, 2019

same problem, SM-G935FD

@FelipeBerrios
Copy link

same problem here on Samsung Device ( Tab Active 2)

@DarkMinstrel
Copy link

Surprisingly enough, adding an errorListener to the CameraKitView has fixed the problem.

@chintan-mishra
Copy link

@DarkMinstrel it doesn't seem to work for some devices.

@Intonjokel
Copy link

I have the same Problem. Sometimes it work. But most of the time it doesn't work.

@Jaime97
Copy link

Jaime97 commented Jun 27, 2019

Same problem here

@toeii
Copy link

toeii commented Aug 23, 2019

Same problem, from MI 6(Android 8.0)

@toeii
Copy link

toeii commented Aug 23, 2019

Same problem, from MI 6(Android 8.0)

This problem can be avoided by lowering the version to v1.0.0-beta3.10

@simplepeng
Copy link

same problem from oneplus3A and oneplus6

@nxnyk
Copy link

nxnyk commented Oct 19, 2019

the same problem

@javdev
Copy link

javdev commented Nov 24, 2019

same for me. beta3.11
Works sometimes, doesn't work sometimes. Built in a retry with stopping starting the camera again. Works sometimes, doesn't work sometimes. Is this project discontinued. The last change seemed to be happening months ago...

@javdev
Copy link

javdev commented Nov 24, 2019

and 3.10 same problem. I even cleaned the project, rebuilt it, invalidated the caches and restarted.

@sjd753
Copy link

sjd753 commented Dec 23, 2019

Same problem with implementation 'com.camerakit:camerakit:1.0.0-beta3.11' and kotlin on android 10 it doesn't capture any image. No errors are logged or thrown in listener. Are they working on it or is it discontinued???

@passatgt
Copy link

Downgrading to beta 3.10 solved the issue for me

@javdev
Copy link

javdev commented Dec 23, 2019

Hi, I think it is discontinued, because Google Jetpack has integrated CameraX. So it wouldn't make sense to try to compete with it. CameraX has image analysis on top. I switched

@NaqiControl
Copy link

Downgrading to beta 3.10 solved the issue for me

@matteomedioli
Copy link

matteomedioli commented Feb 12, 2020

Downgrading to beta 3.10 also works for me on RedmiNote7!

implementation 'com.camerakit:camerakit:1.0.0-beta3.10'
implementation 'com.camerakit:jpegkit:0.1.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0'

EDIT:
Only sometimes works....:( But is an improvement from not working at all

@tian102
Copy link

tian102 commented Oct 14, 2020

Same problem, from MI 6(Android 8.0)

This problem can be avoided by lowering the version to v1.0.0-beta3.10

Worked for me! Oh, happy days!

@103945089
Copy link

Downgrading to beta 3.10 solved the issue for me

worked for me too, Thanks

@ArslanKhan99
Copy link

Thanks

Downgrading to beta 3.10 solved the issue for me

worked for me too, Thanks

Thanks Work for me

@ruben93
Copy link

ruben93 commented Aug 14, 2021

In the new version you should activate microphone permissions to take a photo 🤷🏻‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests