【发布时间】:2019-03-24 02:55:47
【问题描述】:
我是 python 新手。我在谷歌上搜索 python 代码来检测路牌,我找到了一些代码,但我不明白代码的含义。
elif dominant_color[0] > 80:
zone_0 = square[square.shape[0]*3//8:square.shape[0]
* 5//8, square.shape[1]*1//8:square.shape[1]*3//8]
cv2.imshow('Zone0', zone_0)
zone_0_color = warnadominan(zone_0, 1)
zone_1 = square[square.shape[0]*1//8:square.shape[0]
* 3//8, square.shape[1]*3//8:square.shape[1]*5//8]
cv2.imshow('Zone1', zone_1)
zone_1_color = warnadominan(zone_1, 1)
zone_2 = square[square.shape[0]*3//8:square.shape[0]
* 5//8, square.shape[1]*5//8:square.shape[1]*7//8]
cv2.imshow('Zone2', zone_2)
zone_2_color = warnadominan(zone_2, 1)
提前致谢
【问题讨论】:
-
正方形。 shape 是一个元组,数组的维度。
-
如果将形状的两个元素分配给变量,代码会更清晰,例如
h, w = square.shape,然后使用像square[h*3//8:h*5//8, w*1//8:w*3//8]这样的索引表达式,它选择中间一半的行和四分之一的列(大约)。
标签: python-3.x numpy opencv