@Name(value="cv::Rect_<int>") @NoOffset @Properties(inherit=opencv_core.class) public class Rect extends IntPointer
described by the following parameters: - Coordinates of the top-left corner. This is a default interpretation of Rect_::x and Rect_::y in OpenCV. Though, in your algorithms you may count x and y from the bottom-left corner. - Rectangle width and height.
OpenCV typically assumes that the top and left boundary of the rectangle are inclusive, while the right and bottom boundaries are not. For example, the method Rect_::contains returns true if
\[x \leq pt.x < x+width,
y \leq pt.y < y+height\]
Virtually every loop over an image ROI in OpenCV (where ROI is specified by Rect_\
This is an example how the partial ordering on rectangles can be established (rect1
In addition to the class members, the following operations on rectangles are implemented:
-
for(int y = roi.y; y < roi.y + roi.height; y++)
for(int x = roi.x; x < roi.x + roi.width; x++)
{
// ...
}
\texttt{rect} = \texttt{rect} \pm \texttt{point}
(shifting a rectangle by a certain offset)
- \texttt{rect} = \texttt{rect} \pm \texttt{size}
(expanding or shrinking a rectangle by a
certain amount)
- rect += point, rect -= point, rect += size, rect -= size (augmenting operations)
- rect = rect1 & rect2 (rectangle intersection)
- rect = rect1 | rect2 (minimum area rectangle containing rect1 and rect2 )
- rect &= rect1, rect |= rect1 (and the corresponding augmenting operations)
- rect == rect1, rect != rect1 (rectangle comparison)
\subseteq
rect2):
For your convenience, the Rect_\<\> alias is available: cv::Rect
template<typename _Tp> inline bool
operator <= (const Rect_<_Tp>& r1, const Rect_<_Tp>& r2)
{
return (r1 & r2) == r1;
}
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
Rect()
default constructor
|
Rect(int _x,
int _y,
int _width,
int _height) |
Rect(long size)
Native array allocator.
|
Rect(Pointer p)
Pointer cast constructor.
|
Rect(Point pt1,
Point pt2) |
Rect(Point org,
Size sz) |
Rect(Rect r) |
Modifier and Type | Method and Description |
---|---|
int |
area()
area (width*height) of the rectangle
|
Point |
br()
the bottom-right corner
|
boolean |
contains(Point pt)
checks whether the rectangle contains the point
|
boolean |
empty()
true if empty
|
int |
height()
height of the rectangle
|
Rect |
height(int setter) |
Rect |
position(long position) |
Rect |
put(Rect r) |
Size |
size()
size (width, height) of the rectangle
|
Point |
tl()
the top-left corner
|
int |
width()
width of the rectangle
|
Rect |
width(int setter) |
int |
x()
x coordinate of the top-left corner
|
Rect |
x(int setter) |
int |
y()
y coordinate of the top-left corner
|
Rect |
y(int setter) |
asBuffer, capacity, get, get, get, get, getString, getStringCodePoints, limit, put, put, put, put, putString, sizeof
address, asByteBuffer, availablePhysicalBytes, calloc, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, isNull, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, toString, totalBytes, totalPhysicalBytes, withDeallocator, zero
public Rect(Pointer p)
Pointer.Pointer(Pointer)
.public Rect(long size)
Pointer.position(long)
.public Rect()
public Rect(int _x, int _y, int _width, int _height)
public Rect position(long position)
position
in class IntPointer
public int area()
@Cast(value="bool") public boolean contains(@Const @ByRef Point pt)
public int x()
public Rect x(int setter)
public int y()
public Rect y(int setter)
public int width()
public Rect width(int setter)
public int height()
public Rect height(int setter)
Copyright © 2020. All rights reserved.