我知道,这样是不是租来的编码器,但我有一个非常简单的Python的例子,我需要帮助翻译到C++Python的阵列管理C++相当于
grey_image_as_array = numpy.asarray(cv.GetMat(grey_image))
non_black_coords_array = numpy.where(grey_image_as_array > 3)
# Convert from numpy.where()'s two separate lists to one list of (x, y) tuples:
non_black_coords_array = zip(non_black_coords_array[1], non_black_coords_array[0])
第一个是相当简单的我想 - 一个线性可索引数组是使用什么字节从cv.GetMat
重新创建的,对吧?
相当于pyton的where
,特别是zip
的功能是什么?
对于zip,看看这个问题(你应该能够使用boost :: zip_iterator):http://stackoverflow.com/questions/8511035/sequence-zip-function-for-c11 – ChristopheD 2012-02-28 23:32:57
你不'因为你需要以'non_black_coords_array'具有所需结构的方式编写代码,所以需要在C++中使用'zip()'。它在Python中是必需的,因为你无法控制'numpy.where()'的输出格式。 – 2012-02-28 23:35:42