Ask Your Question

SAKHILETI SATYA KISHORE's profile - activity

2018-03-12 15:53:01 -0600 received badge  Notable Question (source)
2017-05-12 01:35:48 -0600 received badge  Famous Question (source)
2016-11-13 03:44:57 -0600 received badge  Popular Question (source)
2016-07-21 17:00:56 -0600 received badge  Notable Question (source)
2016-02-24 08:50:18 -0600 received badge  Popular Question (source)
2014-09-25 05:19:38 -0600 commented answer how to read matrix from text file to Mat in opencv

'FileStorage' is able to handle .xml and .yml files. my file is .txt from which I've to load the float values.

2014-09-24 03:27:25 -0600 commented question how to read matrix from text file to Mat in opencv

Example: text file {1 5 0.666 0.535......2 0.24 0.82... 3 .042 .0287...} in this example the values 1 2 3 are frame numbers. expected output: {1 5 0.666 0.535........ 2 0.24 0.82......... 3 0.042 .0287.......} each row is one video frame.

2014-09-24 03:16:59 -0600 commented question how to read matrix from text file to Mat in opencv

thanks berak , the cols in the reshape function is separting rows.. can you help me in separating frame values in a text file for each frame in a matrix.

2014-09-24 02:55:33 -0600 commented question how to read matrix from text file to Mat in opencv

all the data in the txt file is being loaded as a single column .please help me in separating cols.

2014-09-24 02:22:38 -0600 asked a question how to read matrix from text file to Mat in opencv

Hi.. In my projec, I have to load matrix from a text file to MAt object in opencv. . Please help me in this regard.. eg 1 2 3 4 5 6 7 8 9 in text file. it should be loded to Mat

2014-09-23 02:40:39 -0600 commented question how to load matrix from text file(.txt) as float values

i am getting feature points stored in a .txt file.. I should read the float values in .txt file to a matrix in the same format..I should give the matrix as input to an algorithm...

2014-09-23 01:22:18 -0600 asked a question how to load matrix from text file(.txt) as float values

Hi.. I am doing a project on action recognition in which I have to load values in a text file which are in double type to a matrix in the double format in the Opencv c++.. I tried using FileStorage but could not load the .txt files.. Please help me in this regard..

I tried this code.

#include <iostream>  // for cout, getline
#include <sstream>  // for istringstream
#include <string>   // for string
#include <opencv2\highgui\highgui.hpp>
#include <fstream>
using namespace std;
using namespace cv;
int main() {
    std::ifstream file("E:\op.txt");  // assume the file opens correctly

    double matrix[500][10];
    int row = 0, col = 0;

    std::string line;
    while (std::getline(file, line)) {  // read each line from the file
        // okay we have a line, let's extract the numbers on this line
        // this is an "input string stream", a stream formed from a string
        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++;
        }

        // okay that's all the data on this line, go to the next line
        row++;
    }

    // now let's print out the data we read into the matrix.
    // At this point, row tells us how many rows there are, and
    // we never reset col so col still tells us how many values were on
    // the last line (let's hope this is the same as the other rows of the
    // matrix).
    for (int i = 0; i < row; i++) {
        for (int j = 0; j < col; j++) {
            std::cout << matrix[i][j];
        }
        std::cout << "\n";
        cout << typeid(matrix).name() << endl;

    }
    system("pause >nul");
    return 0;
}