Ask Your Question

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 as cv" instead of "import cv". I can also eliminate those same errors by creating a module that contains the statement "from 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 becomes obsolete?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

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

Guanta gravatar image

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

  1. import 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 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 will vanish then, too.

edit flag offensive delete link more


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 module just show up in the cv module namespace.

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

Question Tools


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

Seen: 5,600 times

Last updated: Nov 26 '13