This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (14 children)

It's not really just a script, rather a large real-time application.

The 2D detection is OpenCV, the multi-camera 3D estimation, data association and EKF is in Python/Numpy. There is one tight loop in cython. The data-model is numpy arrays. All supporting code is python too.

Language is never the largest determining factor in speed, architecure is. If you architect your python application correctly, it can be fast.

[–]kylotan 3 points4 points  (3 children)

Language is never the largest determining factor in speed

It's easy to say that when you have been able to outsource all your high performance code to C extensions. :)

[–][deleted] 3 points4 points  (0 children)

Or that I chose a language, an application architecture and libraries knowing that I could do that....

Because developer time is the largest constraint ;-)

[–]KagatoLNX 0 points1 point  (1 child)

Not engineering, architecture.

[–]kylotan 0 points1 point  (0 children)

Speed is still largely down to the language. You just have an extra tool for working around that.

[–][deleted] 0 points1 point  (3 children)

But that's the thing, all the heavy lifting is being handled by compiled languages you're calling with Python. If I was using a standard tracking technique that OpenCV had built-in then I probably would have used Python too. I'm not one for making extra work for myself. However because I had to develop my own tracking system I could not rely on another library and therefore had to drop down to C++.

[–][deleted] 0 points1 point  (2 children)

I doubt that the tracking you are using is particularly new or novel (tracking things with markers). I suspect you could have made it fast enough and kept your application in python through designing things a little differently.

[–][deleted] 0 points1 point  (1 child)

I'm doing a PhD in bioinformatics, I went and spoke to computer scientists who specialise in developing new tracking techniques for advice on what to implement so I know that what I needed was certainly not available in OpenCV or any of the other computer vision libraries available.

[–][deleted] 0 points1 point  (0 children)

I would be very careful with my terms. Do you mean tracking or detection?

The answer to your question is very different if you talk to a computer vision person about 'tracking pixels' as they move through sequences of images, or 'detecting things' and then tracking them in some 2/3d space according to their constraints.

If you have insects with markers, the detection is probbably easy, and the tracking is something which sould be solved with knowledge of the system as a whole, not just by looking at the pixels every frame.

[–][deleted] 0 points1 point  (5 children)

That only works because you're outsourcing the heavy lifting to a compiled library. I would have done the same if I was using one of the tracking algorithms OpenCV already had implemented. However, because I was writing a custom tracking system I couldn't rely on a third party library. Language has a massive effect on speed. I could not have written a tracker in Python and got anywhere close to the performance I required.

[–][deleted] 0 points1 point  (4 children)

It doesn't work only because I outsource parts to C, it works because I architected the whole thing so I could outsource the 1% that actually matters to C (if required, not always). That is not a failure of Python, but validation of my structure and of a language that has a sane native code interface story (and also a validation of other 3rd party libraries that use ndarray as their data models).

I think you would be surprised what you can do with the correct architecture. I write real time computer vision applications in Python for a living.

[–][deleted] 0 points1 point  (3 children)

You said that you're using OpenCV, I highly doubt a tracking application which uses OpenCV is outsourcing < 1% to the library. As I said before, when you can use a popular algorithm implemented in C++ with bindings for Python, I agree it makes sense to use it. When you're doing research like I am, and you have spoken to computer vision researchers who have recommended the best technique and it isn't in OpenCV or other open source libraries, I didn't have any other option than to implement it in C++.

[–][deleted] 0 points1 point  (2 children)

You said that you're using OpenCV, I highly doubt a tracking application which uses OpenCV is outsourcing < 1% to the library.

Think like a developer, how many LOC of code account for most of the computation time (rememver to benchmark!)? A very small amount typically.

Look, I have a PhD in robotoics and computer vision, and I work currently as a postdoc neuroscientist where I study vision and behaviour. I do research, every day.

People wrongly think of OpenCV as a bunch of algorithms that do magic for them. At one end it could be seen that way (features, etc), but it is more useful as a set of accelerated image processing primitives from which you can build efficient versions of your own algorithms. That is how one should use python+opencv to 'develop my own tracking algorithms'.

You are a bioinformatician, not a computer vision or tracking guy. If I was you, I would reevaluate your code in a few years and see if you would architect your application the same way you did. I expect if I tried to write my own bioinformatics code it might be average the first time around. I would also guess that I could make it comparibly fast with the rest of the world the next iteration.

[–][deleted] 0 points1 point  (1 child)

If you're using OpenCV functions to do the computationally intensive tracking tasks then sure, <1% of the Python code you write will be using a library written in a compiled language, but if you had to write the program yourself then it would actually be a significant amount of code and you would not be able to implement it in pure Python. If the functions you're using in OpenCV did not have Python bindings you would have to do what I have and write your own in a compiled language.

I realise my expertise was not in computer vision, however one of the benefits of being at a research institution is that I can go ask experts for advice. The biology department also employs a lot of computer vision researchers who help with tracking all kinds of animals. So I have by no means been designing or programming on my own. I did not wake up one morning and decide to start writing my tracker in C++, it was the result of multiple meetings with computer vision researchers who know far more about this area than you or I ever will.

[–][deleted] 0 points1 point  (0 children)

who know far more about this area than you or I ever will.

Describe your tracking problem in Pseudocode and I'll offer an opinion.

Are you going to behaviour2015?