What you need...
- Microsoft Kinect Sensor
- Raspberry Pi 3
- Stepper motor and controller
- Touchscreen for Raspberry Pi (optionally)
- Lasercutter to make some custom parts
Install the Raspberry Pi
- Create a fresh Raspberry Pi image, based on Rasbian Jessy Lite)
www.raspberrypi.org/downloads/raspbian/ - Install desktop components.
www.raspberrypi.org/forums/viewtopic.php?f=66&t=133691 - Configure the Pi to boot in Desktop with autologon
sudo raspi-config
Boot Options -> Desktop Autologin - Install libusb and libfreenect
(find the latest libusb release here, and follow the following blog)
(you will need to compile libfreenect with the python wrapper included.
this is done by modifying cmake -L .. to cmake -L .. -DBUILD_PYTHON=ON)
blog.bitcollectors.com/adam/2016/01/kinect-support-for-raspberry-pi-using-libfreenect/ - Setup the Python wrapper for libfreenect
cd ~/src/libfreenect-0.5.3/wrappers/python
sudo python setup.py install
sudo ldconfig -v - Install opencv
sudo apt-get install python-opencv - Important note: I noticed that libfreenect is only working well on my Pi when the ethernet port is up. I still did not figure out what the root cause is, but I bypassed it by creating an ethernet loopback connector. When plugged in in the ethernet port of the Pi, the port comes up and libfreenect is working very well. The built in wifi of the Pi also remains active.
- Connect the Kinect and run the sample scripts.
- Optionally install the USB touchscreen. The touchscreen is not really required. You can install xrdp and launch a remote desktop session from a smartphone.
blog.ask-a.ninja/?p=48
Mount the stepper motor
I have built my focus follower for a Canon 6D. This was I think the worst situation possible because:
I used a small and cheap stepper (28BYJ48, with ULN2003 Driver Board). It has (just) sufficient torque and speed to drive the focus ring of my lens. Available on Aliexpress or DHGate.
- Although libraries exists (like gphoto2) to drive your camera with a Raspberry Pi via an USB connection, it is not possible to accurately drive the focus via USB. It IS possible to drive the focus of the lens by small, medium or huge steps, but the size of these steps do not seem to be constant, and depend on the selected focus length of the zoom lens.
- You cannot read the current focus distance.
I used a small and cheap stepper (28BYJ48, with ULN2003 Driver Board). It has (just) sufficient torque and speed to drive the focus ring of my lens. Available on Aliexpress or DHGate.
You will need some custom design and laser cutting to create a mount that fits the lens of your camera. Contact me via the contact form if you need my design files for a Canon 24-105 lens.
Connect the stepper to the Pi
I used the same script and wiring as described in the following blog:
www.raspberrypi-spy.co.uk/2012/07/stepper-motor-control-in-python/
www.raspberrypi-spy.co.uk/2012/07/stepper-motor-control-in-python/
Install the Python scripts for the focus follow
For the scripts I decided to make a clear distinction between the 2 independent tasks that need to be done:
The focusfollow.py script writes the required focus distance (and some other parameters like for example focus speed) to and external config file. This file is read by the focus.py script. So both scripts need to run at the same time.
Install the 2 scripts and the ini config file in /usr/local/bin.
- Read the depth map and the required required focus distance (focusfollower.py)
- Drive the focus ring (focus.py)
The focusfollow.py script writes the required focus distance (and some other parameters like for example focus speed) to and external config file. This file is read by the focus.py script. So both scripts need to run at the same time.
Install the 2 scripts and the ini config file in /usr/local/bin.
focusfollower.py
focus.py
Make it portable
Also some custom laser cutting work required... contact me to get the design files.
Currently I am using a 12 volt lead acid battery. The 12 volt is converted by a DC-DC converter to 5V for the Raspberry Pi. The stepper motor has just sufficient torque with 5 volt, but if required the voltage on the stepper can be increased up to 12 volt to produce a higher torque at a cost of more heat and more power consumed. The 12 volt is also required for the Kinect (which has its own power supply you will need to cut off to connect the Kinect directly to the battery).
The whole setup (Raspberry Pi + lcd touchscreen + kinect + stepper) draws 1 amp from a 12 volt power supply.
The lead acid battery will be replaced by Li ion batteries with an additional DC-DC converter to 12 volt.
Currently I am using a 12 volt lead acid battery. The 12 volt is converted by a DC-DC converter to 5V for the Raspberry Pi. The stepper motor has just sufficient torque with 5 volt, but if required the voltage on the stepper can be increased up to 12 volt to produce a higher torque at a cost of more heat and more power consumed. The 12 volt is also required for the Kinect (which has its own power supply you will need to cut off to connect the Kinect directly to the battery).
The whole setup (Raspberry Pi + lcd touchscreen + kinect + stepper) draws 1 amp from a 12 volt power supply.
The lead acid battery will be replaced by Li ion batteries with an additional DC-DC converter to 12 volt.
Start it up
The focus.py script assumes that the focus of the lens is on the nearest distance when the script starts. Make sure you check this before you start the 2 scripts.