30 #ifndef KJB_AA_RECTANGLE_2D_H
31 #define KJB_AA_RECTANGLE_2D_H
42 class Base_gl_interface;
65 m_center(0.5 * (p1 + p2)),
66 m_width(fabs(p1[0] - p2[0])),
67 m_height(fabs(p1[1] - p2[1]))
97 double get_left()
const {
return m_center[0] - m_width / 2.0; }
98 double get_right()
const {
return m_center[0] + m_width / 2.0; }
99 double get_bottom()
const {
return m_center[1] - m_height / 2.0; }
100 double get_top()
const {
return m_center[1] + m_height/ 2.0; }
140 assert(pt.
size() == 2);
159 void draw(
kjb::Image & img,
double ir = 255,
double ig = 0,
double ib = 0,
double iwidth = 1.0)
const;
169 swap(m_center, r.m_center);
170 swap(m_width, r.m_width);
171 swap(m_height, r.m_height);
187 m_center(
Vector().set(center_x, center_y)),
213 return m_width*m_height;
225 m_center(0) = center_x;
231 m_center(1) = center_y;
244 std::ostream&
operator<<(std::ostream& ost,
const Axis_aligned_rectangle_2d& box);
246 std::istream&
operator>>(std::istream& ist, Axis_aligned_rectangle_2d& box);
280 Axis_aligned_rectangle_2d& bb,
281 const std::vector<Vector>&
points,
282 const Base_gl_interface& camera,
296 template<
class Iterator>
double get_width() const
returns the width of this bounding box
Definition: gr_2D_bounding_box.h:86
const Vector & get_centre() const
returns the center of this Axis_aligned_rectangle_2d
Definition: gr_2D_bounding_box.h:193
size_type size() const
Alias to get_length(). Required to comply with stl Container concept.
Definition: m_vector.h:510
Class that represents an axis-aligned 2D rectangle. It is defined in terms of its (2D) center...
Definition: gr_2D_bounding_box.h:51
void translate(kjb::Axis_aligned_rectangle_2d &box, const kjb::Vector &t)
Definition: gr_2D_bounding_box.h:258
bool contains(const kjb::Vector &pt) const
Definition: gr_2D_bounding_box.h:138
Axis_aligned_rectangle_2d(const Vector &p1, const Vector &p2)
Constructs a Axis_aligned_rectangle_2d.
Definition: gr_2D_bounding_box.h:64
double get_centre_x() const
returns the x-coordinate of the center of this Axis_aligned_rectangle_2d
Definition: gr_2D_bounding_box.h:199
void set_centre_y(double center_y)
sets the y-coordinate of the center of this bounding box
Definition: gr_2D_bounding_box.h:229
Axis_aligned_rectangle_2d Bounding_Box2D
Definition: gr_2D_bounding_box.h:248
void set_centre(const Vector &icenter)
sets the center of this bounding box
Definition: gr_2D_bounding_box.h:217
Predicate that compares the kth element of a indexable type.
Definition: l_functors.h:94
double get_height() const
returns the height of this bounding box
Definition: gr_2D_bounding_box.h:92
double get_bottom() const
Definition: gr_2D_bounding_box.h:99
double get_area() const
returns the area of the box
Definition: gr_2D_bounding_box.h:211
double get_right() const
Definition: gr_2D_bounding_box.h:98
void swap(Perspective_camera &cam1, Perspective_camera &cam2)
Swap two cameras.
Definition: perspective_camera.h:599
height
Definition: APPgetLargeConnectedEdges.m:33
r
Definition: APPgetLargeConnectedEdges.m:127
friend std::istream & operator>>(std::istream &ist, Axis_aligned_rectangle_2d &box)
Definition: gr_2D_bounding_box.cpp:249
Vector get_top_center() const
Definition: gr_2D_bounding_box.h:104
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
void draw(kjb::Image &img, double ir=255, double ig=0, double ib=0, double iwidth=1.0) const
Definition: gr_2D_bounding_box.cpp:57
Bounding_Box2D intersect(const Bounding_Box2D &b1, const Bounding_Box2D &b2)
Definition: gr_2D_bounding_box.cpp:263
std::istream & operator>>(std::istream &ist, Detection_type &type)
Stream in an detection.
Definition: d_type.cpp:91
void set_height(double height)
sets the height of this bounding box
Definition: gr_2D_bounding_box.h:121
bool intersects(const Self &other) const
Definition: gr_2D_bounding_box.h:146
const Vector & get_center() const
returns the center of this Axis_aligned_rectangle_2d
Definition: gr_2D_bounding_box.h:80
Axis_aligned_rectangle_2d * clone() const
Clones this Axis_aligned_rectangle_2d.
Definition: gr_2D_bounding_box.h:71
void wire_render() const
Definition: gr_2D_bounding_box.cpp:37
void set_centre_x(double center_x)
sets the x-coordinate of the center of this bounding box
Definition: gr_2D_bounding_box.h:223
std::ofstream & operator<<(std::ofstream &out, const Quaternion &q)
Definition: turntable_camera.cpp:77
void swap(kjb::Gsl_Multimin_fdf &m1, kjb::Gsl_Multimin_fdf &m2)
Swap two wrapped multimin objects.
Definition: gsl_multimin.h:693
double get_left() const
Definition: gr_2D_bounding_box.h:97
Vector get_bottom_right() const
Definition: gr_2D_bounding_box.h:103
void write_corners_on(std::ostream &ofs)
Definition: gr_2D_bounding_box.cpp:103
double get_top() const
Definition: gr_2D_bounding_box.h:100
void set_width(double width)
sets the width of this bounding box
Definition: gr_2D_bounding_box.h:115
Axis_aligned_rectangle_2d compute_bounding_box(Iterator first, Iterator last)
Computes the 2D bounding box of a range of 2D points.
Definition: gr_2D_bounding_box.h:298
Vector get_top_left() const
Definition: gr_2D_bounding_box.h:102
~Axis_aligned_rectangle_2d()
Deletes this Axis_aligned_rectangle_2d.
Definition: gr_2D_bounding_box.h:77
double get_centre_y() const
returns the y-coordinate of the center of this Axis_aligned_rectangle_2d
Definition: gr_2D_bounding_box.h:205
double get_rectangle_intersection(const kjb::Bounding_Box2D &b1, const kjb::Bounding_Box2D &b2)
Compute area of intersection of two rectangles.
Definition: gr_2D_bounding_box.cpp:282
friend std::ostream & operator<<(std::ostream &ost, const Axis_aligned_rectangle_2d &box)
Definition: gr_2D_bounding_box.cpp:232
Wrapped version of the C struct KJB_image.
Definition: i_image.h:76
Axis_aligned_rectangle_2d(double center_x, double center_y, double iwidth, double iheight)
Constructs a Axis_aligned_rectangle_2d.
Definition: gr_2D_bounding_box.h:186
void swap(Axis_aligned_rectangle_2d &r)
Swaps this rectangle with another.
Definition: gr_2D_bounding_box.h:166
void scale(kjb::Axis_aligned_rectangle_2d &box, const kjb::Vector &s)
Definition: gr_2D_bounding_box.cpp:108
struct memorypool points
Definition: triangle.c:637
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
void get_projected_bbox_from_3Dpoints(Bounding_Box2D &bb, const std::vector< Vector > &points, const Base_gl_interface &camera, double img_width, double img_height)
Projects a set of 3D points onto the image plane, and finds a bounding box (aligned with the image ax...
Definition: gr_2D_bounding_box.cpp:138
Vector get_bottom_center() const
Definition: gr_2D_bounding_box.h:105
void set_center(const Vector ¢er)
sets the center of this bounding box
Definition: gr_2D_bounding_box.h:109
Axis_aligned_rectangle_2d(const Vector ¢er=Vector(2, 0.0), double width=1.0, double height=1.0)
Constructs a Axis_aligned_rectangle_2d.
Definition: gr_2D_bounding_box.h:57