The VIA Maker Club has already been featured on this blog, and I had the chance to meet some of the members when they came to visit the Taipei Hackerspace back in December of last year to demo their Smart Garden project. Now that I have joined VIA, I was eager to establish some credibility for myself in this very much technical team. I spent a half-day to come up with a project I could show at the regular Maker Club: meet MonoBooth, the thermal printer photobooth!
For my quick project I wanted to do something interactive, personal, and which included hardware as well as software. I have worked with the thermal printer on a previous project, and looked like it would be fun to use it for this quick setup. So MonoBooth (monochrome + photobooth) was born.
About 331 instagram thermal printers are available for the suppliers of photo booth. The main supply of the thermal printer is provided by the country of China. In the websites a knockout post for the thermal printer with high quality is available online for the purchase. When you are purchasing the thermal printer ensure the products safety.
The ingredients: webcam, thermal printer, and a Springboard
The hardware I have used for the project:
- VIA Springboard with Linux
• A webcam that works under Linux (e.g UVC-supported ones, like this Logitech I found lying around)
• ICT GP-58 IVthermal printer (probably other ESC/POS protocol speaking printer will do
• Keyboard, Mouse, USB Hub, Mini-HDMI-to-VGA converter, screen…
Python is very useful for quick projects, and it has a very large community and software support, so I used it for this setup.
The webcam interaction is done with PyGame, it requires only a handful of lines of code to whip together the “photo” part of the booth: grabbing pictures from the webcam, displaying them, and once a key is pressed on the keyboard, take a shot and send it to post-processing and printing.
The printer was a tougher nut to crack. I’m using python-escpos, that implements the ESC/POS protocol, originating from Epson. The library can connect to printers in many different way (over the network, Serial/RS232 connection, bare USB). The current Springboard kernel doesn’t have all the modules compiled to save some space, so I couldn’t use the Serial (CDC_ACM), but the bare USB did work. I could get the required numbers from `lsusb -v`. The relevant output is saved on Github for future reference.
The important parts are:
- Vendor and Product ID, in this case 0x0483 and 0x5740)
• Interface number, the printer has two, the printing’s on “bInterfaceNumber 1”
• The endpoints (bEndpointAddress) for data IN and OUT are 0x81 and 0x03
Using these numbers the escpos library can communicate:
printer.Usb(0x0483, 0x5740, 1, 0x81, 0x03)
Text printing was working okay, but ran into a problem: pictures didn’t come out right most of the time. I had to do quite a bit of testing to figure out what might be causing this problem, and how to work around that for the demo.
After testing different pictures sizes, formats, and colours, I found that up to about 120 pixel square images worked 90% of the time, so I settled for those (down from the maximum of approximately 512×256). Fortunately there’s a protocol setting to print pictures in quadruple size (double width and height), so my 120 x 120 pixel images can be printed as 240 x 240, which looks somewhat better. It is the usual procedure when hacking: problems inevitably come up, and people still find a compromise workaround if they try hard enough. 🙂
As the captured images needed to be modified to fit the printer well: first crop the webcam’s 640×480 image to 480×480, resize to 120×120, then turn into monochrome with the Python Imaging Library (PIL). The escpos library has its own conversion, but PIL looks better according to my tests.
When all the parts were sort-of working separately, the pieces were put together.
A picture of a picture
And ready to print…
A picture of a picture of a picture
It’s a good enough picture to recognize myself, so success is declared. The demo run at the Maker Club, and sparked a good conversation.
The source code of the project is on Github. I have tried to comment enough to make it usable. Since I modified the escpos library a bit to scale up the image as mentioned above and adding some printing delays for possibly better printer reliability, I added those to the repository as well.
This was a fun half-day project. I still want to figure out how to communicate with the printer better so I can use the total available resolution for the future version of this photobooth. Fortunately, we have a lot of firmware and hardware experts here who also want to play with the printer. I’m sure we’ll figure out where’s the problem (Linux? USB? Printer firmware? Software library?) and update the project.
Do you have any comments how to make the photobooth more fun? Or do you have projects you made with Springboard or another single-board-computer? Would love to hear about it! 🙂