import OpenCV on Blender

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

nestor20
Posts: 2
Joined: Thu Aug 30, 2012 5:26 pm

import OpenCV on Blender

Postby nestor20 » Thu Aug 30, 2012 5:43 pm

At first !thank you for try to help me! :) :) and now-->
----------------------------------------------------------------------
i wanna import openCV python library in blender(bge) for use the realtime function "camera tracking" and "object dectect" and I find some guys who have done some games with openCV and Blender(it's true).
----------------------------------------------------------------------------------
I have installed openCV 2.4
I have python 2.7 and 3.2
I have installed openCv in the both versions
I have Blender 2.6.2
I have the file "cv2.pyd" in the folder "C:\Archivos de programa\Blender Foundation\Blender\2.62\python\lib\site-packages"
-------------------------------------------------------------------
anybody know how to import openCV in Blender?
-------------------------------------------------
I tryed writing a python script for the bge (with a always sensor and a python controller connected to the other sensor)

This is the scripts that i tryed to use:
---------------------------------------------------
# 1 script

import sys
sys.path.append("C:\opencv\build\python\2.7")
import cv

--- ERROR: no module named "cv" --


# 2 script

import sys
sys.path.append("C:\opencv\build\python\2.7")
import cv2

--- ERROR: no module named "cv2" --


# 3 script

import sys
sys.path.append("C:\opencv\build\python\2.7")
import opencv from cv

--- ERROR: no module named "opencv" --


# 4 script

import sys
sys.path.append("C:\opencv\build\python\2.7")
from opencv.cv import cv

--- ERROR: no module named "opencv.cv" --


# 5 script

import sys
sys.path.append("C:\opencv\build\python\2.7")
from opencv.cv import cv2

--- ERROR: no module named "cv" --


# 6 script

import sys
sys.path.append("C:\Archivos de programa\Blender Foundation\Blender\2.62\python\lib\site-packages)
import cv

--- ERROR: no module named "cv" --


# 6 script

import sys
sys.path.append("C:\Archivos de programa\Blender Foundation\Blender\2.62\python\lib\site-packages)
import cv2

--- ERROR: no module named "cv2" --


............................
and 20 scripts more!
.............................

thanks you for help me!
:)

stiv
Posts: 3646
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Postby stiv » Thu Aug 30, 2012 6:16 pm

New Blender uses Python 3.2. It comes with its own copy of Python.

In order to import modules, they must be for Python 3. If you build modules with Python 2, they are unlikely to install.

nestor20
Posts: 2
Joined: Thu Aug 30, 2012 5:26 pm

Postby nestor20 » Thu Aug 30, 2012 9:02 pm

stiv wrote:New Blender uses Python 3.2. It comes with its own copy of Python.

In order to import modules, they must be for Python 3. If you build modules with Python 2, they are unlikely to install.


thanks you but...

how i can get blender 2.62 with python 2.7?

I try to use the version 2.49b how is the last blender version how uses python 2.x(2.6 exactly) but (you will have to excuse me) i dont like blender
2.49b is too different. :(

i try to find a solution! :):(

stiv
Posts: 3646
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Postby stiv » Thu Aug 30, 2012 10:26 pm

how i can get blender 2.62 with python 2.7?


You cannot. New Blender needs Python 3. It cannot be compiled with Python 2.

A quick google suggests opencv does not work with python3 yet.

mjrmua
Posts: 3
Joined: Thu Jan 01, 1970 1:00 am

Postby mjrmua » Sun Sep 02, 2012 10:35 pm

stiv wrote:You cannot. New Blender needs Python 3.


Is there an older version of blender that will work with python 2.x?

stiv
Posts: 3646
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Postby stiv » Sun Sep 02, 2012 10:51 pm

Old Blender (2.49) uses Python 2. IIRC, official versions were compiled with Py 2.5 or 2.6, but you can build it with any Py version greater than 2.3 or so.

You might be able to find it already built on graphicall.org .

mjrmua
Posts: 3
Joined: Thu Jan 01, 1970 1:00 am

Postby mjrmua » Mon Sep 03, 2012 12:07 am

How about running the CV in python 2.7, then set up some sockets communication between blender-python and the openCV program?

Not sure what's the best way to set this up in blender though, Maybe a repeating delay sensor that triggers the blender script to poll openCV program server?

Can blender experts suggest a better solution?


Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests