Giter Site home page Giter Site logo

infinum / android-goldeneye Goto Github PK

View Code? Open in Web Editor NEW
375.0 24.0 53.0 377 KB

A wrapper for Camera1 and Camera2 API which exposes simple to use interface.

License: Apache License 2.0

Kotlin 99.35% Groovy 0.65%
camera1 camera2 camera android android-library android-development kotlin-android kotlin-library kotlin open-source

android-goldeneye's People

Contributors

domagojkorman avatar jonatanplesko avatar novakmarijan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-goldeneye's Issues

camera HAL 尺寸问题

image
这个问题出现在oppo 一款新机上,是一个4摄手机,能否排查下问题。

HTC Desire 310 (Camera1)

HTC Desire 310 seems to have troubles initializing the camera. It is expected to see the preview, but that never happens. it is necessary to identify a source of this issue.

Video recording problem with a solid green screen when using front camera on some specific devices

Hi, Infinium team.
Thank you for opening a really good camera wrapper. But I have faced a problem which really hard to solve.

I'm using the front camera for recording a video and most devices work fine.
But some devices show the issue.

and here is the photo
green_screen

I figured out that Samsung Galaxy Note 5 and Samsung Galaxy S6 Edge+ have this issue.

I had tried to debug with devices, but the android studio says everything works fine. The problem was there, but no errors were there.

Do you have any ideas about this?
(rear camera does not make this issue)

Thanks 👍

I attach the related codes below:

    private fun setupCamera() {
        if (CameraPermissionHelper.hasCameraPermission(this)) {
            goldenEye = GoldenEye.Builder(this)
                .setCameraApi(CameraApi.CAMERA2)
                .setLogger(onMessage = { s: String -> Timber.d(s) }, onThrowable = { Timber.e(it) })
                .build()


            viewModel.goldenEye = goldenEye
        } else {

            CameraPermissionHelper.requestCameraPermission(this)
        }
    }

android.hardware.camera2.CameraAccessException

Samsung Galaxy S6 edge (zerolte), Android 5.0
Report 1 of 1
java.lang.RuntimeException:
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1194)
Caused by: java.lang.reflect.InvocationTargetException:
at java.lang.reflect.Method.invoke (Method.java)
at java.lang.reflect.Method.invoke (Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1194)
Caused by: android.hardware.camera2.CameraAccessException:
at android.hardware.camera2.utils.CameraBinderDecorator$CameraBinderDecoratorListener.onCatchException (CameraBinderDecorator.java:81)
at android.hardware.camera2.utils.Decorator.invoke (Decorator.java:84)
at java.lang.reflect.Proxy.invoke (Proxy.java:397)
at $Proxy1.submitRequestList ($Proxy1.java)
at android.hardware.camera2.impl.CameraDeviceImpl.submitCaptureRequest (CameraDeviceImpl.java:617)
at android.hardware.camera2.impl.CameraDeviceImpl.capture (CameraDeviceImpl.java:503)
at android.hardware.camera2.impl.CameraCaptureSessionImpl.capture (CameraCaptureSessionImpl.java:161)
at co.infinum.goldeneye.sessions.PictureSession.takePicture (PictureSession.java:191)
at co.infinum.goldeneye.sessions.SessionsManager.takePicture (SessionsManager.java:86)
at co.infinum.goldeneye.GoldenEye2Impl.takePicture (GoldenEye2Impl.java:222)
at co.infinum.goldeneye.BaseGoldenEye.takePicture (BaseGoldenEye.java:56)
at co.infinum.goldeneye.GoldenEye$DefaultImpls.takePicture$default (GoldenEye.java:115)
at co.infinum.example.CamActivity$initListeners$2.onClick (CamActivity.java:106)
at android.view.View.performClick (View.java:5217)
at android.view.View$PerformClick.run (View.java:20983)
at android.os.Handler.handleCallback (Handler.java:739)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:145)
at android.app.ActivityThread.main (ActivityThread.java:6141)
at java.lang.reflect.Method.invoke (Method.java)
at java.lang.reflect.Method.invoke (Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1194)
Caused by: android.os.DeadObjectException:
at android.os.BinderProxy.transactNative (BinderProxy.java)
at android.os.BinderProxy.transact (BinderProxy.java:496)
at android.hardware.camera2.ICameraDeviceUser$Stub$Proxy.submitRequestList (ICameraDeviceUser.java:303)
at java.lang.reflect.Method.invoke (Method.java)
at java.lang.reflect.Method.invoke (Method.java:372)
at android.hardware.camera2.utils.Decorator.invoke (Decorator.java:80)
at java.lang.reflect.Proxy.invoke (Proxy.java:397)
at $Proxy1.submitRequestList ($Proxy1.java)
at android.hardware.camera2.impl.CameraDeviceImpl.submitCaptureRequest (CameraDeviceImpl.java:617)
at android.hardware.camera2.impl.CameraDeviceImpl.capture (CameraDeviceImpl.java:503)
at android.hardware.camera2.impl.CameraCaptureSessionImpl.capture (CameraCaptureSessionImpl.java:161)
at co.infinum.goldeneye.sessions.PictureSession.takePicture (PictureSession.java:191)
at co.infinum.goldeneye.sessions.SessionsManager.takePicture (SessionsManager.java:86)
at co.infinum.goldeneye.GoldenEye2Impl.takePicture (GoldenEye2Impl.java:222)
at co.infinum.goldeneye.BaseGoldenEye.takePicture (BaseGoldenEye.java:56)
at co.infinum.goldeneye.GoldenEye$DefaultImpls.takePicture$default (GoldenEye.java:115)
at co.infinum.example.CamActivity$initListeners$2.onClick (CamActivity.java:106)
at android.view.View.performClick (View.java:5217)
at android.view.View$PerformClick.run (View.java:20983)
at android.os.Handler.handleCallback (Handler.java:739)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:145)
at android.app.ActivityThread.main (ActivityThread.java:6141)
at java.lang.reflect.Method.invoke (Method.java)
at java.lang.reflect.Method.invoke (Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1194)

Regarding Video Capture

Hiii,

I am getting error in library when i capturing image
when i capture first video that will shoot completed.
in after that i am getting exception surface can not be null.

co.infinum.goldeneye.ThreadNotStartedException

Xiaomi Redmi Note 5A (ugg), Android 7.1

java.lang.RuntimeException:
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:823)
Caused by: java.lang.reflect.InvocationTargetException:
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:933)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:823)
Caused by: co.infinum.goldeneye.ThreadNotStartedException:
at co.infinum.goldeneye.utils.AsyncUtils.getBackgroundHandler (AsyncUtils.java:19)
at co.infinum.goldeneye.extensions.AnyKt.async (AnyKt.java:24)
at co.infinum.goldeneye.recorders.PictureRecorder$takePicture$cameraPictureCallback$1.onPictureTaken (PictureRecorder.java:61)
at android.hardware.Camera$EventHandler.handleMessage (Camera.java:1178)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:163)
at android.app.ActivityThread.main (ActivityThread.java:6393)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:933)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:823)

How to take a picture w/o a preview?

I'd like to have the minimal amount possible. Can goldeneye be used without a preview?

val bitmap = goldenEye.availableCameras.find { it.facing == Facing.BACK }!!.takePicture()

ThreadNotStartedException: random crashes when take photo

Sometimes the library crashes when i take a photo on Samsung Galaxy TAB S7 (Nougat):

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1390)
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1500)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1390) 
     Caused by: co.infinum.goldeneye.ThreadNotStartedException: Trying to fetch [backgroundHandler] but background Thread is not started.
        at co.infinum.goldeneye.utils.AsyncUtils.getBackgroundHandler(AsyncUtils.kt:19)
        at co.infinum.goldeneye.extensions.AnyKt.async(Any.kt:24)
        at co.infinum.goldeneye.recorders.PictureRecorder$takePicture$cameraPictureCallback$1.onPictureTaken(PictureRecorder.kt:61)
        at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1115)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6780)
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1500) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1390) 

How to Override defaults for the Camera

Hello,

I have implemented Goldeneye as a dependency in my project, and adapted MainActivity.kt from the example for my needs.

I'd like to change the defaults for resolution to QVGA, and I'd like to set Antibanding to "off" by default. Can you explain to me how to go about this?

Thank you.

CameraDevice close problem

StateCallback:onError method throws an error on close() call because cameraDevice is null. Also, other callbacks might have the same problem

Check how to deal with continuous focus

Some devices have continuous passive focus, which messes up the logic in an endless loop of trying to acquire focus.

Research this topic and see how to properly treat this state.

Allow user to choose between Camera1 and Camera2 API

Hi,

I'd like to allow the users of my app to opt out of using Camera2 even if it's available to use. To help with this, I'd like this library to

  1. Tell me if using Camera2 is even an option.

  2. Allow me to build a GoldenEye instance using Camera1 (i.e. GoldenEye1Impl) even if the device supports Camera2.

Looking at the code it seems to me this is currently not possible (please correct me if I am mistaken), even though you already have most of the building blocks to make this possible. Basically, I'd like to bundle that if condition in GoldenEye.Builder.build() into a boolean variable (e.g. GoldenEye.isCamera2Supported), and add a builder function (e.g. GoldenEye.Builder.forceCamera1()) that would force the build() function to return GoldenEye1Impl regardless of anything else.

Would you be willing to add this feature? And if so, would you like me to submit the necessary changes in a pull request?

Can I get the Uri of photo after the image is captured by GoldenEye

Hi,
Can I get the Uri of image as I am getting bitmap from " onPictureTaken" callback.

goldenEye.takePicture(
onPictureTaken = { bitmap ->

                    if (bitmap.width <= 4096 && bitmap.height <= 4096) {
                        displayPicture(bitmap)
                    } else {
                        reducePictureSize(bitmap)
                    }
                },
                onError = { it.printStackTrace() }
        )

Please help me out.
Thanks

Frequent crash when I try to set flashMode right after the build() of GoldenEye object

Basically my questions are: What is the best way (and timing) to turn off the flash feature? Is there a way to turn off the flash feature in the GoldenEye.Builder?

I build the GoldenEye object with these line of code:

////// from CameraActivity.onCreate()
this.goldenEye = GoldenEye.Builder(this)
                .setCameraApi(CameraApi.CAMERA1)
                .build()

this.goldenEye?.config?.flashMode = FlashMode.OFF
//////
java.lang.RuntimeException: Unable to start activity ComponentInfo{OMISSIS}: kotlin.UninitializedPropertyAccessException: lateinit property _config has not been initialized
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: kotlin.UninitializedPropertyAccessException: lateinit property _config has not been initialized
        at co.infinum.goldeneye.GoldenEye1Impl.getConfig(GoldenEye1Impl.kt:54)
        at OMISSIS:124)
        at android.app.Activity.performCreate(Activity.java:7136)
        at android.app.Activity.performCreate(Activity.java:7127)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6669) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

Wrong orientation of saved image

Steps:

  1. Implement the camera in an activity and lock it to portrait orientation
  2. Tilt phone to landscape and save the image
  3. The preview is fine, but the image is saved rotated by 90 degrees (wrong exif?)

Samsung A3 Hit timeout for jpeg callback!

When taking a photo this error occured. I could reproduce this error only on Samsung A3.

12-20 13:25:36.684 2795-6262/co.infinum.zagrebbethere.dev E/RequestThread-0: Hit timeout for jpeg callback!
12-20 13:25:37.414 2795-6262/co.infinum.zagrebbethere.dev E/AndroidRuntime: FATAL EXCEPTION: RequestThread-0
                                                                            Process: co.infinum.zagrebbethere.dev, PID: 2795
                                                                            java.lang.RuntimeException: startPreview failed
                                                                                at android.hardware.Camera.startPreview(Native Method)
                                                                                at android.hardware.camera2.legacy.RequestThreadManager.startPreview(RequestThreadManager.java:275)
                                                                                at android.hardware.camera2.legacy.RequestThreadManager.doPreviewCapture(RequestThreadManager.java:317)
                                                                                at android.hardware.camera2.legacy.RequestThreadManager.access$1600(RequestThreadManager.java:61)
                                                                                at android.hardware.camera2.legacy.RequestThreadManager$5.handleMessage(RequestThreadManager.java:756)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                                at android.os.Looper.loop(Looper.java:145)
                                                                                at android.os.HandlerThread.run(HandlerThread.java:61)
12-20 13:25:37.784 2795-6224/co.infinum.zagrebbethere.dev E/RequestThread-0: Dropping jpeg frame.

Color effect doesn't work

I don't see any changes to the preview, photo or video when I set color effect (negative, sepia...).

OnePlus 6, Android P

Too many ANRs

On device Samsung Galaxy S8 (dreamlte), Android 9
#11 pc 00000000002c1212 /data/app/my.app.package.name
-HmXpHbkXYxihS0vwKekU6g==/oat/arm64/base.vdex (co.infinum.goldeneye.extensions.BitmapUtils.toBitmap+54)

#17 pc 00000000002c5ab6 /data/app/my.app.package.name-HmXpHbkXYxihS0vwKekU6g==/oat/arm64/base.vdex (co.infinum.goldeneye.sessions.PictureSession$initImageReader$1$1.invoke+22)

#23 pc 00000000002c5b40 /data/app/my.app.package.name-HmXpHbkXYxihS0vwKekU6g==/oat/arm64/base.vdex (co.infinum.goldeneye.sessions.PictureSession$initImageReader$1$1.invoke)

#29 pc 00000000002c1088 /data/app/my.app.package.name-HmXpHbkXYxihS0vwKekU6g==/oat/arm64/base.vdex (co.infinum.goldeneye.extensions.AnyKt$async$1.run+4)

Lenovo Tab 2 A7

Lenovo Tab 2 A7 has a distorted image preview. it obviously fails to load correct resolution for the rotation provided.

Test with the device and find a solution.
See what taken image looks like.

Use Camera1 by default for better consistency

We should encourage the use of the Camera1 API by default. Also I recommend hiding all Camera 2 features behind experimental flag.

I don't think multiple rarely used features are good trade-off over consistency that Camera1 has.

autoFocus failed

Hi, I used GoldenEye in some of my apps and I found a recurrent crash on some devices (Sony Xperia XA1, Samsung Galaxy S10+) which is a Fatal Exception: java.lang.RuntimeException autoFocus failed. In particular, I forced the Camera1 implementation to have a more consistent experience on all devices. Here the Stack trace.

In the documentation, I saw that it can be raised when "hardware or other low-level error, or because release() has been called on this Camera instance".

My question is: did you put any checks to avoid request to the auto focus when the camera is released? Any further suggestion to avoid this kind of issue?

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.