Converting Webots image into a BMP file
Image processing is an important part of the Webots simulation world. During the RoboCup Demonstration Rescue Competition, our team designed a Victim Detection Algorithm using OpenCV. In the past few months, Victor from our team has worked on image processing using C. He has been working on algorithms such as grayscale, binary, histogram, edge, and contour tracing. By making our own algorithms, we do not have to use the OpenCV library, which gives us the ability to embed image processing into different boards.
Victor tested his image processing algorithms on a Webots world since this could potentially provide an advantage over other teams, as the image processing could be faster and more reliable. In addition, by seeing the Webots image, we could then use it to test different algorithms or visualize ideas differently.
Victor wrote the Webots image into a file, and then read the BGR channels into the bmp image.
One of the challenges was in getting a BMP file format. This problem by solved with reading a BMP image first, and then overwriting the data. By getting an image of the same bitsize, height, and width, he was able to simply write the data onto the image without writing every byte.
The end result was an identical new image that could be used as another method for Webots testing or algorithm making.