cv2.cv.Round在OpenCV 3.2.0中有实现吗?我发现前缀cv2.cv被移除,而cv2参数大部分被使用。但我在医生里找不到任何关于圆形的东西。我知道cv2.cv.Round在早期版本中工作过。尝试3.2.0中的cv2循环会抛出一个错误。
AttributeError: 'module' object has no attribute 'Round'因为cv2.cv被删除了,所以这也会像预期的那样抛出错误。
cv2.cv.Round(133.4)
AttributeError: 'module' object has no attribute 'cv'发布于 2017-11-24 12:23:04
再也没有cv2.round、cv2.cv.round或其他东西了。
你可以做到这一点。
>>> sys.version
'3.5.2 (default, Nov 17 2016, 17:05:23) \n[GCC 5.4.0 20160609]'
>>> xxx = [-3.6,-3.5,-3.4,3.4,3.5,3.6]
>>> print(xxx)
[-3.6, -3.5, -3.4, 3.4, 3.5, 3.6]
>>> list(map(round, xxx))
[-4, -4, -3, 3, 4, 4]
>>> func = lambda x: int(x+0.5) if x>0 else int(x-0.5)
>>> list(map(func, xxx))
[-4, -4, -3, 3, 4, 4]https://stackoverflow.com/questions/47472700
复制相似问题