Corner detection in Blender

Hi, actually i’m working on corner detection and i have decided to code
this as python plug-in into Blender.

What’s going on?
Corner detection is used in 3D scene reconstruction and it is used in many different areas.

I tried to use corner detection to help modellers when they have to trace a logo to convert that logo into 3D object. I wanted to make this step somehow easier.

So the corner detection detects corner in image. My script put verticies into the place of corners. Than you can make edges and faces wherever you need.
These corner detection algorithms detects corners with errors you know…

So here is my blend file:

Here is a screenshot:

Little description:
You have to press ALT-P to run script in text editor.
Detection takes 35 seconds on my PC (Athlon XP 1800) - python is slow :frowning:

You can see original picture with detected corners and
i also put verticies in a object, but they do not fit into the image.
You have to manually put them into right place and also you have to scale them.
I will work on this, but i have to find a solution for it.

If you find it somehow useful, please let me know.
I will be glad you if you could even report your running time…(check console, the final number is your running time)

Looks useful, I’ll have to try it.


nice to see you got it started / done :slight_smile:

this box (a 2year old or so p4 3GHz) ran it in 16.25 seconds, not awful.

however, there are obviously ways to speed this kind of thing up, if it is a problem. like we discussed on irc, numerical python ( is a great fit for this, as it provides a nice array interface for matrix manipulation etc. stuff … instead of a couple of nested for loops in py or something, which are easily slow, there is a couple of py method/func calls to library code that is usually implemented in c … and provides many advanced algos too, like gaussian stuff iirc etc

what about the algo, does it do nicely what you targeted? i did not fully understand the result yet, got red spots in weird places in the image that is shown in the image view :spin:

To algo:
Thank you :slight_smile:
Algorithm makes some mistakes, there are some options that have to be set for every specific image like magic constant k in range 0.1 - 0.20 and gauss sigma (0.5 - 3.0 range)

I will make GUI if it will be useful for somebody.

I will look at but i can easily recode this into C.
I have originaly implemented this in Java and it had running time around 1 second or so…

I tested it again and i see that i made a mistake and the result was not seen
in the 3D view. I tried to fix it now.

You still have to align and scale the result to fit the background image.

Any other testers here?

LucasT - it’s great you’re doing this, but I have to warn you it is a duplicate effort, because somebody else is already working on an full tracking for blender, also with corner detection algos. maybe you’d be interested:



Hi pildanovak,
yeah, i know about Keir’s work. He is doing complete camera tracking and scene reconstruction.

I just wanted to take corner detection algorithm that is part of 3d scene reconstuction and use it or test it for 2D reconstruction :slight_smile:

If you want to speed up your Python code without much work, I would suggest this:

  • Use Python 2.5, it is about 1.5 times faster than 2.4
  • Install psyco, and put the following at the top of your script:

import psyco

This will give you AT LEAST a factor 3 increase in speed, and for number crunching things even a factor 5-10. Your script will consume more memory, though.

Really crazy psyco!
It run 10 times faster, on my Athlon XP 1800 it has now running time
2,2 seconds (31-35 seconds without psyco)

It is cool!
Psyco version:

Remember you have to install psyco first!

Windows Psyco 1.5.2

yum install python-psyco
use apt-get or you preffered tool to install packages

Next idea is to implement this:
I would like to put verticies in the same place as red crosses which shows the detected corners. So if you are looking from TOP (NumPad 7) and you have some distance from your background image, you should get verticies in right place…
But i do not know how to implement this…If anyone knows, let me know

Could this be used to detect obtuse angles, and create a mask for texturing? Would be awesome for putting wear on greebling.

This implemented algorithm is called Harris corner detector and it can’t detect obtuse angles, but i’m working on reimplementation of detector that was developed at my university and it detects according angles, so when i get more time (i need month to finish semester), i will work on it and i will write you :slight_smile:

Yes, please let me know how it shapes up :slight_smile: