Android Question Spy camera with CameraEX and AsyncStreamsObject

YIM bunchhat

Active Member
Licensed User
Longtime User
Hello all experts Basic4android,

I am new with programming, I want to use AsyncStreamsObject to live video from one phone to other phone as a spy camera. I don't know how to do it and how to start from where? I have ever test Erel's tutorial about CCTV it is very cool but it was use with PC. It is complicate for me to understand.

Please help me......:(

Thank you
 

YIM bunchhat

Active Member
Licensed User
Longtime User
yes I can run AsyncStreamsObject example. it work properly. I try to use CCTV example to send image to AsyncStreamsObject example but it cannot work and maybe I don't understand clear about the way to do this. and on the other hand I said AsyncStreamsObject example connect to CCTV already, but frequently it is flickering connect disconnect connect disconnect.
 
Upvote 0

YIM bunchhat

Active Member
Licensed User
Longtime User
You should first understand how the image is sent and received in AsyncStreamsObject example. The next step is to take the code that captures the images from the CCTV example and merge it into the first example.

Would you mind if I need a sample code? In your CCTV example it work with PC only, Now I only want to use it with Phone to Phone........:(
 
Upvote 0

YIM bunchhat

Active Member
Licensed User
Longtime User
Were you able to run AsyncStreamsObject and send the drawing between two devices?
yes I can, but it just a picture. I is not what I need. I need live video as your example in CCTV. I means one phone capture video and other phone display video.:)
 
Upvote 0

YIM bunchhat

Active Member
Licensed User
Longtime User
Were you able to run AsyncStreamsObject and send the drawing between two devices?
Hello Erel, this is what I have done with sending bitmap from one phone to other phone. Setup it in two phone and one phone is used to receive bitmap must check on check box. It is not what I want to do. I want to send image preview from one phone to other phone via wifi.
 
Upvote 0

blooddiamond

Member
Licensed User
Longtime User
Hello,
I also want to do something like spy camera between two phones. I'm not really advanced in programming using Basic4android but made several small programs. I wanted to use AsyncStreamsObject but i don't know how to send jpeg byte array so I have used AsyncStream such as in CCTV example and when I recive bytes, convert them to Bitmap. Both phones are connected but i receive only one frame per 5-10 sec... Its something like taking photos.. That works so slow..

Can anybody help me ? or tell, how to convert byte array jpeg to a bitmap and than send with AsyncStreamsObject ?

this is my code for receiving :

B4X:
Sub astream_NewData(Buffer() As Byte)
    
      Dim In As InputStream
          In.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
          Dim bmp As Bitmap
    
            Try

                bmp.Initialize2(In)
                In.Close

            Dim r As Rect
            r.Initialize(0, 0, Panel1.Width, Panel1.Height)
            cvs.DrawBitmap(bmp, Null, r)
            Panel1.Invalidate
        Catch
End Try
End Sub


I also Tried to do so with Object but i got error not in program but on phone : "sub: asyncstreamsobject_getavailablefile (java line:179) java.lang.RuntimeException: Object should first be initialized (Map) ...

And that is when i try to convert byte array to a bitmap..

B4X:
Sub Camera1_Preview (PreviewPic() As Byte)
    If DateTime.Now > lastPreviewSaved + IntervalMs Then
        Dim jpeg() As Byte = camEx.PreviewImageToJpeg(PreviewPic, 70)
        lastPreviewSaved = DateTime.Now
     
        Dim bmp As Bitmap
    Dim In As InputStream
     
          In.InitializeFromBytesArray(jpeg, 0, jpeg.Length)

            Try

                bmp.Initialize2(In)
                In.Close
                Catch
                End Try
        astreamO.WriteBitmap("image", bmp)
    End If
 
End Sub

I discovered that an error occurs when i try to send a bitmap using "astreamO.WriteBitmap("image", bmp)"


If anybody want to check my program, i can make it available..
 
Last edited:
Upvote 0

blooddiamond

Member
Licensed User
Longtime User
So.. I worked a lot and made two programs. First with AscyncStreamsObject and second with AsyncStreams in Prefix mode and both works very well but the second is a bit faster :)
Thanks Erel :)
 
Upvote 0

blooddiamond

Member
Licensed User
Longtime User
I use AsyncStreams and bluetooth for transmiting and receiving data with microcontroler.. Can I Use wifi connection and AsyncStreams in prefix mode to get camera view from another phone together with bluetooth connection ? i mean two modes of connection in one program and separately receiving and sending data ?
 
Upvote 0

YIM bunchhat

Active Member
Licensed User
Longtime User
@blooddiamond,

Hello nice to know you here,

I think we have the same idea, I just download and setup B4J. I will try my best. if I have something to know. Could you help me....:)
 
Upvote 0

blooddiamond

Member
Licensed User
Longtime User
What can I add to this thread is that it is possible to make a hotspot on the phone used as camera and connect with other phone without for ex. home network. I mean something like wifi direct.
 
Upvote 0

blooddiamond

Member
Licensed User
Longtime User
It is server-client application wrote by @Erel for ex. in AscyncStreamsObject tutorial. You have to combine it with CCTV tutorial and before sending Byte array convert it to a bitmap ( when you want to do it in AsyncStreamsObject). I made an example how to do it few post ago.
 
Upvote 0

YIM bunchhat

Active Member
Licensed User
Longtime User
It is server-client application wrote by @Erel for ex. in AscyncStreamsObject tutorial. You have to combine it with CCTV tutorial and before sending Byte array convert it to a bitmap ( when you want to do it in AsyncStreamsObject). I made an example how to do it few post ago.
ok now I can do it, thank...:D
 
Upvote 0
Top