Importing old OpenCV modules from OpenCV 2 in Python on Windows

Some of the legacy modules like Horn Schunck Optical Flow in OpenCV 2.4 are located in “cv” instead of “cv2″ .

To be cross-platform compatible, instead of doing

import cv,cv2

I suggest doing

import cv2
from cv2 import cv


Further, in Windows running Anaconda Python 2.7 (or whatever Python 2.7 you choose), OpenCV is not installable through conda.

To install OpenCV 2.4 for Python on Windows, do the following:

  1. From

    download OpenCV for Windows, version 2.4

  2. Extract to a directory of your choice, let’s say c:\opencv and copy the file

If you’re using CPython instead of Anaconda, copy to that directory instead.

Writing multipage TIFF with Python

You can use the freeimage plugin to SciPy as one method. On Windows you might see the error:
RuntimeError: Could not find a FreeImage library

To fix this, download the FreeImge DLL from

Then extract the file

to the following directory (assuming you’re using Anaconda Python)

Example code (assuming you have image stored in C-ordered 3-D array images):

from import freeimage_plugin as freeimg



OpenCV cv.CalcOpticalFlowHS Horn-Schunck smoothness lambda parameter

More details to come, but I was comparing the performance of OpenCV to Matlab Computer Vision Toolbox for the dense estimates of optical flow given by the Horn Schunck algorithm. I was getting a very different result with OpenCV vs. Matlab for the Optical Flow Estimation. It seemed that OpenCV was washing out fine details in the optical flow. After carefully comparing Matlab Computer Vision and OpenCV outputs for Horn Schunck optical flow, I found that the default lambda/smoothness parameter of 1.0 for cv.CalcOpticalFlowHS is not the same as what Matlab calls 1.0.

I need to quantify this further, but for now I found that in OpenCV cv.CalcOpticalFlowHS setting lambda=0.001 gives results that are much more like Matlab–I can see the fine details. This is just a rough guess, if I have time I’ll quantify it in my forthcoming article on segmenting terabtyes of aurora borealis video in an hour!

PySide in Anaconda3

When using Matplotlib in Anaconda 3, and if you’re trying to use QT4Agg, you may get the error message
ImportError: No module named 'PySide'

To fix this, you can try (using your Anaconda3 pip)
pip install pyside
This will take several minutes and may require the prerequisites:

sudo apt-get install libxext-dev python-qt4 qt4-dev-tools build-essential



Using USB-serial FTDI adapters with Intel Edison

The current Yocto kernel distro available for the Intel Edison (version 68 by configure_edison --version) does not include the FTDI driver. Thus when you plug a USB-serial adapter into the USB OTG host port, you’ll see it partially recognized in dmesg tail upon plugin, but you won’t see an assignment to a /dev/ttyUSB_ device.

You need to install the FTDI kernel module first.
opkg install kernel-module-ftdi-sio
This assumes you have already setup the unofficial opkg repository.

Now when you type dmesg tail you’ll see the line something like
usb: FTDI USB Serial Device converter now attached to ttyUSB0

You may have to update your kernel if this doesn’t work.

Connecting to Boston University’s 802.1x Wifi from a Linux device

If you don’t have a graphical desktop, BU’s Enterprise Wifi requires the following manual settigns. The settings below are from BU’s recommended settings.  Their webpage has now been updated per my suggestion.

# nano /etc/wpa_supplicant/wpa_supplicant.conf

paste at the end
ssid=”BU (802.1x)”

pairwise=CCMP TKIP
identity=”Your BU login”
password=”your Kerberos Password: be aware others can read this file!”


# reboot

This results in the feedback upon successful connection:

# wpa_cli -i wlan0 status

ssid=BU (802.1x)
key_mgmt=WPA2/IEEE 802.1X/EAP
Supplicant PAE state=AUTHENTICATED
selectedMethod=21 (EAP-TTLS)
EAP-TTLSv0 Phase2 method=MSCHAPV2

WriteLatex vs. ShareLatex

Short answer: Use ShareLatex

1) ShareLatex is much faster to compile. I have a 30 page journal article draft with numerous figures, and WriteLatex seems to take on the order of a minute to compile while ShareLatex was substantially less.

2) ShareLatex has far better error/warning feedback and a much better IDE overall. WriteLatex error/warnings keep disappearing and the line number with error is not clearly indicated.

3) ShareLatex is open-source. WriteLatex is NOT open source.