Hi all, i was wondering if someone could tell me if it would be possible to get the supported preview formats using the CameraEx2 class, i'm not too familiar with JavaObject, i have tried but am not able to get anywhere, please if anyone has tried this before and can share the code it would be greatly appreciated.
Thank you but i am referring to the PreviewFormat not PreviewSizes, for example NV21, Raw10 etc. i don't see that method being exposed in this library, but i'm assuming it can be done with JavaObject, i have tried the following:
B4X:
Dim JO As JavaObject
JO = Camera
JO.RunMethod("getPreviewFormats", null)
I get an error saying getPreviewFormats doesn't exist in the anywheresoftware.ba.cam2 class.
Public Sub getSupportedOutputFormats As Int()
Dim StreamConfigurationMap As JavaObject = jcamera.RunMethod("GetScalerStreamConfiguration", Array(id))
Return StreamConfigurationMap.RunMethod("getOutputFormats", Null)
End Sub
Public Sub getSupportedOutputFormats As Int()
Dim StreamConfigurationMap As JavaObject = jcamera.RunMethod("GetScalerStreamConfiguration", Array(id))
Return StreamConfigurationMap.RunMethod("getOutputFormats", Null)
End Sub
If I pass 35 as a parameter to this function in the Camex2 Class library
B4X:
'Prepared the surface for still capture.
Public Sub PrepareSurface (MyTaskIndex As Int) As ResumableSub
If MyTaskIndex <> TaskIndex Then Return False
CloseSession
Wait For (CreateSurface) Complete (Result As Boolean)
If MyTaskIndex <> TaskIndex Then Return False
Camera.StartSession(tv, PreviewSize, CaptureSize, 35, 0, False) '256 = JPEG
Wait For Camera_SessionConfigured (Success As Boolean)
If MyTaskIndex <> TaskIndex Then Return False
Return Success
End Sub
Then I get the following error, any idea on how to go around that?
Start success: true
format: 32
format: 256
format: 34
format: 35
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:1842)
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 **