@Name(value="cv::Rect_<int>")
@NoOffset
public static class opencv_core.Rect
extends org.bytedeco.javacpp.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
\f[x \leq pt.x < x+width, y \leq pt.y < y+height\f]
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 \f$\subseteq\f$
rect2):
In addition to the class members, the following operations on rectangles are implemented:
- \f$\texttt{rect} = \texttt{rect} \pm \texttt{point}\f$ (shifting a rectangle by a certain offset)
- \f$\texttt{rect} = \texttt{rect} \pm \texttt{size}\f$ (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)
for(int y = roi.y; y < roi.y + roi.height; y++)
for(int x = roi.x; x < roi.x + roi.width; x++)
{
// ...
}
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;
}
| Constructor and Description |
|---|
Rect()
default constructor
|
Rect(int _x,
int _y,
int _width,
int _height) |
Rect(long size)
Native array allocator.
|
Rect(opencv_core.Point pt1,
opencv_core.Point pt2) |
Rect(opencv_core.Point org,
opencv_core.Size sz) |
Rect(opencv_core.Rect r) |
Rect(org.bytedeco.javacpp.Pointer p)
Pointer cast constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
area()
area (width*height) of the rectangle
|
opencv_core.Point |
br()
the bottom-right corner
|
boolean |
contains(opencv_core.Point pt)
checks whether the rectangle contains the point
|
boolean |
empty()
true if empty
|
int |
height()
height of the rectangle
|
opencv_core.Rect |
height(int height) |
opencv_core.Rect |
position(long position) |
opencv_core.Rect |
put(opencv_core.Rect r) |
opencv_core.Size |
size()
size (width, height) of the rectangle
|
opencv_core.Point |
tl()
the top-left corner
|
int |
width()
width of the rectangle
|
opencv_core.Rect |
width(int width) |
int |
x()
x coordinate of the top-left corner
|
opencv_core.Rect |
x(int x) |
int |
y()
y coordinate of the top-left corner
|
opencv_core.Rect |
y(int y) |
asBuffer, capacity, get, get, get, get, getString, getStringCodePoints, limit, put, put, put, put, putStringaddress, asByteBuffer, availablePhysicalBytes, calloc, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, withDeallocator, zeropublic Rect(org.bytedeco.javacpp.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(@Const @ByRef
opencv_core.Rect r)
public Rect(@Const @ByRef
opencv_core.Point org,
@Const @ByRef
opencv_core.Size sz)
public Rect(@Const @ByRef
opencv_core.Point pt1,
@Const @ByRef
opencv_core.Point pt2)
public opencv_core.Rect position(long position)
position in class org.bytedeco.javacpp.IntPointer@ByRef @Name(value="operator =") public opencv_core.Rect put(@Const @ByRef opencv_core.Rect r)
@ByVal public opencv_core.Point tl()
@ByVal public opencv_core.Point br()
@ByVal public opencv_core.Size size()
public int area()
@Cast(value="bool") public boolean empty()
@Cast(value="bool")
public boolean contains(@Const @ByRef
opencv_core.Point pt)
public int x()
public opencv_core.Rect x(int x)
public int y()
public opencv_core.Rect y(int y)
public int width()
public opencv_core.Rect width(int width)
public int height()
public opencv_core.Rect height(int height)
Copyright © 2018. All rights reserved.