我有一个问题是将numpy的ndarray函数转换为等效的OpenCV C++调用,以将n维cv :: Mat重新整形/拆分成适当的切片.特别是我试图将OpenCV python2示例"texture_flow.py"(> = OpenCV 2.4.3)转换为C++.我在下面的代码段中标记了有问题的行.
# [......]
img = cv2.imread(fn)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# simple width and height tuple
h, w = img.shape[:2]
eigen = cv2.cornerEigenValsAndVecs(gray, 15, 3)
print eigen.shape # prints: (height, widht, 6), i.e. 6 channels
# Problem 1:
# OpenCV's reshape function is not sufficient to do this.
# probably must be split into several steps...
eigen = eigen.reshape(h, w, 3, 2) # [[e1, e2], v1, v2]
print eigen.shape # prints: (height, width, …Run Code Online (Sandbox Code Playgroud)