flora site modification
[platform/framework/native/vision.git] / src / ImageRecognitionInfo.h
1 //
2 // Tizen C++ SDK
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #ifndef IMAGERECOGNITIONINFO_H_
19 #define IMAGERECOGNITIONINFO_H_
20
21 namespace sari2
22 {
23 class ImageFeatureManager;
24 class Database;
25
26 /// Holds all required information about one object on scene.
27 class ImageRecognitionInfo
28 {
29     friend class ImageRecognizer;
30
31 public:
32     /// \brief Default constructor.
33     ImageRecognitionInfo(void);
34
35     /// \brief Constructor.
36     ///
37     /// Gives information about image of specified object from database,
38     /// without providing tracking information.
39     /// \param[in] ifm ImageFeatureManager instance (holds image database).
40     /// \param[in] index ID of object in database.
41     ImageRecognitionInfo(const ImageFeatureManager* ifm, int index);
42
43     ImageRecognitionInfo(const ImageRecognitionInfo&);
44     ~ImageRecognitionInfo(void) {}
45     ImageRecognitionInfo& operator=(const ImageRecognitionInfo&);
46
47     /// \return Unique ID of object on scene.
48     inline int index(void) const { return mIndex; }
49     /// \return ID of object type.
50     inline int typeId(void) const { return mTypeId; }
51     /// \return OpenGL transformation matrix for object position.
52     inline const float* transform(void) const { return mTransform; }
53
54     inline const float aspect(void) const { int w = imageWidth(); return w > 0 ? imageHeight() / (float) w : 0.f; }
55
56     /// \brief Width of image of corresponding object from the database.
57     /// \return Image width.
58     int imageWidth(void) const;
59
60     /// \brief Height of image of corresponding object from the database.
61     /// \return Image height.
62     int imageHeight(void) const;
63
64     /// \brief Calculates homogeneous coordinates of reference image rectangle
65     /// verteces projections on current view.
66     /// \param[out] coordinates Buffer of size 8 to store calculation result as
67     /// follows: {x1, y1, x2, y2, x3, y3, x4, y4}.
68     /// \return 'true' on success.
69     bool rectangle(float *coordinates) const;
70
71 private:
72     int mIndex; ///< Unique ID of object on scene.
73     int mTypeId; ///< ID of object type.
74     float mTransform[16]; ///< OpenGL transformation matrix for object position.
75     const Database*      mDatabase;
76 };
77
78 }
79
80 #endif // IMAGERECOGNITIONINFO_H_