splitbrain.org

electronic brain surgery since 2001

Writing /var/www/html/data/log/deprecated/2024-11-07.log failed

Writing /var/www/html/data/log/deprecated/2024-11-07.log failed

Digitizing my Beer Can Collection

Saturday November 11th, 1989 my parents took me for the very first visit in what was known back then as West Berlin. The Berlin Wall had come “down” rather suddenly just three days ago and this was the first weekend after that historical event. Streets were full of celebrating people… and litter.


To eleven year old me all of this was very fascinating of course. And one particular piece of the litter caught my eye: beer cans. In the GDR, aluminum cans for drinks did not exist. Aluminium was a too precious metal to waste on something so mundane…

Bottom of the can The first can I picked up was only meant as a souvenir to remember the day, but somehow I continued to collect more. Throughout the nineties I collected about 370 cans, even though I did not drink beer for most of this time myself. My parents were happy to help out a bit ;-)

Here is an old picture from my room in 1993:

My Collection in 1993

However at some point, I was more interested in drinking beer than in collecting empty cans, so the cans moved into boxes and those boxes moved into the cellar. But I could never bring it over myself to get rid of them. For years I fantasized about digitizing them by building a special beer can scanner. But I never found the time (and skill) to build it.

Photo Studio Setup

This week I decided to finally do it in another way. Instead of scanning them, I would take pictures from multiple sides. Doing something with those pictures could come later.

Of course taking pictures from different sides still needs some kind of mechanized setup. What I came up with is this: An old Raspberry Pi 1, a Stepper Motor with a ULN2003APG controller and a Aukey HD Webcam.

The RPi controls the stepper which has a simple 3D printed platform attached to rotate the can in 8 steps and take a picture for each side. A simple push button lets me signal that the next can is ready.

My improvised photo studio

The code for that isn't beautiful but it worked:

#!/usr/bin/env python
from time import sleep, time
import RPi.GPIO as GPIO
import os
import pygame
import pygame.camera
 
# GPIO pins to use for stepper
pins = [ 24, 25, 8, 7 ]
 
button = 11
 
# stepper sequences
sequences = [[1,0,0,1],
       [1,0,0,0],
       [1,1,0,0],
       [0,1,0,0],
       [0,1,1,0],
       [0,0,1,0],
       [0,0,1,1],
       [0,0,0,1]]
 
# global camera instance
cam = None
 
def setup():
    """ initialize everythin """
    global cam
 
    # use GPIO numbers
    GPIO.setmode(GPIO.BCM)
 
    # set up stepper pins
    for pin in pins:
        GPIO.setup(pin, GPIO.OUT)
        GPIO.output(pin, 0)
 
    # set up button pin
    GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP)
 
    pygame.camera.init()
    camlist = pygame.camera.list_cameras() #Camera detected or not
    print "using camera %s" % camlist[0]
    cam = pygame.camera.Camera(camlist[0],(2048, 1080))
    cam.start()
 
    cam.get_image()
    sleep(3) #wait for white balance
    cam.get_image()
 
def sequence(seq):
    """ execute a single step sequence, eight of them make one step """
 
    # set pins to correct sequence
    for idx, val in enumerate(seq):
        GPIO.output(pins[idx], val)
 
    # give it a bit to move
    sleep(0.005)
 
    # reset all pins to off
    for pin in pins:
        GPIO.output(pin, 0);
 
 
 
def left(step):
    """ do this many steps to the left """
    for i in range (step):  
        for seq in sequences:
            sequence(seq)
 
def right(step):
    """ do thi many steps to the right """
    for i in range (step):
        for seq in reverse(sequences):
            sequence(seq)
 
 
def run():
    out = "out/%s" % time()
    os.mkdir(out)
    for x in range(8):
        # take picture
        cam.get_image()
        cam.get_image()
        img = cam.get_image()
        pygame.image.save(img, "%s/image%d.jpg" % (out, x))
        print "saved %s/image%d.jpg" % (out, x)
        left(512/8) # turn an eigth
 
setup()
while True:
    run()
    while True:
        input_state = GPIO.input(button)
        if input_state == False:
            break
        sleep(0.2)
 
GPIO.cleanup()

It took me quite a while to process all my cans in that way.

All the raw images are checked into a github repository.

Getting rid of the Cans

Now that I have a digital copy, I do not need the physical objects anymore. I could recycle them, but I would rather have a more serious collector to have them.

So for now I put them up on eBay. However since I don't want to ship 4 big moving boxes it's listed as pick up only - we'll see if anyone bites.

The whole collection

Post-Processing

For now I have not done any post processing at all. At some point in the future I'd like to do the following things

  1. turn the images upright
  2. extract the actual can out of the background
  3. detect EAN bar codes and look up data online
  4. use OCR to read labels?
  5. join the 8 different sides into a full texture
  6. create some nice presentation layer on top

Point 2 is actually quite interesting. I wonder how this could be automated. Maybe a machine learning approach could do this?

If anyone wants to help out, feel free to send a pull request.

Tags:
collection, childhood, beer, python, raspberry
Similar posts: