Closed darkdragon-001 closed 7 years ago
Direct using of fields in well written code should be avoided, please use methods instead: .ptr()
/.at()
with .step()
, .elemSize()
methods. They are more safe and provide some useful checks in debug mode.
For my time critical application, I am using direct pointers for speed reasons.
Is my following interpretation correct?
datastart <= data <= dataend <= datalimit. On this picture your should swap data <-> datastart. datalimit is almost not used (and it may be located after the current "datalimit" pointer). dataend should be placed on datalimit location. There is no field which points "on the end" of green region.
step[1] (which is step[dims-1]) is always equal to sizeof(matrix element)
(CV_8U => 1, CV_32FC3 => 12).
See locateROI() code.
BTW, There is good simple example of efficient code.
So datalimit points to the end off allocated storage?
Does this picture now represent reality better?
Based on this code, dataend
should be less or equal than datalimit
.
On your picture there is missing "alignment area" on the right side (for example), that doesn't hold any matrix elements, but it aligns rows starting addresses. BTW, In general step[0] may be not divisible on element size.
dataend
is located after last valid image byte. datalimit probably points to the end of allocated buffer (after "alignment area").
I assume that green is Image ROI (region of interest), white cells are Image data (these values can be used too, for example in image filters for border values (if there is no BORDER_ISOLATE
flag).
In order to avoid confusion (is it allocated space or not?), I guess one should clearly define datalimit
and document it directly in the code.
Is anything else missing in my image?
white background: alloated data
black border: matrix elements
green background: ROI
pointers: datastart, data, dataend, datalimit
size in bytes: step
number of elements: rows, cols
ok, it can be closed, as it still can be referenced, even after being closed
what about if the image has multi channel?
Can somebody explain me the exact purpose of these member fields?
Since these members are neither well documented via Doxygen (see member definitions ) nor seems their purpose clear to other developers (see code comments).