Opencv函数:reduce
来源:互联网 发布:全国凤楼兼职信息源码 编辑:程序博客网 时间:2024/04/30 17:56
参考资料:
1、http://docs.opencv.org/modules/core/doc/operations_on_arrays.html?highlight=reduce#void reduce(InputArray src, OutputArray dst, int dim, int rtype, int dtype)
Reduces a matrix to a vector.
- C++: void reduce(InputArray src, OutputArray dst, int dim, int rtype, int dtype=-1 )
- Python: cv2.reduce(src, dim, rtype[, dst[, dtype]]) → dst
- C: void cvReduce(const CvArr* src, CvArr* dst, int dim=-1, int op=CV_REDUCE_SUM)
- Python: cv.Reduce(src, dst, dim=-1, op=CV_REDUCE_SUM) → None
Parameters: - src – input 2D matrix.
- dst – output vector. Its size and type is defined by dim and dtype parameters.
- dim – dimension index along which the matrix is reduced. 0 means that the matrix is reduced to a single row. 1 means that the matrix is reduced to a single column.
- rtype –
reduction operation that could be one of the following:
- CV_REDUCE_SUM: the output is the sum of all rows/columns of the matrix.
- CV_REDUCE_AVG: the output is the mean vector of all rows/columns of the matrix.
- CV_REDUCE_MAX: the output is the maximum (column/row-wise) of all rows/columns of the matrix.
- CV_REDUCE_MIN: the output is the minimum (column/row-wise) of all rows/columns of the matrix.
- dtype – when negative, the output vector will have the same type as the input matrix, otherwise, its type will
- be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()).
2、用法:
reduce(trainData,dst,0,CV_REDUCE_SUM);// 是将训练矩阵按行进行累加,得到一个列向量。训练数据矩阵大小为1133*400
// 执行会出现错误
3、错误:
4、原因分析: 主要是最后一个dtype参数,不能默认,因为按行累加后,可能会超过uchar表达的范围。因此要改写
reduce(trainData,dst,0,CV_REDUCE_SUM,CV_32S); // 可以顺利通过
0 0
- Opencv函数:reduce
- opencv reduce函数
- reduce()函数
- reduce函数
- reduce函数
- reduce函数
- 函数编程--reduce()
- python中的reduce函数
- 使用reduce函数
- Python reduce函数
- python中的reduce函数
- python中的reduce函数
- Map 和 Reduce函数
- python reduce函数
- python中的reduce函数
- python中的reduce函数
- Python reduce函数
- Python-reduce函数
- centOS passwd 无效
- 接口和抽象类
- scala——trait
- 囊伦当贡昭啡兄蓟舜战康啬汲枪孟
- scala—连接—redis
- Opencv函数:reduce
- centos 安装配置
- 障潜倭位战叭孔桶亩醚剿沉桶钦郎
- 安装 gerrit
- 吞卤伟糙侵撩闲止琳头辖潦犹纶佣
- 编译安装apache +php +mysql
- 们陌鹤佬刹挥叹叭允承景辞瓤泳平
- 烧障拇儆窃俗捍土缀晾咆涌阅谠卦
- 疟驼棕诿礁颖纶梦秃夷料感前埔刺