Ask Your Question
0

python import cv

asked 2013-11-25 16:50:05 -0600

xaffeine gravatar image

I am trying to work with Pyvision from CSU. My root problem is that several of the source files contain "import cv" statements and a lot of references to members of the cv module. I know that I can resolve the obvious errors by using "import cv2.cv as cv" instead of "import cv". I can also eliminate those same errors by creating a cv.py module that contains the statement "from cv2.cv import *". This is easier than changing all the original import statements.

My 2-part question is: 1. Does my "fake" cv module trick make sense for now? 2. How much time do we have before cv2.cv becomes obsolete?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-11-26 05:31:32 -0600

Guanta gravatar image

updated 2013-11-26 05:32:31 -0600

  1. import cv2.cv as cv is absolutely valid and is favorable to your second variant (since with your second variant you wouldn't need to write cv.method() but just method() which might get confusing over time). BUT, really, I'd try to circumvent cv2.cv as much as possible and use the functionality of just the cv2 module (exist there modules at all which are only in cv but not in cv2?).

  2. I don't know, but python3 support will come with OpenCV 3.0 afaik. Maybe cv2.cv will vanish then, too.

edit flag offensive delete link more

Comments

I am working with third-party code that I prefer not to modify. That is why I use the "fake" cv module. From the outer-level code, the symbols from the real cv2.cv module just show up in the cv module namespace.

xaffeine gravatar imagexaffeine ( 2013-11-26 12:52:12 -0600 )edit

Question Tools

Stats

Asked: 2013-11-25 16:50:05 -0600

Seen: 5,869 times

Last updated: Nov 26 '13