iVS3D v2.0.0
Loading...
Searching...
No Matches
ROI Class Reference

The ROI class manages a region of interest represented as a rectangle in the [0,1]x[0,1] square. We refer to this as a normalized ROI. The ROI can be scaled to a given resolution (width x height), in this case we refert o it as a crop region. the crop region is only valid with the resolution it was scaled to because the resulting QRect or OpenCV rectangle is gicen as pixels in [0,width]x[0,height] scale. More...

#include <roi.h>

Public Member Functions

 ROI ()
 Default constructor initializing ROI to the full image (normalized [0,1] scale).
 
 ROI (const QRectF &roi)
 Constructs an ROI object from a QRectF.
 
 ROI (const cv::Rect2f &roi)
 Constructs an ROI object from an OpenCV Rect2f.
 
 ROI (const QRect &roi, const Resolution &resolution)
 Constructs an ROI object from a QRect in pixel coordinates and the corresponding reolution for normalization.
 
 ROI (const cv::Rect &roi, const Resolution &resolution)
 Constructs an ROI object from an OpenCV Rect in pixel coordinates and the corresponding reolution for normalization.
 
bool isDefault () const
 Checks if the ROI matches the default ROI which is the entire image.
 
QRect cropAsQRect (const Resolution &resolution) const
 Converts to a QRect, scaled to the given resolution.
 
cv::Rect cropAsCvRect (const Resolution &resolution) const
 Converts to an OpenCV rect, scaled to the given resolution.
 
void crop (const cv::Mat &src, cv::Mat &dest) const
 Crops an image using the ROI and stores the result in dest.
 
void crop (cv::Mat &img) const
 Crops an image in-place.
 

Detailed Description

The ROI class manages a region of interest represented as a rectangle in the [0,1]x[0,1] square. We refer to this as a normalized ROI. The ROI can be scaled to a given resolution (width x height), in this case we refert o it as a crop region. the crop region is only valid with the resolution it was scaled to because the resulting QRect or OpenCV rectangle is gicen as pixels in [0,width]x[0,height] scale.

Author
Dominik Wüst
Date
March 2025

Constructor & Destructor Documentation

◆ ROI() [1/4]

ROI::ROI ( const QRectF &  roi)
inline

Constructs an ROI object from a QRectF.

Parameters
roiThe QRectF defining the region in [0,1] scale.

◆ ROI() [2/4]

ROI::ROI ( const cv::Rect2f &  roi)
inline

Constructs an ROI object from an OpenCV Rect2f.

Parameters
roiThe OpenCV rectangle defining the region in [0,1] scale.

◆ ROI() [3/4]

ROI::ROI ( const QRect &  roi,
const Resolution resolution 
)

Constructs an ROI object from a QRect in pixel coordinates and the corresponding reolution for normalization.

Parameters
roiThe QRect defining the region in [0,width]x[0,height] scale.
resolutionThe Resolution (width x height) for normalizing the roi to [0,1] scale.

◆ ROI() [4/4]

ROI::ROI ( const cv::Rect &  roi,
const Resolution resolution 
)

Constructs an ROI object from an OpenCV Rect in pixel coordinates and the corresponding reolution for normalization.

Parameters
roiThe OpenCV rectangle defining the region in [0,width]x[0,height] scale.
resolutionThe Resolution (width x height) for normalizing the roi to [0,1] scale.

Member Function Documentation

◆ crop() [1/2]

void ROI::crop ( const cv::Mat &  src,
cv::Mat &  dest 
) const
inline

Crops an image using the ROI and stores the result in dest.

Parameters
srcInput image.
destOutput cropped image.

◆ crop() [2/2]

void ROI::crop ( cv::Mat &  img) const
inline

Crops an image in-place.

Parameters
imgImage to crop.

◆ cropAsCvRect()

cv::Rect ROI::cropAsCvRect ( const Resolution resolution) const
inline

Converts to an OpenCV rect, scaled to the given resolution.

Parameters
resolutionThe resolution (width x height) to scale the roi to.
Returns
The ROI as an OpenCV rectangle in [0,width]x[0,height] scale.

◆ cropAsQRect()

QRect ROI::cropAsQRect ( const Resolution resolution) const
inline

Converts to a QRect, scaled to the given resolution.

Parameters
resolutionThe resolution (width x height) to scale the roi to.
Returns
The ROI as a QRect in [0,width]x[0,height] scale.

◆ isDefault()

bool ROI::isDefault ( ) const
inline

Checks if the ROI matches the default ROI which is the entire image.

Returns
true if the ROI matches is the entire image.

The documentation for this class was generated from the following files: