How to Create and Read Your Own 3D Printed Punch Cards with OpenCV

Introduction

Punch cards may be the lowest-density storage medium ever invented, but they offer remarkable longevity and simplicity. As demonstrated by the maker known as Bitroller, a modern twist on this ancient technology combines 3D printing and computer vision. His project encodes 16 bytes of data plus 4 bytes of Reed–Solomon error correction—enough for a password or a private key—and reads the cards using OpenCV through a webcam. The result is a durable, fire-resistant storage solution that can outlast most digital media (especially if printed in stainless steel instead of PLA). This guide walks you through the entire process, from generating the card design to decoding it with your webcam.

How to Create and Read Your Own 3D Printed Punch Cards with OpenCV
Source: hackaday.com

What You Need

Step-by-Step Instructions

Step 1: Prepare Your Data & Generate the 3D Printable File

First, decide what information you want to encode. The card can hold exactly 16 bytes (128 bits). Bitroller’s generator script automatically adds 4 bytes of Reed–Solomon error correction, making the total payload 20 bytes. This error correction can recover up to 2 corrupted bytes during reading.

  1. Run the generator script: python punchcard_generate.py
  2. When prompted, enter your 16 bytes as a hexadecimal string (32 hex characters) or a plain ASCII string (16 characters).
  3. The script outputs an STL file or a g-code file ready for 3D printing. The design consists of raised bumps (representing binary 1s) and flat spots (binary 0s) arranged in a grid.
  4. Save the file with a descriptive name, e.g., mypassword.stl.

Step 2: 3D Print the Punch Card

While the original punch cards were literally punched with holes, your 3D printed version uses raised bumps. The contrast between the bumps (light-colored) and the background (dark) is what the camera sees.

  1. Load the generated STL file into your slicer software (Cura, PrusaSlicer, etc.).
  2. Set layer height to 0.2 mm or finer for best detail. Use a infill of at least 20% to ensure rigidity.
  3. Choose a light-colored filament (white, yellow, or light gray) to maximize contrast with your dark reading surface.
  4. Print the card. It should be about 50×50 mm and 2–3 mm thick. If using stainless steel, follow the manufacturer’s guidelines (requires a specialized printer).
  5. Allow the print to cool completely. Clean any stringing or blobs with a knife or sandpaper.

Step 3: Set Up the Reading Station

The key to reliable reading is a controlled, high-contrast environment. The webcam will detect the pattern of light (bumps) against dark (background).

  1. Place your dark matte table or surface under good, even lighting (avoid direct sunlight or harsh shadows).
  2. Mount your webcam directly above, pointing straight down at the table. A distance of 15–20 cm works well.
  3. Ensure the camera’s field of view covers the entire card area. You can test by placing a bright object on the table and confirming it’s visible.
  4. (Optional) Stick a piece of black paper or adhesive vinyl on the table to create a perfectly uniform dark background.

Step 4: Run the OpenCV Reader Script

Bitroller’s reader script uses OpenCV to capture a live image from the webcam, find the card’s corners, warp perspective, and decode the bumps.

How to Create and Read Your Own 3D Printed Punch Cards with OpenCV
Source: hackaday.com
  1. Launch the reader script: python punchcard_read.py
  2. A window will open showing the live webcam feed. Place your 3D printed punch card on the dark surface, within the camera’s view.
  3. The script automatically detects the rectangular shape of the card. It highlights the card with a border and then processes the interior grid.
  4. When it finishes reading, the decoded 16 bytes (plus error correction status) will be displayed in the console. If the error correction is successful, you’ll see the original data.
  5. If the script fails to detect the card, adjust lighting, ensure the card is flat, and the background is as dark as possible. You can also manually adjust the contrast threshold settings in the script (see comments).

Note: The reader is massively overkill compared to historical punch card readers—it’s using a modern computer to do what would have required a supercomputer in the 1960s. But that’s what makes this project both fun and practical.

Tips & Best Practices

With these steps, you can build a tangible, durable backup for your most critical digital secrets. The combination of modern 3D printing and computer vision revives a legacy storage method in a way that’s both fun and surprisingly reliable.

Tags:

Recommended

Discover More

10 Things You Need to Know About Data Normalization: Risks, Trade-offs, and AI ImplicationsIreland Joins the Artemis Accords: A New Chapter in Space ExplorationTech Lead Reveals Simple Documentation Fix for AI-Generated Code That Passes Tests but Breaks ArchitectureHow a Pair of Mismatched Exoplanets Found Stability After Travelling Inward from the ColdBreaking the Chatter: How Disrupting Bacterial Gossip Could Prevent Gum Disease