如何更新返回值"res"?(ConcativeMat Con NN)
How does the return value "res" is updated? (ConcativeMat Con NN)
我有一个关于for循环及其返回值的问题。这是c++代码,我使用的是openCV 2.4V。
该函数的输入是带池的600张图片的最大值。600张图片<<池& lt; & lt;最大值点。"res"矩阵的大小为600x128, vec.size() = 600。
对于我来说,在For循环中,res永远不会更新,但是返回值不是零。
I suspect
" ptmat.copyTo(子视图)"
因为,我认为那是没有必要的行。然而,当我把它拿出来时,res没有得到更新(像初始Mat一样为零)。有人能解释一下res值是如何更新的吗?
为什么这个函数被称为concatenate..?
Mat
concatenateMat(vector<vector<Mat> > &vec) {
int subFeatures = vec[0][0].rows * vec[0][0].cols;
int height = vec[0].size() * subFeatures;
int width = vec.size();
Mat res = Mat::zeros(height, width, CV_64FC1);
for (int i = 0; i<vec.size(); i++) {
for (int j = 0; j<vec[i].size(); j++) {
Rect roi = Rect(i, j * subFeatures, 1, subFeatures);
Mat subView = res(roi);
Mat ptmat = vec[i][j].reshape(0, subFeatures);
ptmat.copyTo(subView);
}
}
return res;
}
根据OpenCV文档,Mat::操作符()不会复制矩阵数据,因此循环中对subView矩阵对象的任何更改也将反映在res矩阵对象中。这就是你提到的那一行:
ptmat.copyTo(subView);
它被称为concatenate是因为它将Mat对象的2D向量连接成一个。
相关文章:
- OpenCV 3.4.1 error readNetFromTensorflow 无法在 cv::d nn::ReadProtoFromBinaryFile 中打开 .pb
- CMake 用于设定C++标准的设施 "at least C++NN"
- 训练 NN 以计算 atan2(y, x)
- 如何解决 ReLU 不是构建时火炬::nn 错误的成员?
- 在哪里放置pthread Mutex和con var,以确保激活所有功能
- 支持向量机 (SVM) 与 K-NN 测试效率
- 如何从 k-d 树实现 K-NN 分类
- 开放CV C 人识别K-NN
- YACC递归中的con缩值
- 带有G 的破坏者con C (中止(核心倾倒))
- Herb Sutter 的 C++Con 2014 演讲中的完美货运代理
- 在 c++ 中调用 lua 函数(带有 require 'nn')
- fpermissive class constructorstack class: fpermissive on con
- C++程序在执行时崩溃且没有错误消息 con = 驱动程序>连接(主机、用户、通行证);
- 如何更新返回值"res"?(ConcativeMat Con NN)