Android Question Two Camera Previews

treehousefrog

Member
Licensed User
Longtime User
Hey guys,

Another very random question I know! I'm looking for a way to show a camera preview on two separate panels within my application... is this possible? I've been taking a look at libraries and come up with nothing. Even if I could just somehow get one panel to mirror what was on the other panel that would work... Thanks a ton in advance
 

treehousefrog

Member
Licensed User
Longtime User
Thanks Erel That's roughly what I'm doing (except loading the same BMP into both panels to avoid difference in FPS). I think there must be some way to do it more smoothly though as I've seen it in a couple of other camera apps. I will check out the reflection library. Anyone got any pointers on where to start there?

This is the code I'm currently using (Camera22 is initialized to a panel way off screen). Is this the fastest way to do it? Thanks again for your help, this is a v exciting project I'm working on currently

B4X:
Sub Camera22_Preview (PreviewPic() As Byte)
        Dim jpeg() As Byte = camera22.PreviewImageToJpeg(PreviewPic, 20)
   
  Dim In As InputStream
  In.InitializeFromBytesArray(jpeg, 0, jpeg.Length)
 
  Dim bmp As Bitmap
  bmp.Initialize2(In)
  In.Close
    camera2panel.SetBackgroundImage(bmp)
    camera1panel.SetBackgroundImage(bmp)
   
End Sub
 
Upvote 0

treehousefrog

Member
Licensed User
Longtime User
Adding back the: If DateTime.Now > lastPreviewSaved + IntervalMs Then...

From your example has helped a lot. Is there anything else I can do to increase speed? Thanks!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…