Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm working on a project which includes an Arduino camera that broadcasts its video through wifi, connecting to the camera URL.

When watching the stream from a browser, I get about 15 fps. I've gotten my c# application to load the image from the URL and to show it to a picture with
image.Load("http://192.168.4.1/jpg")
but it takes at least one second to show each frame.

Is there a way to download the images and save them somewhere so I can load them faster, or to get a picture element to stream from a URL?

What I have tried:

To load each frame, I use a timer that activates the previous code. However, it gets to a point where lowering the timer interval doesn't make the image load faster, but i don't know what solution could be implemented or what makes the image load so slow (when loading images from two different static URLs intercalated, with much more quality, they loaded faster).
Posted
Updated 7-Feb-21 6:37am

Basically, we can't help you - we have no idea what you are doing with the image, and no access at all to your local network or the computer it is loaded on - but loading a video of any form frame by frame as separate images is never going to work at high speed. Or pretty much any speed ...
Images are compressed, but very differently from video streams - they work by sending differences between this and the previous frame, so they have a whole load less data to transfer. Images aren't like that - they hold the whole image in each frame and so need a lot more processing, and a lot more data transfer.

Though even then one fps does sound very low and I'd suspect there is a whole load going on that you aren't telling us!

I'd start by looking to see if there was a way I could access the actual stream instead of relying on frame-by-frame data.
 
Share this answer
 
Comments
MRS_ 7-Feb-21 11:57am    
Sorry for the missing information, this was my first time here.

I know you cant access the URL, it was just to show the method I used.
This camera (esp32 Arduino wifi cam) works in the following way: You connect to the wifi it emits, open the link I used from a browser for example, and it shows the image from the camera. I suspected the problem was about getting the image frame by frame, thanks for confirming that. Actually, the camera has two "modes", image ("http://192.168.4.1/jpg") and stream ("http://192.168.4.1/jpg_stream").
That's why I asked if I can load a stream into a picture element on Windows form application, because I've been searching but I cant find a method.

As to what I do with the image: using aforge, a library to identify objects in images, I use the image that I loaded in the picture to search for squares. That part works well at least.

I hope this information helps and thanks for the answer!
Luc Pattyn 7-Feb-21 12:09pm    
If by "picture element" you mean a PictureBox, I would advise against that silly Control; just use a Panel and draw its content yourself.

I hope you measured the time your library takes to analyse a single picture.

And as long as you work frame by frame, this is a situation where you absolutely must pipeline the whole process; which means using threads and proper synchronisation.

Finally, there are lots of nice articles on CodeProject, maybe you'll like some of these.

:)
MRS_ 7-Feb-21 12:18pm    
Precisely I got the tracking part from the second article you linked!
Seems like a really powerful tool and I don't think it takes much more than a few milliseconds.

Yes, I meant PictureBox, but ill try the panel, thanks!
About using threads, I already used them (I think). I created a task to load the image while rest of my code ran, so it doesn't stop the other processes, but i don't have much experience on c# so it definitely isn't that optimized.

I'll investigate if there is any element in which I can run a video from a URL, and Ill look into more articles

Thanks for the ideas!
Luc Pattyn 7-Feb-21 12:29pm    
May I suggest more facts and less think. :D
RTSP streams are commonly used, see if your camera supports these.
Here is a CodeProject article about it: Stream Player Control[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900