将数据放入Opencv中的Mat对象中
Putting data inside a Mat object in Opencv
我试图从文件中读取数据,将其存储在双数组中,然后使用Mat构造函数创建包含该数据的对象。然而,输出结果与预期不符。
ifstream in;
in.open("data");
double d[500][2];
for(int i=0;i<500;i++)
{
for(int j=0;j<2;j++)
{
in>>d[i][j];
}
}
Mat samples = Mat(500,2,CV_32FC1,&d);
for(int i=0;i<5;i++)
{
cout<<"n";
for(int j=0;j<2;j++)
{
cout<<d[i][j]<<" ";
}
}
cout<<"nSamples";
for(int i=0;i<5;i++)
{
cout<<"n";
for(int j=0;j<2;j++)
{
cout<<samples.at<double>(i,j)<<" ";
}
}
Mat samples = Mat(500,2,CV_32FC1,&d); // that's a *float* Mat !
你想要的;
Mat samples = Mat(500,2,CV_64FC1,&d);
相关文章:
- 如何将 cv::mat 对象从 python 模块传递到 c++ 函数并返回返回的 cv::mat 类型为对象?
- OpenCV Otsu的阈值:计算多个Mat对象的单个阈值
- 当我更改其他 Mat 对象时,垫子值会更改
- 无法在类中分配 cv::Mat 对象C++
- 将 Mat 对象C++传递给 Unity
- 为什么包装 setMouseCallback 会导致 Mat 对象为空
- OpenCV Mat对象复制速度更快
- 在cv::Mat对象上循环时,内存位置出现cv::异常
- OpenCV-C++中Mat对象的平均值
- OpenCV格式化程序类和Mat对象的cout产生链接器错误:体系结构x86_64的未定义符号:libopencv_co
- 如何从XML文件(OpenCV)将一定数量的行读入Mat对象
- 在 Java 客户端中创建 Mat 对象,使用 opencv 从C++服务器发送
- 通过套接字将 Mat 对象从 c++ 发送到 Java
- 为什么OpenCV Mat对象在嵌套for循环中指定了预期值后却不包含这些值
- 如何将像素设置为cv::Mat对象中的值
- 将Mat对象从androidjava传递到本机cpp部分
- I'm试图将像素数据转换为OpenCV Mat对象
- 如何在Android中从文件中读取OpenCV Mat对象
- Zeros Mat 对象具有除零以外的一些值
- 如何调整空的 cv::Mat 对象