c++ - Reading data cv::Mat -
I'm looking for a better way to get data from a cv :: Mat 32F3C
. It was using: Vec3f c1 = _image.at
Vec3f c1 (_image.data [step [0] * i + step [1] ] * J + 0], _ image.data [step [0] * i + step [1] * j + 1], _ image data [step [0] * i + phase [1] * j + 2]) ;
It is compiled but this is not correct, I also tried:
Vec3f c1 (_image.data [step * i + channels * j + 0], _image.data [step * i + channel * j + 1], _ image.data [step * i + channel * j + 2]);
But the only thing is, it compiles, but gives me another absurd result.
I should be reminded of one factor or something.
Thank you!
You can find useful in OpenCV-documentation. However, I will first write the code which is easy to understand, and only optimizes it, if it becomes clear that I have to customize exactly that portion of the source code.
The summary of the article is that there are three ways to access the pixels:
-
On-the-fly address count:
Const cv :: Vec3f & amp; Pixel = img.at & lt; Cv :: Vec3f & gt; (Y, x)
-
Iterator:
cv: MatIterator & lt; Cv :: Vec3f & gt; This = img.begin (), end = img.end (); (; It! = End; + it) (* it) [0] = (* it) [1]
-
Pointer:
cv :: Vec3f * pixel_ptr; For (int y = 0; y and lt; img.rows; ++ y) {pixel_ptr = img.ptr & lt; Cv :: Vec3f & gt; (why); For (int x = 0; x & lt; img.cols; ++ x) {(* pixel_ptr) [0] = (* pixel_ptr) [1] ++ pixel_peter; }}
Comments
Post a Comment