OpenCV python Calibration
opencv的python接口尽管可以用了,仍然不觉得那么好用… 比如cvMat cv.IplImage等,为什么不用python原生的数据结构呢?
好,我就来检查下opencv中的各种数据结构、类型间的关系。
CvPoint
2D point with integer coordinates (usually zero-based).
2D point, represented as a tuple (x, y) , where x and y are integers.
CvPoint2D32f
2D point with floating-point coordinates
2D point, represented as a tuple (x, y) , where x and y are floats.
CvPoint3D32f
3D point with floating-point coordinates
3D point, represented as a tuple (x, y, z) , where x, y and z are floats.
CvPoint2D64f
2D point, represented as a tuple (x, y) , where x and y are floats.
CvPoint3D64f
3D point, represented as a tuple (x, y, z) , where x, y and z are floats.
由此看到,Point相关的传tuple,这是很容易理解的
CvSize
Size of a rectangle, represented as a tuple (width, height) , where width and height are integers.
CvSize2D32f
Size of a rectangle, represented as a tuple (width, height) , where width and height are floats.
CvRect
Rectangle, represented as a tuple (x, y, width, height) , where all are integers.
CvScalar
CvScalar is always represented as a 4-tuple.
>>> import cv >>> cv.Scalar(1, 2, 3, 4) (1.0, 2.0, 3.0, 4.0) >>> cv.ScalarAll(7) (7.0, 7.0, 7.0, 7.0) >>> cv.RealScalar(7) (7.0, 0.0, 0.0, 0.0) >>> cv.RGB(17, 110, 255) (255.0, 110.0, 17.0, 0.0)
CvTermCriteria
Represented by a tuple (type, max_iter, epsilon) .
(cv.CV_TERMCRIT_ITER, 10, 0) # terminate after 10 iterations (cv.CV_TERMCRIT_EPS, 0, 0.01) # terminate when epsilon reaches 0.01 (cv.CV_TERMCRIT_ITER | cv.CV_TERMCRIT_EPS, 10, 0.01) # terminate as soon as either condition is met
------------------------------分割--------------------------------------
CvMat
A multi-channel 2D matrix. Created by CreateMat , LoadImageM , CreateMatHeader , fromarray .
- type
- A CvMat signature containing the type of elements and flags, int
CvMatND
- type
- A CvMatND signature combining the type of elements and flags, int
- tostring() → str
- Returns the contents of the CvMatND as a single string.
IplImage
- tostring() → str
- Returns the contents of the CvMatND as a single string.
CvArr
CvArr is used only as a function parameter to specify that the parameter can be:
- an IplImage
- a CvMat
- any other type that exports the array interface 即要有__array_interface__属性
于此看来,point size color scaler 啥的用tuple就可以了,而mat iplimage 啥的要用opencv上定义的,但有一个疑惑是有次需要传mat的时候,我传入了一个list竟然没有出问题。有人能帮忙解释下么?