<< operator
I saw something like this in some source files of OpenCV:
(double)(1<<16)
What does the operator << do?
Thanks.
I saw something like this in some source files of OpenCV:
(double)(1<<16)
What does the operator << do?
Thanks.
in this case it's a binary shift, 1 gets bitwise shifted to the left.
(1 << 16) === (2 ** 16) === pow(2,16) = 65536
but beware, the << and the >> operators are overloaded multiple times (e.g for io)
cout << "l2l2l2";
int n; cin >> n;
or for special operations, as in here:
Mat dm = (Mat_<double>(2,2) << 1.0, 0.0, 3.0, -1.0); // 2x2 double mat with initaialization list
More exactly, a << b means a*2^b. (http://en.wikipedia.org/wiki/Binary_shift#Bit_shifts)
Actually it depends from case to case. It is an operator that can be specified for each type of input it gets. I know for example that it can be used to effectively retrieve a frame from a capture.
Mat frame;
capture >> frame;
This calls internally the function
capture.read();
No idea what this operator does exactly in this case. But it could be something like creating an array of double elements running from 1 -> 16?
Asked: 2013-04-09 05:10:20 -0600
Seen: 863 times
Last updated: Apr 09 '13