Getting OpenCV 3 with contributions (e.g., SIFT) to work with Python 3.5 on a Mac OS X

This has got to be the most mis-documented thing on the web.  To save you the hours I spent spinning around on this, assuming you have homebrew:

brew install opencv3 --with-python3 --with-contrib

So many websites want you to check out a bunch of GIT repositories and build stuff by hand.  I have no idea why.  You may need other pre-requisites to make this work (probably Xcode command line tools), but they’re each not hard to find and install.  And of course you need python, numpy, and probably scipy to make it all work.

I don’t have a “virgin” system to try it on, so I can’t give a complete set of steps, but homebrew is very good at telling you what’s missing and getting it for you.

Hope this helps.


Afterwards, I needed to make sure I could process video files, and so I did:

brew reinstall opencv3 --with-python3 --with-contrib --with-ffmpeg

Using Python and Gphoto2 to control the focus of a Canon T3i (EOS 600D)

Turns out it’s really not well documented how to control the focus of a Canon T3i using Gphoto2.  Here’s what I found did the trick:

  1. You have to change the focus from the shutter release to the * button. See this for a description of how.  Otherwise, the camera refocuses every time you take a picture.
  2. You have to be in preview mode (mirror up)
  3. Then you can make the calls to change the focus.
  4. The camera does seem to appreciate being fed commands too quickly, so I threw a bunch of delays in.  I’m not sure what the right timing is…

Here’s my code that did the trick:

def doFocusStep(camera, context, change):
    config = camera.get_config(context)
    focus = config.get_child_by_name('manualfocusdrive')
    camera.set_config(config, context)

To flip the mirror up, you just have to capture a preview:

# Set into preview mode
camera_file = camera.capture_preview(context)

You can then make calls like:

doFocusStep(camera, context, "Far 3")

The rest of the program (creating a context and a camera) are fairly well documented.


How High Tech loves to Blame the victim

If you’re like me, you get lots of spam, and a lot of it harbors a malicious intent.  People are constantly trying to get me to cough up user ids and passwords, bank accounts, or unwittingly install malware on my computer.  I’m pretty skeptical about email and so far (knock on wood) I’ve managed to avoid falling for them.

Don't click!!!

Don’t click!!!

For the most part, that’s not hard to do.  Most people sending phishing email do an incredibly bad job of mimicking the real thing, so it usually doesn’t look good.  Every once in a while one looks really good, but that just gets me more excited to find its tell. And they all have tells … which means that, if you’re really good at looking for them, and extremely diligent, you should never fall victim to one of these scams.

Continue reading

10 Ways the Secret Service can Defend Against Drones

With the accidental (and apparently innocent) crash of a DJI Phantom quadcopter on the White House lawn, there’s an urgency to the question of how the Secret Service can defend against a small drone that’s been launched with malicious intent.  The key is malicious — people who are actively hoping to evade detection (otherwise, rule and regulations will suffice, no?).  There’s two problems to solve, really.  The first is detection, and the second is stopping a drone.

Continue reading

What Oliver North could have taught Sony Executives about Email

In late 1986, the White House was on the cusp of a huge scandal involving Iran-Contra, a complicated and illegal program to sell arms to Iran and route the proceeds to the Contras, a guerrilla organization dedicated to the overthrow of Nicaragua’s leftist, Sandinista regime. To try to destroy incriminating evidence, National Security Advisor John Poindexter and his assistant, Lieutenant Colonel Oliver North shredded the paper trail and methodically set out to delete all of their emails related to the program.  When done, they felt confident that they had erased anything that could have tied them and the White House to the illegal program. But that was a false confidence.

Continue reading