Visualization: How Common Is Your Birthday – 360 degrees

I’ve done a visualization based on this one by Matt Stiles. Use the mouse to locate a birth date. I’ve a added a red arc that indicates the most probable conception date for the given birth date based on an average pregnancy of 39.5 weeks. January 1st is at 0 degrees and the year goes clockwise. I think that a circle gives a better impression on what’s happening around the year. Check the gaps at some special dates likes July 4th, Christmas and Thanks Giving weeks.

I hope to have another visualization with our own data soon.

Images licensed under Creative Commons Attribution 3.0 Unported. These files are licensed under the Creative Commons Attribution 3.0 Unported license. You are free: to share, to copy, distribute and transmit the work to remix or to adapt the work Under the following conditions: attribution: You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). Code is OpenSource bajo MIT License.

Read More

DIY Powered USB Cable for Raspberry Pi

I’ve got a Logitech c270 webcam working on the Raspberry Pi with Archlinux, since the current Debian image does not include the video modules. The main issue is power. I’ve measured the current that the camera is using and it goes up to 240mA when capturing video which is well over the Pi’s specification. If you can get a powered USB hub I guess that will work, just keep an eye on the power consuption of all the devices connected to it.

I have built a powered usb cable from a USB extension cable and a USB Type A-B cable. The extension cable is the one that has on each side a Type A male and female (receptacle), and is used to access a remote USB port. The type A to B cable is the one that is commonly used to connect a host to a device, like a computer to a printer, and that seems to be used less nowadays.


USB connectors. Three right-most are: Type A female (receptacle), Type A male and Type B

Please note that doing this may be dangerous or risky for your devices, since a shortcut or an incorrectly plugged terminal may damage or blow any of them. Build this at you own risk!. Also take into account that this cable will be less reliable than the original cables.

The USB standard pinout consists of four conductors: Ground (GND – black), VBUS (+5V – red), Data+ (D+ – green) and Data- (D- – white). We will connect the GND and VBUS lines from the extension cable to the GND and VBUS lines of the Type A side of the other cable, leaving both Data lines untouched in the extension cable. The Data lines of the Type-A from the AB cable will not be used (will be unconnected). The Type-B side of the AB cable will be thrown away.

Cut the extension cable from the middle. If possible, do not touch the green and white lines. If you need to cut them, resolder both later to keep the same configuration as the original.

Cut the A-B cable and throw away the B side. Peel the red and black lines of the A side and trim the white and green lines since they will not be used. Connect and solder the red conductors of the two Type A male sides and the Type A female. Connect and solder the black conductors of the three connectors. Isolate the connections (I used thermofit). Use some electrical tape to strengthen the cable. Test using a multimeter.

You will have a cable with two Type A male connectors and one Type A female connector (receptacle).

You can now connect the cable to the devices. I recommend this order:

  • The Type-A (male) from the A-B cable to a USB power source (like a phone’s charger)
  • The Type-A (male) from the extension cable to the Raspberry Pi
  • The Type-A (female, receptable) to the device, in my case, the webcam.

Everything should run smoothly since the power for the device is now taken from the charger and not from the board.

Once again, do this at your own risk and evaluate your skills. The procedure is simple but it may produce irreversible damage to your devices if done improperly.

Read More

Installing OpenCV on the Raspberry Pi

UPDATE 2:Here is my guide for Arch Linux

UPDATE: I’ve moved to Archlinux because it has the webcam modules included. OpenCV is really easy to install: pacman -S opencv

Installing OpenCV (2.3.1) on the Raspberry Pi is pretty easy using the base Debian Squeeze image and following these instructions for Debian/Ubuntu.You will need to have more space on the root partition so I recommend resizing it to at least 3GB (see the video tutorial using GParted or follow these instructions). Here they are with some comments on the few issues I found:

I found an error trying to install cmake for the first time, so first do

sudo apt-get update

two times before anything else. The first time I did the update an error on “duplicate sources” was shown thus the second update was necessary.

Install in the following order:

sudo apt-get install build-essential
sudo apt-get install cmake 
sudo apt-get install pkg-config 
sudo apt-get install libpng12-0 libpng12-dev libpng++-dev libpng3 
sudo apt-get install libpnglite-dev libpngwriter0-dev libpngwriter0c2 
sudo apt-get install zlib1g-dbg zlib1g zlib1g-dev 
sudo apt-get install pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools 
sudo apt-get install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs 
sudo apt-get install ffmpeg libavcodec-dev libavcodec52 libavformat52 libavformat-dev 
sudo apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0  libgstreamer0.10-dev 
sudo apt-get install libxine1-ffmpeg  libxine-dev libxine1-bin 
sudo apt-get install libunicap2 libunicap2-dev 
sudo apt-get install libdc1394-22-dev libdc1394-22 libdc1394-utils 
sudo apt-get install swig 
sudo apt-get install libv4l-0 libv4l-dev 
sudo apt-get install  python-numpy 
sudo apt-get install libpython2.6 python-dev python2.6-dev 
sudo apt-get install libgtk2.0-dev pkg-config

The package build-essential was already installed on my device so maybe you don’t need to install it. Note that for the eighth line the original link says “libjpeg-prog” but it must be “libjpeg-progs”. Also, check the last step that is not included on the original instructions but it’s needed for this platform.

Get the sources (check the version you want to install):

wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.3.1/OpenCV-2.3.1a.tar.bz2/download

Uncompress the sources and create a directory inside it (I called it ‘release’). Chdir to it. Run cmake to configure, compile and install. Compilation will take a while, about a couple of hours:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
make
sudo make install 

Now you can run the samples. In this image, the Python version of contours:

Read More