Partial Images Displayed in Control Panel

Create issue
Issue #2 resolved
Michael Backus repo owner created an issue

OpenCV is not outputting images to the /var/www directory which can now be easily viewed thanks to some jquery in the index.html file. The problem is, partial images are picked up fairly frequently.

Comments (5)

  1. Michael Backus reporter

    I modified the index.html file slightly to reload images via the onload event handler. It looks like no partial images are showing up anymore. I think this is because the browser is now waiting for OpenCV to finish writing the file and uploading the whole think before trying to upload the next image. However, there's still an error every once in a while that causes everything to freeze unless the onerror event handler is added to the mix. With the onerror event handler in place, there's only a quick flash which is distracting but still an improvement.

    I like the simplicity of this approach, but I'd like to improve upon it in two ways:

    1. More intelligent error handling that doesn't cause a flash by showing the previous image. Orion Lawlor suggested toggling between the two most recent images.
  2. Michael Backus reporter

    Some addition reading online suggests that this approach will result in high memory usage as browser cache the images being sent. Would using socket.io fix this problem?

  3. Michael Backus reporter

    In commit 1b31d8e, RoboBeagleBot.cpp is able to display images generated by OpenCV with a lag of just under a second. To prevent flickering, I had to embed the cv code within Wt so that I would know when the image was generated and could update it immediately afterward.

    I'd like to be able to run RoboBeagleBot.cpp without a gui when it comes time to complete (for performance reasons), so I'd like to separate the OpenCV code from the Wt interface using threads. The question is how to go about calling a function within Wt from an OpenCV thread. boost::thread looks promising as does Wt's server::post and triggerUpdate(). The trick is passing a reference to the Wt app object to the OpenCV thread so that I can reference the functions.

    http://antonym.org/2009/05/threading-with-boost---part-i-creating-threads.html

  4. Michael Backus reporter

    RoboBeagleBot.cpp now pushes the image to the client. No flickering and a relatively short delay (less than a second using the Genius 320 Widecam).

  5. Log in to comment