"vscode:/vscode.git/clone" did not exist on "49e0a6d6ff1f15a14bee0def0bcdfaca30e55380"
full_object_detection_abstract.h 4.26 KB
Newer Older
1
// Copyright (C) 2012  Davis E. King (davis@dlib.net)
2
// License: Boost Software License   See LICENSE.txt for the full license.
3
4
#undef DLIB_FULL_OBJECT_DeTECTION_ABSTRACT_Hh_
#ifdef DLIB_FULL_OBJECT_DeTECTION_ABSTRACT_Hh_
5
6
7

#include <vector>
#include "../geometry.h"
8
#include "../serialize.h"
9
10
11
12
13
14

namespace dlib
{

// ----------------------------------------------------------------------------------------

15
16
    const static point OBJECT_PART_NOT_PRESENT(0x7FFFFFFF,
                                               0x7FFFFFFF);
17
18
19

// ----------------------------------------------------------------------------------------

20
    class full_object_detection
21
    {
22
23
24
25
26
27
28
29
        /*!
            WHAT THIS OBJECT REPRESENTS
                This object represents the location of an object in an image along with the
                positions of each of its constituent parts.
        !*/

    public:

30
        full_object_detection(
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
            const rectangle& rect,
            const std::vector<point>& parts
        );
        /*!
            ensures
                - #get_rect() == rect
                - #num_parts() == parts.size()
                - for all valid i:
                    - part(i) == parts[i]
        !*/

        full_object_detection(
        );
        /*!
            ensures
                - #get_rect().is_empty() == true
                - #num_parts() == 0
        !*/
49

50
        explicit full_object_detection(
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
            const rectangle& rect
        );
        /*!
            ensures
                - #get_rect() == rect
                - #num_parts() == 0
        !*/

        const rectangle& get_rect(
        ) const;
        /*!
            ensures
                - returns the rectangle that indicates where this object is.  In general,
                  this should be the bounding box for the object.
        !*/
66

67
68
69
70
71
72
73
74
        rectangle& get_rect(
        ); 
        /*!
            ensures
                - returns the rectangle that indicates where this object is.  In general,
                  this should be the bounding box for the object.
        !*/

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
        unsigned long num_parts(
        ) const;
        /*!
            ensures
                - returns the number of parts in this object.  
        !*/

        const point& part(
            unsigned long idx
        ) const; 
        /*!
            requires
                - idx < num_parts()
            ensures
                - returns the location of the center of the idx-th part of this object.
                  Note that it is valid for a part to be "not present".  This is indicated
                  when the return value of part() is equal to OBJECT_PART_NOT_PRESENT. 
                  This is useful for modeling object parts that are not always observed.
        !*/
94
95
96
97
98
99
100
101
102
103
104
105
106

        point& part(
            unsigned long idx
        ); 
        /*!
            requires
                - idx < num_parts()
            ensures
                - returns the location of the center of the idx-th part of this object.
                  Note that it is valid for a part to be "not present".  This is indicated
                  when the return value of part() is equal to OBJECT_PART_NOT_PRESENT. 
                  This is useful for modeling object parts that are not always observed.
        !*/
107
108
    };

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// ----------------------------------------------------------------------------------------

    void serialize (
        const full_object_detection& item, 
        std::ostream& out
    );   
    /*!
        provides serialization support 
    !*/

    void deserialize (
        full_object_detection& item, 
        std::istream& in
    );   
    /*!
        provides deserialization support 
    !*/

127
128
129
130
131
132
133
134
135
136
// ----------------------------------------------------------------------------------------

    bool all_parts_in_rect (
        const full_object_detection& obj
    );
    /*!
        ensures
            - returns true if all the parts in obj are contained within obj.get_rect().
              That is, returns true if and only if, for all valid i, the following is
              always true:
Davis King's avatar
Davis King committed
137
                obj.get_rect().contains(obj.part(i)) == true || obj.part(i) == OBJECT_PART_NOT_PRESENT
138
139
    !*/

140
141
142
143
// ----------------------------------------------------------------------------------------

}

144
#endif // DLIB_FULL_OBJECT_DeTECTION_ABSTRACT_Hh_
145
146