B4J Question CCTV server - blinking ?

derez

Expert
Licensed User
Longtime User
I checked the cctv server and got the pictures from few cameras on the browser display.
Can the blinking be reduced ? (the screen clears and shows again )
 

derez

Expert
Licensed User
Longtime User
It was on debug. With release the update is faster but it still blinks. I guess it must be as the screen is recreated all the time. ( Erel - you can check with my link)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It blinks because of the way the html is built. It sends a request every 500ms to GetImages. GetImages returns a short html snippet with the <img> nodes.
At this point it replaces the existing <div> thus removing the existing images.
Now the browsers sends two requests to download the images.
This causes the blinking.

There are two ways to solve it. You can change the JavaScript code to download the images to a hidden div and then replace the two divs.

The second solution is to encode the images directly in the response as base64 strings.

Change GetImages class to:
B4X:
Sub Class_Globals
   Dim su As StringUtils
End Sub

Public Sub Initialize

End Sub

Public Sub Handle(req As ServletRequest, resp As ServletResponse)
   For Each ip As String In Main.images.Keys
     resp.Write("<p>").Write(ip).Write("</p>")
     Dim img() As Byte = Main.images.Get(ip)
     resp.Write("<img width=500 height=300 src='data:image/png;base64,") '<--- this tells the browser to decode the base64 images.
     resp.Write(su.EncodeBase64(img))
     resp.Write("'/img>")
   Next
End Sub

You can remove GetImage handler as it is no longer used.
 
Upvote 0

derez

Expert
Licensed User
Longtime User
I'm trying to use my old devices (android 2.2) as cameras but they even do not initialize the camera with the regular camera library. Any solution for this ? (they have camera but I can't control it)
 
Upvote 0

derez

Expert
Licensed User
Longtime User
I know and they can't be upgraded.
By the way - duckdns report
Error updating Duck DNS: Service Unavailable: Back-end server is at capacity
when updating the IP in FileServer
 
Upvote 0

derez

Expert
Licensed User
Longtime User
Got no-ip account as well and it works fine. It has a stand alone updating program so may be it is better.
 
Upvote 0

derez

Expert
Licensed User
Longtime User
A question -
When starting the server I get for few minutes a series of "old" pictures over and over, until it sends only the last one. Can the server reset the map when restarted ?
 
Last edited:
Upvote 0
Top