使用小数组制作长向量(列矩阵)
Making a long vector(coloumn Matrix) using small arrays
我正在尝试制作一个包含数组元素的向量(特征向量)。
假设我在第一次迭代中有一个大小为 nx1
的数组arr1
。我必须将此数组元素添加到大小CvMat
矩阵featureVect
中,2*n x 1
.
在下一次迭代中,我有一个大小为 nx1
的数组arr2
,现在我必须将此数组添加到从第 n+1
行到2*n
featureVect
(使用基于一的索引)
假设我有
int arr1[4] = {1, 2, 3, 4};
int arr2[4] = {5, 6, 7, 8};
CvMat *featureVect;
现在我希望结果看起来像这样(其中featureVect
是单列矩阵)
featureVect = {1, 2, 3, 4, 5, 6, 7, 8};// featureVect size is 8x1;
如果你在OpenCV中使用C++,我会推荐Mat
类。然后
Mat featureVect(8,1,CV_32S); //CV_32s <=> int (32-bit signed integer)
const int n = 4;
for(int i = 0; i < n; ++i)
{
featureVect.at<int>(i,0) = arr1[i];
featureVect.at<int>(i+n,0) = arr2[i];
}
相关文章:
- 写入向量<向量<bool>>
- 函数向量_指针有不同的原型,我可以构建一个吗
- std::向量与传递值的动态数组
- 将值指定给向量(2D)的向量中的某个位置
- 找不到成员对象:没有名为get_event()的成员,也处理多态性和向量
- 如何使用向量的template_back函数
- 尝试通过多个向量访问变量时,向量下标超出范围
- C++将浮点指针值舍入为小数位数
- 如何通过派生类函数更改基类中的向量
- C++从另一个类访问公共静态向量的正确方法是什么
- 如何将ampl中的集合表示为c++中的向量
- 从给定的 I 和 D 序列中形成最小数
- 如何防止 c++ 在从浮点型转换为双精度型(不适用于 IO)时添加额外的小数?
- 变量没有改变?通过向量的函数调用
- 迭代时从向量和内存中删除对象
- 向量 <int> a {N, 0} 和 int arr a[N] = {0} 的时间复杂度有什么区别
- 使用小数组制作长向量(列矩阵)
- 不能做一个固定大小数组的向量
- 固定大小数组的向量
- std:vector<char[30]>有效,或者如何实现这一点?(固定大小数组的向量?