Android Question CameraEx2 onImageAvailable event

walterf25

Expert
Licensed User
Longtime User
Hi @Erel, I know we're not supposed to direct our questions directly to you, but i really think that since you wrote this library I may have a better chance at getting a straight answer from you, I am currently working on creating an App at work to test some custom made Cameras by Qualcom company, i am in need of having access to the onImageAvailable Event, I went through your library and I see that you have an Event that is supposed to be raised depending on the ImageFormat, below is the code taken from your Camera2 Library:

Code deleted due to inappropriately posting it without Consent.

My question is, I tried setting the following Sub to different values including 35 in the PreviewFormat parameter to see If I can raise the PreviewTaken Event without any success, For the Value = 35 it seems to work but when I take a picture i get the following error:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
LEVEL_3
** Activity (main) Resume **
Start success: true
Error occurred on line: 323 (CamEx2)
java.lang.ClassCastException: android.media.ImageReader$SurfaceImage cannot be cast to byte[]
at b4a.example3.camex2$ResumableSub_TakePictureNow.resume(camex2.java:1823)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:735)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:357)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:245)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$1.run(BA.java:330)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7032)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
** Activity (main) Pause, UserClosed = true **
For any other value except 256 I keep getting an error saying that whatever previewformat i pass to the function is not supported, which brings me to my next question, I have posted this next question on this thread, about getting the supported preview formats.

Any advice you can give me on how to accomplish what i'm trying to do here?

Thanks,
Walter
 
Last edited:

walterf25

Expert
Licensed User
Longtime User
Did I ever publish the library source code?
No, i looked at the Jar file with a tool called JDGUI.

Regards,
Walter
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

walterf25

Expert
Licensed User
Longtime User
In fact you were decompiling it as JD is a JavaDecompiler.
You/we are not allowed to Decompile them.
The tools only shows the source code, you can't really do anything else with it, I would agree with you if I was using Dex2Jar or some other similar tool, but I apologize if I wasn't supposed to, just wanted to take a look at the code, I mean the library is based on Android's Native Camera2 API, i don't think there's any harm on that, i would say If the library was based on Erel's own proprietary API then Yes by all means shoot me :(

Walter
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. All libraries call underlying APIs. The library code is propriety.
2. Showing the source code = reverse engineering the library. This is not allowed. I don't really mind if you do it for yourself however you shouldn't post the reverse engineered code and you shouldn't except me to provide support based on this code.
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
1. All libraries call underlying APIs. The library code is propriety.
2. Showing the source code = reverse engineering the library. This is not allowed. I don't really mind if you do it for yourself however you shouldn't post the reverse engineered code and you shouldn't except me to provide support based on this code.
Got it, and again I apologize, i have deleted the code and written "Deleted due to inappropriately posting it without consent" instead.

Thanks again.
Walter
 
Upvote 0
Top