首页 > 解决方案 > numpy shape[::-1] 中的参数 -1 是什么意思?

问题描述

numpy shape[::-1] 中的参数 -1 是什么意思?

template = cv2.imread('template.jpg',0)
w, h = template.shape[::-1]

标签: pythonnumpy

解决方案


在这里,它与numpy无关。您正在使用 [start:end:step] 访问一个元组(有关更多详细信息,请参阅此问题),使用 -1 的步骤意味着您颠倒了顺序。


推荐阅读