There’s no free lunch in this world. You know that already, don’t you ? Well, so do marketers.
Unlike other brands though, Sprite recently had the courage to tell it out loud in the first promotion that tells the truth about, well, promotions.
The campaign “Prizes that advertise for us”, developed by McCann Bucharest has Sprite super over-branded prizes up for grabs. And if you think the consumers would never want an over-branded prize, think again! These over-branded prizes can get pretty crazy: like a photo camera that takes pictures only with huge Sprite logo watermarks on them, a car with a gigantic bottle on top or a cuckoo clock that sings “Sprite” whenever the clock strikes 12 are just some of them.
In the following we’ll tell you how together with McCann Bucharest we got through our first challenge: creating a custom photo camera from scratch using the Raspberry PI camera as the active sensor (with optional automatic image processing).
The requirements we initially had
The camera should be able to store the photos on a USB memory stick, should be really simple to use and should be powered by a rechargeable battery.
Each photo must be processed before saving it to the USB memory stick (e.g. by adding the “Sprite” watermark automatically).
Of course, the core – the Raspberry PI Camera.
Next comes the Raspberry PI board. We could have used the A variant instead and further extend battery life, but we were afraid on the memory required for the OpenCV processing, so we just used the 512 MB B board.
For the power source, we’ve decided to take no risks and go for the off-the-shelf Colia mobile phone external battery (“Colia Power Stick i2400”). It already has in place all the safety stuff you need when using LiPO batteries (like auto-shutdown when empty and safe built-in USB charging mechanism).
For an extra-touch, we’ve added a small audio speaker playing “Sprite !” for each photo you take.
The green case was resin casted specially for this project.
The hardware assembly
Basically, there are short USB cables connecting everything inside to the outside world. A mini USB cable with the inside wires exposed is connected to a Sparkfun Mini USB Breakout Board to create the external USB charging port and a USB cable extender is glued in the case wall and connected to the Raspberry PI USB port as the USB stick port. The nice side-effect there is that you can simply replace the USB memory stick with a WIFI USB dongle and be able to access the Raspberry PI inside the camera by SSH, no need to open the camera case. We have even prepared a WIFI router specially for this project, to debug and alter the software on the PI on the go.
We’ve removed the audio speaker case and separated the amplifier PCB board and the speaker itself due to space constraints.
The ON / OFF switch is simply connecting the Raspberry PI to the external battery (using a USB cable plugged in the battery and having the inside wires exposed and soldered to the other end). Luckily, the battery automatically starts delivering current when connected to the PI and shuts down when the PI is disconnected, so nothing more to do here.
The shutter button connects directly on the Raspberry PI GPIO18 pin with a 10K pullup resistor. Same for the status led which is connected to the GPIO23 pin through a 500 ohm resistor.
The audio speaker is connected directly to the audio out Raspberry PI jack (had to cut the original jack a bit, not enough space in the case).
Taking a basic photo with the Raspberry PI camera is nothing complicated. However, balancing the ISO, exposure and automatic white balance so that you always get nice results IS quite complicated. Remember, we want the camera to be really really simple to use. This blog post helped a lot. After running the script there and evaluating each parameter combination under different lightings and environments, we have decided for a short “sports” exposure, “auto” white balance and a medium ISO value.
Pressing the shutter button just takes a photo and saves it on the memory SD Card. At the same time, it plays a short MP3 “Sprite !” tune as a confirmation for the photo being taken, as below.
The Python script which takes the photo
#!/usr/bin/env python import time import os import RPi.GPIO as GPIO import subprocess GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.OUT) GPIO.setup(18, GPIO.IN) GPIO.output(23,True) while True: if GPIO.input(18)==True: print "Take picture" GPIO.output(23, False) subprocess.call(["amixer", "cset", "numid=3", "100%"]) subprocess.call(["aplay", "/home/pi/sprite.wav"]) subprocess.call(["raspistill","-awb", "auto", "-iso", "200", "-ex", "sports","-t","20","-o","/home/pi/picture/image"+str(time.time())+".jpg"]) print "photo saved" GPIO.output(23, True)
We’ve used OpenCV to process the photos for adding the watermark, and soon found out that processing a photo does take a lot of time ( ~ 5 to 15 seconds). We initially thought of creating some threads in the code for image processing, but realized that having two operating system processes might do a better job instead. So we have created instead just a new Python script which monitors the “/home/pi/picture” folder and every time there’s a new photo, processes it, saves it on the memory USB stick and removes it from the SD card.
While the image is being processed (actually, while there are still some images in the “/home/pi/picture” folder), the status led blinks. This is done by a third Python script which only monitors the folder and triggers the led. If any files are present, the led blinks, otherwise it’s always ON.
Of course we have carefully wrote in the manual “DO NOT remove the memory stick while the status led is blinking, as this might lead to corrupt pictures!”. But who reads the manuals anyway? So to protect it from data loss if the user unexpectedly removes the USB memory stick, before each copy operation the stick needs to be mounted and when the copy is finished, the stick should be unmounted.
The Python script which blinks the status led
import time import os import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.OUT) GPIO.output(23,True) while True: fileList= os.chdir("/home/pi/picture") if len(os.listdir("."))!=0: GPIO.output(23, True) time.sleep(0.5) GPIO.output(23,False) else: GPIO.output(23, True) time.sleep(0.5)
The photo exhibition event
The over branded camera even got the attention of a Romanian urban photographer who organized together with Sprite, the Sprite-ography exhibition. Yes, you guessed it right: it’s the first exhibition that has all its pictures taken with the Sprite RaspberryPi camera.
Below are some photos from the event.
All the photos watermarked „Sprite” are actually taken WITH the Sprite / Raspberry PI Camera itself during the exhibition !
(feel free to use these under Creative Commons Share Alike, CC BY-SA)