I have problem with changing array data to matrix.
I have a problem with changing array to matrix because array data type is not proper...
could you help me?
#include <iostream> // for cout, getline
#include <sstream> // for istringstream
#include <string> // for string
#include <opencv2\highgui\highgui.hpp>
#include <fstream>
#include <stdio.h>
using namespace std; using namespace cv;
int main() { std::ifstream file("cell2.txt"); // assume the file opens correctly
double matrix[256][256];
int row = 0, col = 0;
Mat abs_val;
Mat dst(256, 256, CV_32F);
//double dst[256][256];
std::string line;
while (std::getline(file, line)) { // read each line from the file
std::istringstream stream(line);
double x;
col = 0; // reset column counter
while (stream >> x) { // keep trying to read ints until there are no more
matrix[row][col] = x;
col++;
}
row++;
}
Mat matrix1(Size(256, 256), CV_32F, matrix);// = Mat(256, 256, CV_32FC1, matrix);
cout << matrix1 << endl;
system("pause >nul");
return 0;
}
in here when I change the array to the matrix, message data is not read properly...
0.0448286 0.0437008 0.0430881 0.0448606 0.0383793 0.044633 0.0411747 0.0460828 0.0449244 0.042626 0.0447564 0.0404438 0.0397293 0.0428335 0.0440014 0.0427125 0.039638 0.0450739 0.0387029 0.0405195
data type is like this.
Could you tell me problem or change type instead CV_32F?
hi, due to a lot of spam lately, this site has to go moderated. patience required, and please don't post duplicates ;)