Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8276205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:18:38+00:00 2026-06-08T08:18:38+00:00

I’m trying to read a data file (1000 x 5 doubles) into a Mat

  • 0

I’m trying to read a data file (1000 x 5 doubles) into a Mat object. The Mat object was initialized as Mat::zeros(1000,5,CV_32F). While each line of data were read, the corresponding row were assigned to the new values. The code is shown below:

void readNavFile(const char* filename, Mat& navdata) {

    ifstream infile(filename);
    string line;
    int x=0, y=0;

    if (infile.is_open()) {

        while (getline(infile, line)) {
            double value;
            stringstream converter(&line[0]);
            double* p = navdata.ptr<double>(x);
            while (converter >> value) {

                p[y++] = value;
                //DEBUGING
                cout << "Pointer value:" << p[y-1] << endl;
                cout << "Matrix value at:" << "row:" << x << " col:" << y-1 <<" is: "<< navdata.at<double>(x,y-1)<< endl;
                cout << navdata.at<double>(0,4) << endl;

            }
            y = 0;
            x++;
        }

        infile.close();
        //DEBUGING
        cout << "Final matrix first row, last element:" << navdata.at<double>(0,4) << endl;
    }
}

As you can see, I try to print out the value of the Mat (matrix) element as they are assigned so I can be sure the correct values are stored. The weird thing is the assignment all went well however some of the previously assigned elements would all of suddent change their value. A sample output looks like the followings, at the last line, after assigning element [1,2], the value at [0,4] changed from its correct value 18.1901 to 3.31757e-190:

Pointer value:-35.1236
Matrix value at:row:0 col:0 is: -35.1236
Matrix element [0,4]: 0
Pointer value:150.735
Matrix value at:row:0 col:1 is: 150.735
Matrix element [0,4]: 0
Pointer value:360.094
Matrix value at:row:0 col:2 is: 360.094
Matrix element [0,4]: 0
Pointer value:3.46045
Matrix value at:row:0 col:3 is: 3.46045
Matrix element [0,4]: 0
Pointer value:18.1901
Matrix value at:row:0 col:4 is: 18.1901
Matrix element [0,4]: 18.1901
Pointer value:-35.1236
Matrix value at:row:1 col:0 is: -35.1236
Matrix element [0,4]: 18.1901
Pointer value:150.735
Matrix value at:row:1 col:1 is: 150.735
Matrix element [0,4]: 18.1901
Pointer value:360.096
Matrix value at:row:1 col:2 is: 360.096
Matrix element [0,4]: 3.31757e-190

Could someone help me to figure out what’s going on? Thank you very much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:18:39+00:00Added an answer on June 8, 2026 at 8:18 am

    32F stands for float in OpenCV. navdata.at<double>(0,4) is incorrect. You should use navdata.at<float>(0,4)or, change your datatype to 64F. Also, OpenCV should have thrown an exception for your code. Are you sure it didn’t?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.