SpaceX Telemetry OCR reading and graphing with Tesseract OCR and matplotlib

This project was to use Google's Tesseract OCR package along with other tools to read telemetry from SpaceX Falcon 9 launches, as broadcast on their livestream. After reading the telemetry from the video stream, it also does some math to get more data values that aren't provided in the stream, like vertical and horizontal velocity.

This was a project done just as some practice with my coding as well as some packages that I wanted to try out.

You can see a video demonstration of it here:

Reading the telemetry with OCR

As mentioned before, the code uses Google's Tesseract package to read the data (https://github.com/tesseract-ocr/tesseract). I had some trouble getting the code to recognize the font that SpaceX uses, but eventually I found some traning data for the OCR that seemed to work. On top of the custom training data, I also needed to do some image manipulation to the image. It was converted to black and white, then the contrast was boosted and borders between colors that were sufficiently significant were highlighted. This helped the OCR recognize the text from the background video.

Deriving horizontal and vertical velocity from total velocity and current altitude

The only two values provided by the SpaceX stream are the current total velocity, and the current altitude. I wanted to also get the horizontal and vertical velocity. The way I decided to do this was to use the altitude over time to get vertical velocity, and subtract that from the total to get horizontal velocity. I took the rolling average of the altitude over 5 samples, with each sample having one second in between them. Therefore, it was easy to get the velocity by adding all the 5 samples together and dividing them by 5, which gives us vertical velocity with no further conversion.

Once that was done, it was as simple as a single subtraction to get the horizontal velocity. You can see these values in the graph on the left in the video.

Graphing the telemetry with matplotlib

This part is fairly simple, just graphing. However, I originally had the altitude and velocities in the same graph, but the altitude in meters is way too large and makes the velocity unreadable, but its also the other way around with the altitude in km. So I had to split up the graphs into velocity and altitude. I could alternatively had used hectometers as a unit of altitude, but that doesn't seem to be as well known as km or m, so I decided not to use it.

Files

Output Reader
OCR Python script
Sample output file
Launch video
Video example