Initialize Tizen 2.3
[framework/osp/vision.git] / src / FUixVision_ImageObjectImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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 #include "FUixVision_ImageObjectImpl.h"
19
20 namespace Tizen { namespace Uix { namespace Vision
21 {
22
23 _ImageObjectImpl::_ImageObjectImpl(void)
24     : __pRectangleList(0)
25     , __pMatrix(0)
26 {
27     __pRectangleList = new Tizen::Base::Collection::ArrayListT<Tizen::Graphics::FloatPoint>();
28     __pMatrix = new Tizen::Graphics::FloatMatrix4();
29 }
30
31 _ImageObjectImpl::~_ImageObjectImpl(void)
32 {
33     delete __pRectangleList;
34     delete __pMatrix;
35 }
36
37 int
38 _ImageObjectImpl::GetId(void) const
39 {
40     return __ImageRecognitionInfo.index();
41 }
42
43 int
44 _ImageObjectImpl::GetFeatureId(void) const
45 {
46     return __ImageRecognitionInfo.typeId();
47 }
48
49 const Tizen::Graphics::FloatMatrix4*
50 _ImageObjectImpl::GetTransformMatrix(void) const
51 {
52     memcpy(__pMatrix->matrix, __ImageRecognitionInfo.transform(), 16 * sizeof(float));
53     return __pMatrix;
54 }
55
56 float
57 _ImageObjectImpl::GetAspect(void) const
58 {
59     return __ImageRecognitionInfo.aspect();
60 }
61
62 void
63 _ImageObjectImpl::SetSariPointer(const sari2::ImageRecognitionInfo& sari)
64 {
65     __ImageRecognitionInfo = sari;
66 }
67
68 const Tizen::Base::Collection::ArrayListT<Tizen::Graphics::FloatPoint>*
69 _ImageObjectImpl::GetRectangle(void) const
70 {
71     __pRectangleList->RemoveAll();
72     static float coordinates[8] = {0.f};
73     __ImageRecognitionInfo.rectangle(coordinates);
74
75     for (int i = 0; i < 4; ++i)
76         __pRectangleList->Add(Tizen::Graphics::FloatPoint(coordinates[2 * i], coordinates[(2 * i) + 1]));
77
78     return __pRectangleList;
79 }
80
81 _ImageObjectImpl*
82 _ImageObjectImpl::GetInstance(ImageObject* pImageObject)
83 {
84     return pImageObject->__pImageObjectImpl;
85 }
86
87 const _ImageObjectImpl*
88 _ImageObjectImpl::GetInstance(const ImageObject* pImageObject)
89 {
90     return pImageObject->__pImageObjectImpl;
91 }
92
93 void
94 _ImageObjectImpl::ReleaseImageObject(ImageObject* pImageObject)
95 {
96     delete pImageObject;
97 }
98
99 void
100 _ImageObjectImpl::ReleaseImageObjectArray(ImageObject* pImageObject)
101 {
102     delete[] pImageObject;
103 }
104
105 ImageObject*
106 _ImageObjectImpl::CreateImageObjectStorageN(const unsigned int size)
107 {
108     ImageObject* objectStorage = new ImageObject[size];
109     return objectStorage;
110 }
111
112 ImageObject*
113 _ImageObjectImpl::CreateImageObjectN()
114 {
115         ImageObject* object = new ImageObject;
116     return object;
117 }
118
119 } } } //Tizen::Uix::Vision