Ask Your Question
0

What means "Returns the specified element of the top-level mapping"?

asked 2017-03-30 02:41:06 -0600

el_cid gravatar image

updated 2017-03-30 02:54:07 -0600

In the camera calibration tutorial (link: http:// docs.opencv.org/2.4/doc/tutorials/calib3d/ camera_calibration/camera_calibration.html# ), in part 1. Read the Settings) there is the line:

fs["Settings"] >> s;

which I don't understand. In the reference to the class FileStorage, of which fs is a member, [ ] is overloaded by:

FileNode    operator[] (const String &nodename) const

which is described by

Returns the specified element of the top-level mapping.

  1. What does this description mean?
  2. Why in the definition of the overloading, there is a "const" after "...&nodename)" ?
  3. What is the operator >> doing? By default it's the bitwhise shifting, right? What would bitwise shifting do here?

Thank you in advance for your answers.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2017-03-30 02:51:44 -0600

berak gravatar image

updated 2017-03-30 03:18:38 -0600

  • What does this description mean?

    a FileNode can hold either a single item (a number, string, or Mat), or a list of such items

  • what is the operator >> doing?

    in c++, you can "overload" operators, to add new functionality. in the same way, you can write something to cout using cout << mystring , you can write to a filenode using fs << "K" << 17, and read it back using int n; fs["K"] >> n; (maybe you can think of it as a primitive database / key-value store)

  • there is a "const" ..

    this means, that the FileNode is not altered by reading from it.

you might want to take a look at the tutorial

edit flag offensive delete link more

Comments

Asking humans is so great, thank you. :) But where is this overloading defined? I cannot find it in the FileStorage class definiton, Or maybe better: What's an intelligent way to search for the definition of such an overload?

el_cid gravatar imageel_cid ( 2017-03-30 03:04:26 -0600 )edit

yea, admittedly tricky ;) e.g. for char* , it's here

berak gravatar imageberak ( 2017-03-30 03:13:01 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-03-30 02:41:06 -0600

Seen: 210 times

Last updated: Mar 30 '17