bsdphk
Experienced Member
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:
github.com
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.
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:
GitHub - Datamuseum-DK/Florida2000: Read punched cards with a document scanner
Read punched cards with a document scanner. Contribute to Datamuseum-DK/Florida2000 development by creating an account on GitHub.
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.