iOS Question B4i LLCamera Error

Yvon Steinthal

Active Member
Licensed User
Longtime User
Hi,

I am trying to get rid of a crash related error that comes from triggering a cam.TakePicture before the camera has even started.
Here's what i do:

B4X:
cam.Initialize(pnlCamPhoto,"cam",False)
   cam.PreserveRatio = True
   cam.Preset = cam.PRESET_1920x1080
   cam.BeginConfiguration
   cam.Zoom = 1
   cam.CommitConfiguration
   cam.resize
   cam.StartPreview

Once that is initialized, the trigger to take a picture is on the pnlCamPhoto_Click event as follows:

B4X:
Sub cam_photo_click

     cam.TakePicture
     pnlCamPhoto.RemoveViewFromParent
    
End Sub

The problem i have is when the user clicks the panel too fast!
The following error is logged:

B4X:
error taking picture: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-16800), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1c44492a0 {Error Domain=NSOSStatusErrorDomain Code=-16800 "(null)"}}
Error occurred on line: 1206 (Main)
*** +[AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:] NULL sample buffer.
Stack Trace: (
  CoreFoundation  <redacted> + 148
  libobjc.A.dylib  objc_exception_throw + 56
  AVFoundation  <redacted> + 0
  EyeVu  __26-[B4ILLCamera TakePicture]_block_invoke + 116
  AVFoundation  <redacted> + 1756
  CoreFoundation  <redacted> + 20
  CoreFoundation  <redacted> + 288
  CoreFoundation  <redacted> + 2436
  CoreFoundation  CFRunLoopRunSpecific + 436
  GraphicsServices  GSEventRunModal + 100
 UIKit  UIApplicationMain + 208
 EyeVu  main + 124
 libdyld.dylib  <redacted> + 4
)
SignalHandler 6

How can i either stop the error from crashing the app, or actually blocking user click event before the actual preview and camera is ready to take a photo?

Thanks.

Y.
 

Yvon Steinthal

Active Member
Licensed User
Longtime User
I solved my problem with your example however:

B4X:
Sub cam_PictureTaken (Data() As Byte)
   Dim In As InputStream
   In.InitializeFromBytesArray(Data, 0, Data.Length)
   
   If(Data.Length>0)Then
     
     Dim bmp As Bitmap
     bmp.Initialize2(In)
     In.Close

     Dim out As OutputStream = File.OpenOutput(File.DirDocuments, "eyevudata.png", False)
     bmp.WriteToStream(out,100,"PNG")
     out.Close
     
   End If
 
Upvote 0
Top