import cv into BGE

Hello, I am trying to write a script for the BGE that uses openCV. I have installed openCV, python 2.7, and blender 2.62, all on windows 7. When I run a script from within the GE, it doesn’t like the import cv command even though I can open python and run that command, and it imports just fine.

I guess what I’m wondering is where blender looks for these things, and how I can tell it to use the installation of Python, or look in the same places as is does.

Any help would be appreciated! Thanks!

-Andrew Miller

Id like to know exactly the same thing!

Blender 2.62 uses python 3, which isn’t yet supported by openCV. The solution I’ve found has been to install python 2.6, blender 2.49b, and then I am able to use the openCV libraries in the GE. That’s the workaround I’ve come up with, although I imagine that it should be possible to right your own python wrappers for openCV that would be compatible with python 3 if you really needed to use blender 2.62

I have been able to get a video stream from my webcam and alter it (using a dilate or erode filter) and then display it live as a texture in the game. Unfortunately it has been rather slow, so I will try to see if it can be improved by not re-importing everything… I’ll let you know if I get any more useful results.

Thanks. Im now trying to compile Blender using Python 2.7. Maybe that will solve my problem.

I found a very random version of 2.49 compiled with python 2.7, it was from some website in french, and I have no clue what other features have been changed or if it’s even safe, but here’s the link… http://www.zoo-logique.org/3D.Blender/compilations/stockcompil/win32blender249c-ini_p27.zip

I would suggest recompiling openCV with python 2.6, because that will probably be much easier and stabler overall.

Thanks, for the time being Ive gone for a small hack where I just make a system call within python 3.2 to python 2.7 and run a script like that.
There isnt too much to be moved around so its okay as a temporary workaround.

Great, I was having pretty same issue and solved it with the help of this thread. Thanks for sharing your insights!