Tuesday, November 1, 2022

Raspberry Pi Camera - Color ASCII Real-time Preview for command line


I'm working on a project with my son that uses a Raspberry Pi camera to detect people, identify them, and then shoot them (with a NERF bullet via a turret) if they are not "authorized". 

I'm using an older RPI 3 B+, and like many PIs it has it's limits. To save on resource usage, I decided I would forgo the desktop. After a bit, I realized that there wasn't a great way (I could figure out) to preview my PI camera footage for the purpose of taking pictures of faces to train a CV model. 


In the past, I had seen some ASCII art, and so I thought, "why not build a live camera preview rendering out the frames as ASCII?" shortly after with "and in color!"

This was my first time working with curses, which prove to have it's own little nuances, but isn't terrible. 

Feel free to comment if you have any improvements. The colors are interesting and could probably use some love. Also, I'm sure there are some optimizations that could be done to improve overall performance. 


To improve render performance, you can set use_color = False, but you might have a harder time seeing the image. 


Compare ASCII color preview with capture

Testing out ASCII color w/ change to night vision

No comments: