• Please review our updated Terms and Rules here

Florida2000.py - Read punched cards with a document scanner

bsdphk

Experienced Member
Joined
Jun 2, 2024
Messages
88
Location
Slagelse, Denmark
Some years back I wrote a Python2 script which could read the holes in punched cards scanned on a document scanner, but I was not satisfied with it.

Last week I got a reason to revisit that problem, and the result is a new Python3 script, only 400-some lines long, which does a perfect job on this batch of 800+ cards.

It would have been best to scan the cards in "landscape", but our scanner's feeding mechanism requires the documents to be 4" or longer, so we are forced to scan them in "portrait."

Last time I scaned the cards "head first", but since the scanners feed/detection mechanism is imperfect, I could not reliably detect the front edge of the card.

This time I scanned the cards "tail first," got perfect undistorted scans of the front edge, and code to find the holes in the scanned image became almost trivial.

The code expects the holes to be dark, so you use a flat-bed scanner, put a dark piece of paper on top of the card.

The code expects scans of both front and back, and complains about any differences in detected hole-patterns.

It goes without saying, that this concept can never reach a guaranteed 100% read rate: Black card stock, while unusual, was perfectly legal. People wrote on punched cards with big fat speed-markers and Institutions had big black logos printed on their cards, but for now I consider the problem solved.

The Hollerith→EBCDIC table is copied from Open-SIMH, for which I am grateful.

Enjoy:


Poul-Henning

PS: I have not yet decided what preservation file format we should use for punched cards in Datamuseum.DK.
Bitsavers seem to use the Open-SIMH "binary" format with ".crd" extension, and I'm strongly inclined to follow suit.
 
Is there anything special about how to feed it the card images? My Fujitsu scanner has an ADF but will only let me define a filename sequence ending with a number. (file001, file002, file003 etc.)
 
Fortunately, you didn't have to deal with decks that had mixed or wrong edge notches.
The 1401 guys came up with a mod to the Documation to not complain if the notch was on the wrong edge

There are also some scanners, like my Panasonic, that let you drop a black background instead of white.
 
Is there anything special about how to feed it the card images? My Fujitsu scanner has an ADF but will only let me define a filename sequence ending with a number. (file001, file002, file003 etc.)
No, it just takes whatever filenames you give it, and process them in pairs of two (front+back)
But the main() function is trivial, so you can change it to work any way you want.
 
There are also some scanners, like my Panasonic, that let you drop a black background instead of white.
I think our Sony has similar options but I have never tried them out.

I wonder if it is just a flood-fill from the outside (which would miss the holes) or if it actually turns on a backlight ?
 
Back
Top