infinum / android-goldeneye Goto Github PK
View Code? Open in Web Editor NEWA wrapper for Camera1 and Camera2 API which exposes simple to use interface.
License: Apache License 2.0
A wrapper for Camera1 and Camera2 API which exposes simple to use interface.
License: Apache License 2.0
小米Mix3前置摄像头打开后默认放大了2倍,但参数zoom还是显示为1,必须手动缩放一下才行
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?
Steps:
As the title suggest if goldenEye.open(...)
could accept multiple surfaces the it would be possible to render image on TextureView
as well as process it at the same time.
Can I remove left and right space while we record video? While record video I want preview in autofit. Is it possible?
I don't see any changes to the preview, photo or video when I set color effect (negative, sepia...).
OnePlus 6, Android P
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)
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.
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)
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.
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.
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()
If I am turning on the flash by the Torch mode from settings before click on the video recording button, the flash is turning off and then turning on immediately.
Would you please help me, how can I fix it?
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)
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.
StateCallback:onError
method throws an error on close()
call because cameraDevice
is null. Also, other callbacks might have the same problem
Can anyone help how can we set PreviewScale manual?
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
Tell me if using Camera2 is even an option.
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?
Not sure if this is here or coming, but what about using the new stream for devices with 2+ rear cameras?
Flash works (sometimes only once) on auto
mode and does not work on always_on
.
The demo app fails to display anything but the error.
On a Nexus 5X, Android 6.0.1
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)
Giv
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.
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
More often than not, exceptions are just swallowed by a try / catch
block. For example:
Camera2Api
Camera2Api
Camera1Api
These are just 3 examples out of many.
Consider creating specific exceptions for this library, but don't overdo it. If the app has to crash, so be it. Consider creating an option that will swallow exceptions (maybe settable in the Config
class).
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.
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)
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.
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)
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)
}
}
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.
Hello,
I've enjoyed using your library. It greatly simplifies use of the Camera1 and Camera2 API's. Can I ask why you've chosen to omit the option for CamcorderProfile.QUALITY_QVGA as part of the VideoQuality enum?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.