jump to navigation

Using CHDK to photograph blackboards in University Courses August 5, 2010

Posted by GuySoft in Crictor, diy, Hamakor, ITU, linux, open source, programming, python.
Tags: , , , , , ,
CHDK in University

CHDK used in university for capturing blackboards

Hi all,
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.

You can see my blackboard photographs here (and here is a simple pdf example, if you get lost in the Hebrew).

How it works in a nutshell

The Work Flow

The work flow - photograph, store, generate pdfs

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.

Screenshot of the CHDK script menu

Screenshot of the CHDK script menu

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 />
<p>#path were the photos should be moved to<br />
DESTDIR = &quot;/media/Elements1/University/camera/&quot;</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 + &quot;DCIM/100CANON/&quot;</p>
<p>#the number, and hte course folder to move it to<br />
course= []<br />
course.insert(0, &quot;infi&quot;)<br />
course.insert(1,&quot;quantum1&quot;)<br />
course.insert(2,&quot;dast&quot;)<br />
course.insert(3, &quot;lab2&quot;)<br />
course.insert(4, &quot;oop&quot;)

Its pretty straight forward. The last list sets which ID number corresponds to which course.

Generating PDFs

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.


1. Tashi - August 6, 2010

I will try to use it. Hope you keep doing lot of such things

2. sole - August 10, 2010

guy , what about using a context based catagorization ?
try using the cameras clock instead of letting the user choose , then you can set it once for each semester and have a fallback to the existing feature


if infi starts at 8AM at monday , the script will look for that time and will set the catagory variable to infi , and so on ๐Ÿ™‚

GuySoft - August 10, 2010

Hey Sole,
Actually, although that seems like a good idea, I do sometimes skip and go to a different lesson switch tutor classes etc. I found that setting it manually takes a split-second and in the long run is more reliable.

3. Tal Perry - February 22, 2011

I’m a math student and have learnt to type in LYX fast enough to keep pace in class. For each class I take i define a set of macros and this allows me to type rather quickly.
You may want to give it a try as it gives the extra advantage of being searchable.

GuySoft - February 23, 2011

I did, but I like mine better. Some things just can’t be captured with macros. I know LYX is popular, I have many friends that use it.

4. Eliran Azulay - May 29, 2012

great work !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: