42 drwnObject(
const cv::Rect& ext,
const char *n = NULL);
49 bool save(drwnXMLNode& xml)
const;
51 bool load(drwnXMLNode& xml);
54 bool hit(
double x,
double y)
const;
56 bool hit(
const cv::Point& pt)
const {
return hit(pt.x, pt.y); }
59 double area()
const {
return fabs((
double)(extent.width * extent.height)); }
61 double aspect()
const {
return (
double)extent.width / (double)extent.height; }
64 double overlap(
const cv::Rect& roi)
const;
70 const double ov = overlap(roi);
71 return (ov / (
area() + (roi.width * roi.height) - ov));
78 return (fabs(overlap(obj) -
area()) < DRWN_EPSILON);
82 void scale(
double x_scale,
double y_scale) {
83 extent.x = (int)(x_scale * extent.x);
84 extent.y = (int)(y_scale * extent.y);
85 extent.width = (int)(x_scale * extent.width);
86 extent.height = (int)(y_scale * extent.height);
93 bool operator!=(
const drwnObject& obj)
const {
return !(*
this == obj); }
107 const char *
type()
const {
return "drwnObjectList"; }
108 bool save(drwnXMLNode& xml)
const;
109 bool load(drwnXMLNode& xml);
116 int removeNonMatching(
const string& name);
118 int removeMatching(
const string& name);
120 int nonMaximalSuppression(
double threshold = 0.5,
bool bByName =
true);
122 int keepHighestScoring(
int nKeep);
124 int keepAboveScore(
double threshold);
138 const char *
type()
const {
return "drwnObjectSequence"; }
139 bool save(drwnXMLNode& xml)
const;
140 bool load(drwnXMLNode& xml);
double areaOverlap(const drwnObject &obj) const
return the area of intersection divided by the area of union
Definition: drwnObject.h:74
interface for objects that can serialize and de-serialize themselves
Definition: drwnInterfaces.h:48
List of objects for the same image (see drwnObject)
Definition: drwnObject.h:101
cv::Rect extent
object bounding box (in pixels)
Definition: drwnObject.h:34
double area(const cv::Rect &r)
area defined by the rectangle
Definition: drwnOpenCVUtils.h:76
double areaOverlap(const cv::Rect &roi) const
return the area of intersection divided by the area of union
Definition: drwnObject.h:69
void scale(double sc)
scale the object bounding box
Definition: drwnObject.h:89
bool inside(const drwnObject &obj) const
return true if obj is within the object
Definition: drwnObject.h:77
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnObject.h:138
double score
score (probability) for the object (higher is better)
Definition: drwnObject.h:35
bool operator<(const CvSize &r, const CvSize &s)
inequality operator for CvSize objects (allows partial sorting)
Definition: drwnOpenCVUtils.cpp:88
double overlap(const drwnObject &obj) const
return the number of pixels that overlap between two objects
Definition: drwnObject.h:66
double aspect() const
return the aspect ratio (width/height) of the object
Definition: drwnObject.h:61
double area() const
return the area of the object
Definition: drwnObject.h:59
int ref
external reference
Definition: drwnObject.h:36
void scale(double x_scale, double y_scale)
scale the object bounding box
Definition: drwnObject.h:82
Encapsulates a 2D object in an image for object detection.
Definition: drwnObject.h:31
Sequence of images, each with a list of objects (see drwnObjectList)
Definition: drwnObject.h:132
string name
name of the object category, e.g., "car"
Definition: drwnObject.h:33
bool hit(const cv::Point &pt) const
return true if the point pt is within the object
Definition: drwnObject.h:56
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnObject.h:107
bool operator==(const CvRect &r, const CvRect &s)
equality operator for CvRect objects
Definition: drwnOpenCVUtils.cpp:83