Pages: 1 [2]   Go Down
Author Topic: Please help me with building a paper tape reader (punched tape)  (Read 3195 times)
0 Members and 1 Guest are viewing this topic.
Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 5519
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

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
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 514
Posts: 31533
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
although I still don't understand how to decode images with processing after I read through the site.
When you have an image in processing you can access any pixel in that image just by specifying the x & y co-ordinates.
So all you have to do is to look at one small line of pixels. Identify where the index hole is. Using the mouse down function to print out X & Y on a mouse click is great for finding where you are on an image, to get it all aligned. So you know the place of the middle of the index hole. By looking at the pixel brightness at that point you can tell if the tape is in just the right place so that the other holes are aligned. When this happens just look at the co-ordinates where you know the other holes are and from the brightness you know if they are zero or one.
Processing is fast so you can do this on a frame by frame basis. Treat the index hole just like you would a push button looking for an edge not a level so you don't read the same row of holes in twice.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24430
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Somewhere, I have a dozen or so photodiodes intended as spares for a optical paper tape readers.
Hmm.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: 1 [2]   Go Up
Jump to: