MNN  1.0
Public 成员函数 | 静态 Public 成员函数 | Public 属性 | 所有成员列表
MNN::CV::Rect结构体 参考

#include <Rect.h>

Public 成员函数

bool isEmpty () const
 
bool isSorted () const
 
float x () const
 
float y () const
 
float left () const
 
float top () const
 
float right () const
 
float bottom () const
 
float width () const
 
float height () const
 
float centerX () const
 
float centerY () const
 
void setEmpty ()
 
void set (float left, float top, float right, float bottom)
 
void setLTRB (float left, float top, float right, float bottom)
 
void iset (int left, int top, int right, int bottom)
 
void isetWH (int width, int height)
 
void setXYWH (float x, float y, float width, float height)
 
void setWH (float width, float height)
 
Rect makeOffset (float dx, float dy) const
 
Rect makeInset (float dx, float dy) const
 
Rect makeOutset (float dx, float dy) const
 
void offset (float dx, float dy)
 
void offsetTo (float newX, float newY)
 
void inset (float dx, float dy)
 
void outset (float dx, float dy)
 
bool intersect (const Rect &r)
 
bool intersect (float left, float top, float right, float bottom)
 
bool intersect (const Rect &a, const Rect &b)
 
bool intersects (float left, float top, float right, float bottom) const
 
bool intersects (const Rect &r) const
 
void join (float left, float top, float right, float bottom)
 
void join (const Rect &r)
 
void joinNonEmptyArg (const Rect &r)
 
void joinPossiblyEmptyRect (const Rect &r)
 
bool contains (float x, float y) const
 
void sort ()
 
Rect makeSorted () const
 
const float * asScalars () const
 

静态 Public 成员函数

static constexpr Rect MakeEmpty ()
 
static constexpr Rect MakeWH (float w, float h)
 
static Rect MakeIWH (int w, int h)
 
static constexpr Rect MakeLTRB (float l, float t, float r, float b)
 
static constexpr Rect MakeXYWH (float x, float y, float w, float h)
 
static bool Intersects (const Rect &a, const Rect &b)
 

Public 属性

float fLeft
 smaller x-axis bounds 更多...
 
float fTop
 smaller y-axis bounds 更多...
 
float fRight
 larger x-axis bounds 更多...
 
float fBottom
 larger y-axis bounds 更多...
 

详细描述

Rect holds four float coordinates describing the upper and lower bounds of a rectangle. Rect may be created from outer bounds or from position, width, and height. Rect describes an area; if its right is less than or equal to its left, or if its bottom is less than or equal to its top, it is considered empty.

成员函数说明

◆ asScalars()

const float* MNN::CV::Rect::asScalars ( ) const
inline

Returns pointer to first scalar in Rect, to treat it as an array with four entries.

返回
pointer to fLeft

◆ bottom()

float MNN::CV::Rect::bottom ( ) const
inline

Returns bottom edge of Rect, if sorted. Call isEmpty() to see if Rect may be invalid, and sort() to reverse fTop and fBottom if needed.

返回
fBottom

◆ centerX()

float MNN::CV::Rect::centerX ( ) const
inline

Returns average of left edge and right edge. Result does not change if Rect is sorted. Result may overflow to infinity if Rect is far from the origin.

返回
midpoint in x

◆ centerY()

float MNN::CV::Rect::centerY ( ) const
inline

Returns average of top edge and bottom edge. Result does not change if Rect is sorted.

返回
midpoint in y

◆ contains()

bool MNN::CV::Rect::contains ( float  x,
float  y 
) const
inline

Returns true if: fLeft <= x < fRight && fTop <= y < fBottom. Returns false if Rect is empty.

参数
xtest Point x-coordinate
ytest Point y-coordinate
返回
true if (x, y) is inside Rect

◆ height()

float MNN::CV::Rect::height ( ) const
inline

Returns span on the y-axis. This does not check if Rect is sorted, or if result fits in 32-bit float; result may be negative or infinity.

返回
fBottom minus fTop

◆ inset()

void MNN::CV::Rect::inset ( float  dx,
float  dy 
)
inline

Insets Rect by (dx, dy).

If dx is positive, makes Rect narrower. If dx is negative, makes Rect wider. If dy is positive, makes Rect shorter. If dy is negative, makes Rect taller.

参数
dxadded to fLeft and subtracted from fRight
dyadded to fTop and subtracted from fBottom

◆ intersect() [1/3]

bool MNN::CV::Rect::intersect ( const Rect r)

Returns true if Rect intersects r, and sets Rect to intersection. Returns false if Rect does not intersect r, and leaves Rect unchanged.

Returns false if either r or Rect is empty, leaving Rect unchanged.

参数
rlimit of result
返回
true if r and Rect have area in common

◆ intersect() [2/3]

bool MNN::CV::Rect::intersect ( float  left,
float  top,
float  right,
float  bottom 
)

Constructs Rect to intersect from (left, top, right, bottom). Does not sort construction.

Returns true if Rect intersects construction, and sets Rect to intersection. Returns false if Rect does not intersect construction, and leaves Rect unchanged.

Returns false if either construction or Rect is empty, leaving Rect unchanged.

参数
leftx-axis minimum of constructed Rect
topy-axis minimum of constructed Rect
rightx-axis maximum of constructed Rect
bottomy-axis maximum of constructed Rect
返回
true if construction and Rect have area in common

◆ intersect() [3/3]

bool MNN::CV::Rect::intersect ( const Rect a,
const Rect b 
)

Returns true if a intersects b, and sets Rect to intersection. Returns false if a does not intersect b, and leaves Rect unchanged.

Returns false if either a or b is empty, leaving Rect unchanged.

参数
aRect to intersect
bRect to intersect
返回
true if a and b have area in common

◆ intersects() [1/2]

bool MNN::CV::Rect::intersects ( float  left,
float  top,
float  right,
float  bottom 
) const
inline

Constructs Rect to intersect from (left, top, right, bottom). Does not sort construction.

Returns true if Rect intersects construction. Returns false if either construction or Rect is empty, or do not intersect.

参数
leftx-axis minimum of constructed Rect
topy-axis minimum of constructed Rect
rightx-axis maximum of constructed Rect
bottomy-axis maximum of constructed Rect
返回
true if construction and Rect have area in common

◆ intersects() [2/2]

bool MNN::CV::Rect::intersects ( const Rect r) const
inline

Returns true if Rect intersects r. Returns false if either r or Rect is empty, or do not intersect.

参数
rRect to intersect
返回
true if r and Rect have area in common

◆ Intersects()

static bool MNN::CV::Rect::Intersects ( const Rect a,
const Rect b 
)
inlinestatic

Returns true if a intersects b. Returns false if either a or b is empty, or do not intersect.

参数
aRect to intersect
bRect to intersect
返回
true if a and b have area in common

◆ isEmpty()

bool MNN::CV::Rect::isEmpty ( ) const
inline

Returns true if fLeft is equal to or greater than fRight, or if fTop is equal to or greater than fBottom. Call sort() to reverse rectangles with negative width() or height().

返回
true if width() or height() are zero or negative

◆ iset()

void MNN::CV::Rect::iset ( int  left,
int  top,
int  right,
int  bottom 
)
inline

Sets Rect to (left, top, right, bottom). All parameters are promoted from integer to scalar. left and right are not sorted; left is not necessarily less than right. top and bottom are not sorted; top is not necessarily less than bottom.

参数
leftpromoted to float and stored in fLeft
toppromoted to float and stored in fTop
rightpromoted to float and stored in fRight
bottompromoted to float and stored in fBottom

◆ isetWH()

void MNN::CV::Rect::isetWH ( int  width,
int  height 
)
inline

Sets Rect to (0, 0, width, height). width and height may be zero or negative. width and height are promoted from integer to float, large values may lose precision.

参数
widthpromoted to float and stored in fRight
heightpromoted to float and stored in fBottom

◆ isSorted()

bool MNN::CV::Rect::isSorted ( ) const
inline

Returns true if fLeft is equal to or less than fRight, or if fTop is equal to or less than fBottom. Call sort() to reverse rectangles with negative width() or height().

返回
true if width() or height() are zero or positive

◆ join() [1/2]

void MNN::CV::Rect::join ( float  left,
float  top,
float  right,
float  bottom 
)

Constructs Rect to intersect from (left, top, right, bottom). Does not sort construction.

Sets Rect to the union of itself and the construction.

Has no effect if construction is empty. Otherwise, if Rect is empty, sets Rect to construction.

参数
leftx-axis minimum of constructed Rect
topy-axis minimum of constructed Rect
rightx-axis maximum of constructed Rect
bottomy-axis maximum of constructed Rect

◆ join() [2/2]

void MNN::CV::Rect::join ( const Rect r)
inline

Sets Rect to the union of itself and r.

Has no effect if r is empty. Otherwise, if Rect is empty, sets Rect to r.

参数
rexpansion Rect

◆ joinNonEmptyArg()

void MNN::CV::Rect::joinNonEmptyArg ( const Rect r)
inline

Sets Rect to the union of itself and r.

Asserts if r is empty and SK_DEBUG is defined. If Rect is empty, sets Rect to r.

May produce incorrect results if r is empty.

参数
rexpansion Rect

◆ joinPossiblyEmptyRect()

void MNN::CV::Rect::joinPossiblyEmptyRect ( const Rect r)
inline

Sets Rect to the union of itself and the construction.

May produce incorrect results if Rect or r is empty.

参数
rexpansion Rect

◆ left()

float MNN::CV::Rect::left ( ) const
inline

Returns left edge of Rect, if sorted. Call isSorted() to see if Rect is valid. Call sort() to reverse fLeft and fRight if needed.

返回
fLeft

◆ MakeEmpty()

static constexpr Rect MNN::CV::Rect::MakeEmpty ( )
inlinestatic

Returns constructed Rect set to (0, 0, 0, 0). Many other rectangles are empty; if left is equal to or greater than right, or if top is equal to or greater than bottom. Setting all members to zero is a convenience, but does not designate a special empty rectangle.

返回
bounds (0, 0, 0, 0)

◆ makeInset()

Rect MNN::CV::Rect::makeInset ( float  dx,
float  dy 
) const
inline

Returns Rect, inset by (dx, dy).

If dx is negative, Rect returned is wider. If dx is positive, Rect returned is narrower. If dy is negative, Rect returned is taller. If dy is positive, Rect returned is shorter.

参数
dxadded to fLeft and subtracted from fRight
dyadded to fTop and subtracted from fBottom
返回
Rect inset symmetrically left and right, top and bottom

◆ MakeIWH()

static Rect MNN::CV::Rect::MakeIWH ( int  w,
int  h 
)
inlinestatic

Returns constructed Rect set to integer values (0, 0, w, h). Does not validate input; w or h may be negative.

Use to avoid a compiler warning that input may lose precision when stored. Use SkIRect for an exact integer rectangle.

参数
winteger width of constructed Rect
hinteger height of constructed Rect
返回
bounds (0, 0, w, h)

◆ MakeLTRB()

static constexpr Rect MNN::CV::Rect::MakeLTRB ( float  l,
float  t,
float  r,
float  b 
)
inlinestatic

Returns constructed Rect set to (l, t, r, b). Does not sort input; Rect may result in fLeft greater than fRight, or fTop greater than fBottom.

参数
lfloat stored in fLeft
tfloat stored in fTop
rfloat stored in fRight
bfloat stored in fBottom
返回
bounds (l, t, r, b)

◆ makeOffset()

Rect MNN::CV::Rect::makeOffset ( float  dx,
float  dy 
) const
inline

Returns Rect offset by (dx, dy).

If dx is negative, Rect returned is moved to the left. If dx is positive, Rect returned is moved to the right. If dy is negative, Rect returned is moved upward. If dy is positive, Rect returned is moved downward.

参数
dxadded to fLeft and fRight
dyadded to fTop and fBottom
返回
Rect offset on axes, with original width and height

◆ makeOutset()

Rect MNN::CV::Rect::makeOutset ( float  dx,
float  dy 
) const
inline

Returns Rect, outset by (dx, dy).

If dx is negative, Rect returned is narrower. If dx is positive, Rect returned is wider. If dy is negative, Rect returned is shorter. If dy is positive, Rect returned is taller.

参数
dxsubtracted to fLeft and added from fRight
dysubtracted to fTop and added from fBottom
返回
Rect outset symmetrically left and right, top and bottom

◆ makeSorted()

Rect MNN::CV::Rect::makeSorted ( ) const
inline

Returns Rect with fLeft and fRight swapped if fLeft is greater than fRight; and with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty; and width() and height() will be zero or positive.

返回
sorted Rect

◆ MakeWH()

static constexpr Rect MNN::CV::Rect::MakeWH ( float  w,
float  h 
)
inlinestatic

Returns constructed Rect set to float values (0, 0, w, h). Does not validate input; w or h may be negative.

Passing integer values may generate a compiler warning since Rect cannot represent 32-bit integers exactly. Use SkIRect for an exact integer rectangle.

参数
wfloat width of constructed Rect
hfloat height of constructed Rect
返回
bounds (0, 0, w, h)

◆ MakeXYWH()

static constexpr Rect MNN::CV::Rect::MakeXYWH ( float  x,
float  y,
float  w,
float  h 
)
inlinestatic

Returns constructed Rect set to (x, y, x + w, y + h). Does not validate input; w or h may be negative.

参数
xstored in fLeft
ystored in fTop
wadded to x and stored in fRight
hadded to y and stored in fBottom
返回
bounds at (x, y) with width w and height h

◆ offset()

void MNN::CV::Rect::offset ( float  dx,
float  dy 
)
inline

Offsets Rect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom.

If dx is negative, moves Rect to the left. If dx is positive, moves Rect to the right. If dy is negative, moves Rect upward. If dy is positive, moves Rect downward.

参数
dxoffset added to fLeft and fRight
dyoffset added to fTop and fBottom

◆ offsetTo()

void MNN::CV::Rect::offsetTo ( float  newX,
float  newY 
)
inline

Offsets Rect so that fLeft equals newX, and fTop equals newY. width and height are unchanged.

参数
newXstored in fLeft, preserving width()
newYstored in fTop, preserving height()

◆ outset()

void MNN::CV::Rect::outset ( float  dx,
float  dy 
)
inline

Outsets Rect by (dx, dy).

If dx is positive, makes Rect wider. If dx is negative, makes Rect narrower. If dy is positive, makes Rect taller. If dy is negative, makes Rect shorter.

参数
dxsubtracted to fLeft and added from fRight
dysubtracted to fTop and added from fBottom

◆ right()

float MNN::CV::Rect::right ( ) const
inline

Returns right edge of Rect, if sorted. Call isSorted() to see if Rect is valid. Call sort() to reverse fLeft and fRight if needed.

返回
fRight

◆ set()

void MNN::CV::Rect::set ( float  left,
float  top,
float  right,
float  bottom 
)
inline

Sets Rect to (left, top, right, bottom). left and right are not sorted; left is not necessarily less than right. top and bottom are not sorted; top is not necessarily less than bottom.

参数
leftstored in fLeft
topstored in fTop
rightstored in fRight
bottomstored in fBottom

◆ setEmpty()

void MNN::CV::Rect::setEmpty ( )
inline

Sets Rect to (0, 0, 0, 0).

Many other rectangles are empty; if left is equal to or greater than right, or if top is equal to or greater than bottom. Setting all members to zero is a convenience, but does not designate a special empty rectangle.

◆ setLTRB()

void MNN::CV::Rect::setLTRB ( float  left,
float  top,
float  right,
float  bottom 
)
inline

Sets Rect to (left, top, right, bottom). left and right are not sorted; left is not necessarily less than right. top and bottom are not sorted; top is not necessarily less than bottom.

参数
leftstored in fLeft
topstored in fTop
rightstored in fRight
bottomstored in fBottom

◆ setWH()

void MNN::CV::Rect::setWH ( float  width,
float  height 
)
inline

Sets Rect to (0, 0, width, height). Does not validate input; width or height may be negative.

参数
widthstored in fRight
heightstored in fBottom

◆ setXYWH()

void MNN::CV::Rect::setXYWH ( float  x,
float  y,
float  width,
float  height 
)
inline

Sets Rect to (x, y, x + width, y + height). Does not validate input; width or height may be negative.

参数
xstored in fLeft
ystored in fTop
widthadded to x and stored in fRight
heightadded to y and stored in fBottom

◆ sort()

void MNN::CV::Rect::sort ( )
inline

Swaps fLeft and fRight if fLeft is greater than fRight; and swaps fTop and fBottom if fTop is greater than fBottom. Result may be empty; and width() and height() will be zero or positive.

◆ top()

float MNN::CV::Rect::top ( ) const
inline

Returns top edge of Rect, if sorted. Call isEmpty() to see if Rect may be invalid, and sort() to reverse fTop and fBottom if needed.

返回
fTop

◆ width()

float MNN::CV::Rect::width ( ) const
inline

Returns span on the x-axis. This does not check if Rect is sorted, or if result fits in 32-bit float; result may be negative or infinity.

返回
fRight minus fLeft

◆ x()

float MNN::CV::Rect::x ( ) const
inline

Returns left edge of Rect, if sorted. Call isSorted() to see if Rect is valid. Call sort() to reverse fLeft and fRight if needed.

返回
fLeft

◆ y()

float MNN::CV::Rect::y ( ) const
inline

Returns top edge of Rect, if sorted. Call isEmpty() to see if Rect may be invalid, and sort() to reverse fTop and fBottom if needed.

返回
fTop

类成员变量说明

◆ fBottom

float MNN::CV::Rect::fBottom

larger y-axis bounds

◆ fLeft

float MNN::CV::Rect::fLeft

smaller x-axis bounds

◆ fRight

float MNN::CV::Rect::fRight

larger x-axis bounds

◆ fTop

float MNN::CV::Rect::fTop

smaller y-axis bounds


该结构体的文档由以下文件生成: