我想從python內部調用OpenCV函數MinAreaRect2。 我用Python 2.7和numpy 1.6使用OpenCV 2.4.2。 我去這遠:Python OpenCV Box2D
import cv
def nda2ipl(arr, dtype=None):
return cv.fromarray(np.ascontiguousarray(arr, dtype=dtype))
def min_area_rect2(points):
storage = cv.CreateMemStorage()
cv_points = nda2ipl(points.reshape((-1, 1, 2)))
out = cv.MinAreaRect2(cv_points, storage)
return out
我可以調用此功能與形狀的ndarray(N×2)。我得到這個樣的結果:
((476.5, 604.5), (951.0, 1207.0), -0.0)
我認爲第一個元組是盒子的中心,第二給出了寬度,高度和上次的角度。
問題是我無法得到一個明確的參考說明這一點。實際上,opencv文檔告訴我函數在Python中返回什麼。我發現official documentation about this function但這不是很有幫助。
在python中MinAreaRect2的輸出究竟是什麼? 更一般地說,你從哪裏獲得有關OpenCV python包裝的精確文檔?
感謝您的幫助! – 2012-08-03 19:05:11
不知何故令人失望,看起來他們已經[推遲](http://code.opencv.org/issues/2023)將BoxPoints添加到文檔的請求,直到OpenCV 3.0 – 2013-05-17 22:56:15