<分区>
请原谅我问了一个可能过于宽泛的问题。但是,我的任务非常具体:没有太多 Python 经验,我想将 Python 代码重写为 C++ (OpenCV),我想知道是否有针对某些 C++ 库的良好文档比较(我知道存在 OpenBLAS、Eigen、等),这将使我相对容易地重复原始代码中的所有数组操作,这对我使用 OpenCV 来说是一个相当大的挑战。也许有人真的写过关于语法比较的帖子?
Python代码:
image = im_orig.copy()
# Create input for multiples of net input/output changes.
im_bg_width = int(_np.ceil(
float(image.shape[1]) * scale_factor / _STRIDE) * _STRIDE)
im_bg_height = int(_np.ceil(
float(image.shape[0]) * scale_factor / _STRIDE) * _STRIDE)
pad_size = 64
im_bot_pixels = image[-1:, :, :]
im_bot = _np.tile(im_bot_pixels, (pad_size, 1, 1))
image = _np.vstack((image, im_bot))
im_right_pixels = image[:, -1:, :]
im_right = _np.tile(im_right_pixels, (1, pad_size, 1))
image = _np.hstack((image, im_right))
image = _scipy.misc.imresize(image, scale_factor, interp='bilinear')
image = image.astype('float32') - _MEAN
net_input = _np.zeros((im_bg_height, im_bg_width, 3), dtype='float32')
net_input[:min(net_input.shape[0], image.shape[0]),
:min(net_input.shape[1], image.shape[1]), :] =\
image[:min(net_input.shape[0], image.shape[0]),
:min(net_input.shape[1], image.shape[1]), :]
编辑:我想不惜一切代价摆脱对 python 的依赖(尤其是对 python C++ API 的依赖),并使程序真正可读,这与 Cython 生成的程序不同。