Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Python and OpenCV 2.4.3

Few days ago I went into searching for a good way to make a simple computer vision system. OpenCV library is something I need but it proved hard to learn with Python especially after OpenCV 2.4.3 update which have very slim Python related documentation. So I now understand that there was a bunch of changes in OpenCV, for exaxmple

import cv

is now

import cv2

And there is bunch of modules that is missing. I mean, yes there are examples of the new python-opencv syntax but it's very narrow and proven to be hard to understand. For example: Example in official documentation for Python code

cv2.cvtColor(src, code[, dst[, dstCn]])

I know what this code means and how to use it, at least I think i know. But writing source and color code does nothing just give me :

    Traceback (most recent call last):
  File "C:\Users\hack\My Documents\Aptana Studio 3 Workspace\CAM view\open_cv\tut.py", line 11, in <module>
    cv.cvtColor('proba.jpg', 'CV_RGB2GRAY')
TypeError: an integer is required

Or if i try to write code like variable:

Traceback (most recent call last):
  File "C:\Users\hack\My Documents\Aptana Studio 3 Workspace\CAM view\open_cv\tut.py", line 11, in <module>
    cv.cvtColor('proba.jpg', CV_RGB2GRAY)
NameError: name 'CV_RGB2GRAY' is not defined

So is there any Python related reference document/tutorial/book/guide for newest OpenCV with the ground up explanations that does not confuse newbie like me with unwanted code examples for C++ or Java?

Python and OpenCV 2.4.3

Few days ago I went into searching for a good way to make a simple computer vision system. OpenCV library is something I need but it proved hard to learn with Python especially after OpenCV 2.4.3 update which have very slim Python related documentation. So I now understand that there was a bunch of changes in OpenCV, for exaxmple

import cv

is now

import cv2

And there is bunch of modules that is missing. I mean, yes there are examples of the new python-opencv syntax but it's very narrow and proven to be hard to understand. For example: Example in official documentation for Python code

cv2.cvtColor(src, code[, dst[, dstCn]])

I know what this code means and how to use it, at least I think i know. But writing source and color code does nothing just give me :

    Traceback (most recent call last):
  File "C:\Users\hack\My Documents\Aptana Studio 3 Workspace\CAM view\open_cv\tut.py", "C:\FILEFOLDER\tut.py", line 11, in <module>
    cv.cvtColor('proba.jpg', 'CV_RGB2GRAY')
TypeError: an integer is required

Or if i try to write code like variable:

Traceback (most recent call last):
  File "C:\Users\hack\My Documents\Aptana Studio 3 Workspace\CAM view\open_cv\tut.py", "C:\FILEFOLDER\tut.py", line 11, in <module>
    cv.cvtColor('proba.jpg', CV_RGB2GRAY)
NameError: name 'CV_RGB2GRAY' is not defined

So is there any Python related reference document/tutorial/book/guide for newest OpenCV with the ground up explanations that does not confuse newbie like me with unwanted code examples for C++ or Java?