Closed hansworst24 closed 8 years ago
Fully implemented !
Hello hansworst24, below a bit of code that can help you or improve ticz (try before to be sure :-) ) I was using this method to update image in my old personal windows phone app (I created it for my wife 1 year ago, but as username and pwd are in the code soI never publish it into windows store). I think, this method is fastest to update image :
` Async Function UpdateImg(im As String) As Tasks.Task Try Dim Generator As System.Random = New System.Random() Dim Uri = "https://" & MYDNSNAME & "/camsnapshot.jpg?idx="+im+"&t=" & Generator.Next Dim httpClient As New HttpClient() Dim contentBytes As Byte() = Await httpClient.GetByteArrayAsync(Uri) Dim memoryStream = New MemoryStream(contentBytes) Dim bitmap As New System.Windows.Media.Imaging.BitmapImage bitmap.SetSource(memoryStream)
Select Case im
Case Is = "dlink"
imgdlink.Source = bitmap
Case Is = "foscam"
imgfoscam.Source = bitmap
Case Is = "heden"
imgheden.Source = bitmap
Case Is = "dlink2"
imgdlink2.Source = bitmap
End Select
Catch
End Try
End Function
Private Async Sub dispatcherTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) Await UpdateImg(CamSelected) End Sub`
I hope that will help...
Hi tivax !
The latest versions of Ticz support cam's already. Does it not update fast enough for you ? The only real cam I could test with is an rpi cam, and it gives 15KB big snapshots, which seems to stream nicely when the refresh is set around 100ms in Ticz
Nevertheless I will make a comparison with your code and mine, to see if it makes a difference. I stole my code from somewhere else, which actually was ment for a MJPEG implementation. I altered it myself to work with single JPEGs :)
Hello hansworst,
The ticz picture update seems to be slower than my app especially when I am connected to cellular network (4G), it looks like ticz does not display the pictures if it is dowloading a new picture, so the first picture is fixed (because ticz is still downloading a new one)
perhaps is due to the fact that your code allows to refresh several cam pictures as the same time (even just one cam "refresh" is enabled) so due to the fact that your code below is Async
Await RunOnUIThread(Async Sub() Dim newFrame As New BitmapImage Using RandomAccessStream As InMemoryRandomAccessStream = New InMemoryRandomAccessStream Await RandomAccessStream.WriteAsync(imageStream) RandomAccessStream.Seek(0) If Not RandomAccessStream.Size = 0 Then Await newFrame.SetSourceAsync(RandomAccessStream) End If End Using WriteToDebug("CameraViewModel.GetFrameFromJPG()", String.Format("Frame rendered for camera : {0}", name)) frame1 = newFrame RaisePropertyChanged("frame1") RaisePropertyChanged("FrameSize") RaisePropertyChanged("TotalFrameSize") End Sub)
If you don't know the API for domoticz cam, I am using it for a big while in my personnal website for 4 Ipcams : $.domoticzurl+'/camsnapshot.jpg?idx='+MonIdx+'&t='+Math.random();
I found this API with firefox develloper tools by analysing the domoticz cam webpage