Using C++ or Python for OpenCV Programs

When I first started learning OpenCV, I was working exclusively with Python. While I am still a huge fan of the language, today all of my OpenCV programs are written in C++. Why?

  1. Some of the deeper functionality of OpenCV has not been completely ported to Python (although hopefully the release of OpenCV 3.0 will fix most of these issues).
  2. Most in-depth textbooks on image processing and computer vision that cover OpenCV use C++ as their primary language. It was therefore easier to learn from these resources by adopting the language.
  3. A lot of the computer vision techniques I use (SIFT, machine learning, etc), are better documented in C++.
  4. Passing images back and forth between NumPy arrays has overhead that C++ doesn’t have to worry about.
  5. As has been suggested to me by Carl Bell, Python struggles to perform well with overloaded functions.
Read More
Are university lectures still relevant?

Lately, there’s been quite a few articles (such as here and here) discussing the use of the university lecture and its perceived shortcomings. The question is asked: is the lecture an unengaging relic from before the digital age? Are lectures really the best way to learn? I attended many lectures throughout my undergraduate studies, and have also tried out massive open online courses (MOOCs) from providers such as Coursera. To be perfectly honest, I don’t mind lectures at all. While they could be dull at times, they had the advantage of sitting you in a room where information was being fed to you whilst you were (mostly) shielded from the distractions of the outside world. Having a timetable of lectures was a powerful way to organise your learning (especially as you were paying for this education). It takes a lot of motivation to sit through a fraction of the lectures each week from online courses.

Read More
How to create random DNA sequences with Python

Python’s random module makes it extremely easy to generate random DNA bases.

import random
dna = ["A","G","C","T"]
#output a random base

Now to generate a specific number of random bases, all we have to do is use Python’s range function:

Read More
Sublime Text OpenCV C++ Build System

If you want to compile and run a C++ program using OpenCV in Sublime Text, then copy and paste the code below into a build system file. If you’re not interested in explicitly using C++11 you can delete the “-std=c++0x” section.

"shell_cmd": "g++ -std=c++0x ${file} -o ${file_base_name} `pkg-config --cflags --libs opencv` && ./${file_base_name}"

Read More
Some interesting talks from PyCon 2014

Here are several talks from PyCon 2014 I thought looked rather interesting from a research perspective:



Read More
Where to find R tutorials

Here’s a list of a few R tutorials (in addition to the one I wrote), which I’ve found (or look) rather useful:

Google Developers R Tutorials

A slightly Different Introduction to R

Read More
Educational iPython Notebooks

One of the best things about the iPython notebook is the number of easy-to-follow tutorials it has inspired. I thought I’d share a few that I’ve found on machine learning and statistics.

I’ll continue to update the list as I find new notebooks I find handy.

Read More
Useful links for using ggplot2 in R

The R package ggplot2 is one of the best data visualisation tools I’ve come across, and while it simplifies generating impressive graphics, there’s still a bit you have to learn to use it. Here are a few of the posts I’ve found really handy when using this package:

I’ll try to continue updating this list as I find other good resources.

Read More
Tracking bees using local features

The project I am working on at present is focused on building an automated system for tracking the movement of honeybees in an observation hive, filmed using a grayscale camera and infrared light. My recent attempt at this has involved extracting features (or keypoints) from the frames and then describing them using the SIFT (Scale Invariant Feature Transform) algorithm, implemented in the OpenCV imaging library. There are a number of other (potentially faster) feature detection algorithms available (SURF, ORB, etc), however as SIFT has been traditionally regarded as the most robust, I thought I would start with it. SIFT works first by extracting what it deems to be robust keypoints/features. For each of these, it will then compute a unique feature descriptor based on the 16×16 pixel area of the feature. By extracting and describing these features, you can try to compare images as shown below.

Read More
Essential Free Tools for Research

I commenced my PhD in bioinformatics at the Australian National University about a month ago and thought I’d share some of the tools I’ve found absolutely essential. All of these tools are free to use (some do have paid plans, however at this point I haven’t had the need to sign up for them).

  1. Evernote + Evernote Web Clipper: Once I started to really get into using this tool, I couldn’t understand how I’d lived without it before. Now I can clip snippets from web pages for later reference, write notes from a seminar I attended or upload a Python script and have this all in one easily searchable (and tag-able) location. There’s also a plethora of phone/tablet apps which work really well.
  2. Wunderlist: While I tried to use Evernote for keeping to-do lists, I found that this simple yet powerful program (with support for PC, Mac, phones and tablets) worked extremely well for keeping track of my tasks.
  3. Dropbox: I do all my work within the Dropbox folder on my computer. This way, when I move between computers everything is synced and backed-up. While I have tried Google Drive before, the lack of support for Linux as well as issues with syncing have led me back to using Dropbox.
  4. Zotero: Zotero is a referencing manager with a browser plug-in which is fantastic at importing the bibliographic details and pdf of the paper from the web. It can also sync between computers (although you only get 300 mb of free sync space). While I have used the alternative referencing manager Mendeley before (which has 2gb free sync space and a brilliant program which enables you to annotate your pdfs), the Mendeley web import tool was so bad at importing the bibliographic details and pdfs of papers that I went over to Zotero.
  5. VirtualBox: If you find yourself having to use a lot of Linux-only tools (or you like the fact that you can install entire programs with multiple dependencies merely with the command ‘sudo apt-get’) but don’t really want to set up anything permanent , then VirtualBox could be the way to go. Its a free program that allows you to run a whole operating system on your computer within a window just like any other program.
  6. Coursera/EdX/Udacity: These websites offer free courses from great unis in everything from computer science to genomics.
  7. Stack Overflow/Biostars: Great websites for asking questions relating to programming or bioinformatics. If you can’t find anything after searching Google, then this is the place to post your question.
  8. Twitter: Although this can be a bit of a time-waster, I find that by following other researchers in my field and research organisations I can hear about new papers or tutorials.
  9. Google Plus: G+ may not be as popular as Facebook, but I find most of my programming friends tend to be quite active on it and if you join one of the programming communities it can be a great place to learn new things or ask questions.
  10. Google Scholar Alerts: Sign up to receive emails whenever the keywords you select are published in a paper.
Read More