Using CHDK to photograph blackboards in University Courses August 5, 2010Posted by GuySoft in Crictor, diy, Hamakor, ITU, linux, open source, programming, python.
Tags: chdk, diy, hacking, open source, programming, python, university
During last semester I developed a set of scripts that lets me photograph pictures of the blackboards during my university courses, categorize them while I am taking them and automatically generate PDF document for each course week. Because physics equations are not the simplest things to input in to a laptop in realtime, I have developed the following method. I am writing the post because I have a feeling this tool could help people in many ways, since it did change how I study in lectures.
How it works in a nutshell
During the lesson I take the photographs of the blackboard with a script I wrote for CHDK. In the script you set the course and week of the semester and this is stored per-picture on the SD card.
When I get home, I can quickly clear the card using the build.py script, moving the pictures to my computer, I might be taking dozens of photos a day, so its useful to do this a few times a week. The images are automatically stored in corresponding folders (e.g. /camera/coursename/pics/week1/ ).
Once the images are in the directory structure, all that is left is to generate PDFs from each ‘week folder’. There are quite a few things taken in to account here, due to the fact that the images are resized for fast PDF rendering, to setting the temporary folder of Imagemagick (it needs a few gigs to generate the PDFs!). The final outcome is a PDF file per-course per-week. From here I will go in to the technical configuration.
What you will need
- Canon powershot camera running the CHDK software (Cannon Hack Development Kit). I use a Cannon powershot A590
- Python + bash (+ Linux)
- Imagemagick installed (the convert command)
- Free space is important (both for PDF generation and storage of your photos)
Setting up CHDK script
I will not go in to the details of installing the CHDK, I wrote about this already, and its a post I recommend you read!
Once you have CHDK running on your camera you will need to use this script for shooting pictures (copy it to /CHDK/scripts and load it).
The script lets you pick the course and week, you can edit the script to have a little abbreviations for courses. For example (line 3 in blackboard.lua):
@param c Course (0=inf,1=QM,2=ds,3=fn,4=op)
It will give you a message each time you photograph with it.
The script saves files with the images filenames to the LOGS folder on the card, containing the course ID and week number.
Importing you photos from the camera automatically
Using the build.py will move all the photographs from the camera to the disk, you will need to set a few things in its header, here is how the build.py file looks:
### configuration ###</p> <p>#path to which the camera is mounted<br /> cameraMount="/media/CANON/"</p> <p>#path were the photos should be moved to<br /> DESTDIR = "/media/Elements1/University/camera/"</p> <p>#path where the photos are in the camera (you might need to change this if you took more than 1000 photos)<br /> PICDIR = cameraMount + "DCIM/100CANON/"</p> <p>#the number, and hte course folder to move it to<br /> course= <br /> course.insert(0, "infi")<br /> course.insert(1,"quantum1")<br /> course.insert(2,"dast")<br /> course.insert(3, "lab2")<br /> course.insert(4, "oop")
Its pretty straight forward. The last list sets which ID number corresponds to which course.
The script to generate the PDF is called genpdf.sh, It basically scans the folder and generates the pdf files using imagemagick, it also creates a small file with the picture list, so it only generates when there is a change. Generally useful script! I recommend you set the temp folder that it uses for the generation to be somewhere on your disk (and not just /tmp), because it can take as much as 10GB sometimes to generate!
Here is the settings header:
#this temp dir is where the PDF are generated, it can reach gigabytes! so its recommended to set it to a place with space<br /> export TMPDIR=/tmp</p> <p>#path where the images are saved<br /> PICS_DIR= /media/Elements1/University/camera
Camera setting tips – How not to blind your lecturer
If you are using this tool, here are just a few minor tips for getting a good result:
- First use the manual setting in the camera (the M option). If the course is in a closed lecture hall you can tweak the exposure time to get better resultes. As you can see I also set the picture to grayscale.
- Make sure to set the flash off! Also you can set the AF-Assist beam off (its the red light on the camera). The manual setting remembers these options, so this is useful too.
- I personally try not to photograph lecturers, I suggest you do the same.
What courses are good for this method? – Tips for Lecturers
I found that some courses are better than others to photograph, usually if you have a tidy lecturer who doesn’t erase in the middle of calculations, then you tend to get a good result. Also there are some lectures that think that the whole lecture can be done with equations only, no text. Those lectures tend to be much harder to follow, I would really suggest that they add notes, it tends to help everyone. Even a tiny title over a calculation can really change things, students don’t always follow.
That’s it! This technique really changed how I study in university, I am sure there are ways to improve the process and the code or use this for another things. I would love to hear feedback and would be glad to assist anyone attempting this.