opencv-python cv2接口下错误TypeError: mat data type=18 is not supported
2017-02-01 23:34
543 查看
这个错误原因是因为nbarray这个对象内置一个类别属性,该属性记录了数组元素的类别,属性接口为
ndarray.astype(dtype,order='K',casting='unsafe',
subok=True, copy=True)
(详见文档 ndarray.astype
)
该属性在python-opencv mat数据类型必须定义为整型,所以,在调用imshow前只需配置一下该属性即可,代码是:ndarrayObject.astype(int),由于opencv3在python上取消了c++风格的cv接口,只保留了专门为python设计的matlab风格的cv2接口,说明官方也是提倡规范opencv在python上的使用,而cv2接口采用numpy作为重要的数据结构及处理库以取代c++中的mat等结构,所以要玩好opencv-python,熟悉numpy的基本数据操作是非常必要的。
ndarray.astype(dtype,order='K',casting='unsafe',
subok=True, copy=True)
(详见文档 ndarray.astype
)
该属性在python-opencv mat数据类型必须定义为整型,所以,在调用imshow前只需配置一下该属性即可,代码是:ndarrayObject.astype(int),由于opencv3在python上取消了c++风格的cv接口,只保留了专门为python设计的matlab风格的cv2接口,说明官方也是提倡规范opencv在python上的使用,而cv2接口采用numpy作为重要的数据结构及处理库以取代c++中的mat等结构,所以要玩好opencv-python,熟悉numpy的基本数据操作是非常必要的。
相关文章推荐
- python错误: TypeError:'dict' object is not callable
- Python 3.5 Socket TypeError: a bytes-like object is required, not 'str' 错误提示
- python错误:TypeError: 'module' object is not callable
- 【Python】python "TypeError: 'NoneType' object is not iterable"错误分析
- python错误:TypeError: 'str' object is not callable
- SQL Server error "Xml data type is not supported in distributed queries" and workaround for it
- Python错误代码分析:莫名的[TypeError: 'int' object is not iterable]
- python write()参数错误,导致报错TypeError: a bytes-like object is required, not 'str'
- python错误:TypeError: 'module' object is not callable
- 【Python 笔记】命名域之 TypeError 'DataFrame' object is not callable
- python3中,socket使用send函数时出现的错误:TypeError: a bytes-like object is required, not 'str'
- Python 出现错误TypeError: ‘NoneType’ object is not iterable解决办法
- javascript 错误 "Uncaught TypeError: string is not a function"
- python TypeError: 'builtin_function_or_method' object is not iterable keys
- TypeError: decoding Unicode is not supported
- Python编译时提示“NameError: name 'Popen' is not defined”及”NameError: name 'PIPE' is not defined“错误的解决
- shared_ptr.hpp(321) : error C2039: 'type_info' : is not a member of 'std' 错误修正
- python 的cx_Oracle模块的cx_Oracle.NotSupportedError: Variable_TypeByValue(): unhandled data type unicode解决办法
- 解决yum错误Error: requested datatype primary not available
- python class中遇到的TypeError: 'module' object is not callable