I’ve been experimenting, after a long break, with jp2a again, converting captured images into ASCII representations, which are then sent to a local printer. I remember, long ago and as a child, having my face printed onto a t-shirt in Blackpool. The ASCII character set made up the individual “pixels”.
With this experiment, I’ve used an old Deskjet 930c printer and a cheap USB web cam.
From a software point-of-view, I’ve installed the following:
- CUPS – The Unix Printing System
- jp2a – Takes a jpeg image and turns it into ASCII text
- GUVCVIEW – captures images from a webcam
- Figlet – to create the text for an interesting banner at the bottom of the page
“lp” is the command that sends this text to the printer. There are loads of command line options available. I’ve wrapped this all up in a bash script and set it to run from the command line by making it executable.
To make this all work, I capture an image and it gets saved as my_photo.jpg. I then run the script shown above, typing ./printphoto.sh and the printer spews out a rendered version of whoever is in front of the camera. Neat… and I’ll demo it at the next Raspberry Jam.
Future options would be to use a big button to start the whole process off. I’ve done it before, but there’s not enough time remaining for that.
All of a sudden the startx command resulted in a crash. I had updated and upgraded and wondered if that was the problem… Or was the card corrupted?
One train of thought was – Is the card full?
and there it was: 100% full!
I didn’t want to remove any of my files so somewhere in the back of my mind I remembered that apt-get keeps a cache of all of the downloaded packages. How to clean up? A quick search revealed all I needed was:
sudo apt-get clean
A blink of an eye later and my SD card was reporting 84% full with a saving of 560Mb. Just what I needed and startx performs normally again. Excellent news!
I’ve often been asked about what bits are useful when setting up the Raspberry Pi, so I’ve put in a load of links here to places that might help. It’s a bit random, needs formatting and tidying up. At least I’ll be able to find the stuff easily. Some of the stuff has been directly culled from their respective websites. I’ve tried to reference these directly in places where I can remember.
Continue reading →
It’s been a little while since the last blog entry, but it’s given a little time to considering the next experiments in Pi cookery.
Webcam capture converted with jp2a
I’ve been giving some thoughts for what I could bring to the next Exeter Raspberry Jam (7th June 2014 – 10am). One thing that might be popular is to combine a few tools, a webcam and a printer and create an ASCII photo booth. It would make an interesting flip-side to the high-end megapixel cameras and could also possibly be thought of as art.
So how to do it?
Experiments so far:
I’ve had success with the tool “motion” taking regular images from a USB webcam and saving them to SD cards. I’ve had success with making these visible as JPEGs (Even using Motion’s built-in webserver). I thought I would try some other commands to take just one image from the webcam and process that on demand. What a disaster!
I’ve tried “uvccapture” and also “fswebcam” – both of which seem to give me a headache. One reports an ioctl error and the other produces images that are too dark. I’ve tried a couple hours of fiddling and didn’t see an improvement.
- Currently, what seems to work is to capture images every 2 seconds using motion. I don’t need it to do much else, although the webserver might be handy for viewing full colour previews in future.
- I can then use “jp2a” to show an ASCII version of the jpeg image
- I can use “jp2a –background=light” to create a file that would use black characters on a white background.
- I can use “cups” and the “lpr” command to send the image to a printer.
- I’ll connect a big fruit-machine type button on a GPIO input for triggering the shutter and printing.
- I’ll join it all together with Python, perhaps using “figlet” to generate on-screen instructions.
Other interesting things I’ve discovered: We have a Windows 7 laptop with the printer connected – and shared. For some reason, it seemed more straightforward to connect the Raspberry Pi to the shared printer using CUPS over the network than it was to connect a Vista laptop. I don’t know why this might be – perhaps I’m too short-sighted technically here – but surely the same family of operating systems should be easier? Ho hum…
I’ll post the results of my experiments here later, but that’s another story yet to come!
Link to PDF of interesting programs to install
I’ve found some interesting little bits that make an interesting introduction to the command line. They’re simple to use on their own, but with the addition of a pipe (the | symbol next to the Z key) it’s possible to use them to display results in a more impressive fashion.
To install, use the following:
sudo apt-get install cowsay
sudo apt-get install figlet
sudo apt-get install toilet
sudo apt-get install boxes
sudo apt-get install espeak
sudo apt-get install fortune
The attached files show how to use each of these. Alternatively a manual for each of the commands can be shown with the man command – eg: