In order to let us see what the car is doing, we needed a way to stream data between the car and a server. Having googled around, so far, two methods fit the bill.
First – C++ server → Websocket → HTML5 Client
This seems to be the best solution (if working) for the project as the clients can have the comfort of their HTML5 – supported browser ( while using Facebook at the same time) without any extra installation. Decided to follow the method implemented here:
Streaming from a fixed video works well. There wasn’t any frame drop or lag, and it works for mp4 and ogg formats. In order to stream captured videos, I’ve used OpenCV to capture frames, then writing every frame to video container using the built-in OpenCV VideoWriter and writeframe(). Ogg was used as the extension in this case as OpenCV doesn’t have any codec to write MP4 files. As the writing happens, it is streamed through the server mentioned above.
At the receiving end, results doesn’t look good at all. There is a massive lag and delay in the video received. This is expected as there are overhead from file I/Os, encoding and network delays. After some googling, there doesn’t seem to be a better solution in solving this problem at the moment as OpenCV doesn’t allow writing frames to memory instead of files. On the bright side, the recording from the webcam is playable and seems to be real time. We might incorporate this method into the project as part of recording the journey of the car.
- Video stream is in colour
- Can be accessed through a browser
- Supports many devices
- Streaming is recorded
- Streaming is sluggish, massive delay of 30 seconds
Second Method – C++ Server → Websocket → C++ Client
Anyway, moving on, instead of streaming encoded data, I’ve decided to try streaming OpenCV data instead. The downside of this method is that the client end has to have OpenCV installed instead of using the more available browsers. Managed to stream data using the method from below :
- Faster speed
- Much lesser delay (about 5 seconds only)
- Doesn’t require a server to be setup.
- At the moment, image viewed is in gray-scale. (Working on color streaming)
- Presence of delay defeats the objective of real-time
At the moment, the second method is better than the first method in displaying video obtained from OpenCV. More options to be explored, hopefully its better than these 2. Results to be uploaded soonish in the future.