Please help me with building a paper tape reader (punched tape)

kevindorner:
I've done a scan by hand, so it's not very aligned, but if I decide to do it via image decoding, I will build some kind of rail to scan it alligned.

Now that you have it scanned, you don't really need to re-scan it; just convert it to black and white, then write a program to move the pixels from the first "black" pixel to the last right-hand pixel to the left; ie - write software to align it.

kevindorner:
This is the scanned image,
http://cdn.anonfiles.com/1332518421172.jpg
although I still don't understand how to decode images with processing after I read through the site.

Please tell me guys, how would it be easier to write the program, via the arduino or via processing?

Personally, I think it would be easier to write the software; once you have everything aligned, you can use the indexing hole as your "trigger"; the idea would be to:

  1. Scan the image top to bottom
  2. On each line of pixels, look for the color white at the horizontal "center" pixel location for the index hole.
  3. When found, this is the "top edge" of the hole.
  4. Continue to scan until you hit "black" - now you know the height of the hole, so back up half that height (center of hole), and scan that line of pixels.
  5. Check the "horizontal" pixel locations for each of the remaining holes. If the color is white, then its a hole, if black, then no hole
  6. Build a string of 1's (holes) and 0's (no holes) - 8 characters, terminated by a CR/LF (carriage return/line feed), and stuff that into buffer
  7. Starting where you left off in step 4, continue scanning until you hit the color white again (that is, start at the last vertical position of step 4, continuing with step 2)
  8. Scan until you hit the bottom of the image
  9. When you are done, dump the buffer of strings to a text file - DONE.

I don't know what the processing code to do the above would be, but the above is the basic algorithm to use; the basic algorithm to align the images would be:

  1. Scan the image from top to bottom
  2. For each line, scan left to right looking for black
  3. When black is found, copy from that horizontal pixel to the right-most edge (the width) of the image; copy that line of pixels to horizontal pixel position 0
  4. Note the horizontal pixel position you found; create a white line from the right-most edge (minus that length) to the right-most edge (to blank out the extra pixels you moved)
  5. Continue with step 2-4 until you reach the bottom of the image