CVB++ 15.0
sample_list_image_data_type.hpp
1#pragma once
2
3#include "../_cexports/c_sample_database.h"
4
5#include "../global.hpp"
6#include "../size_2d.hpp"
7#include "../point_2d.hpp"
8#include "../data_type.hpp"
9
10#include <memory>
11
12namespace Cvb
13{
14 CVB_BEGIN_INLINE_NS
15
17 namespace SampleDatabase
18 {
19
21
24 class SampleListImageDataType
25 {
26 private:
27 // Internal helper constructor version
28 explicit SampleListImageDataType(ReleaseObjectGuard &&guardSilDT)
29 : handle_(std::move(guardSilDT))
30 , imageDataType_(DataType::Int8BppUnsigned()) // Arbitrary default, overriden in "real" constructor
31 , imageDimension_(0) // Arbitrary default, overriden in "real" constructor
32 {
33 }
34
35 // Helper to create the instance
36 static CExports::TSILDATATYPE CreateInternal(Size2D<int> imageSize, int imageDimension, DataType imageDataType,
37 Point2D<int> featureWindowLoc, Size2D<int> featureWindowSize,
38 Point2D<int> featureWindowOrigin)
39 {
40 CExports::TSILDATATYPE sildt = CVB_CALL_CAPI(SilCreateDataTypeImage(
41 imageSize.Width(), imageSize.Height(), imageDimension, imageDataType.NativeDescriptor(),
42 featureWindowLoc.X(), featureWindowLoc.Y(), featureWindowSize.Width(), featureWindowSize.Height(),
43 featureWindowOrigin.X(), featureWindowOrigin.Y()));
44 if (sildt == nullptr)
45 {
46 Utilities::SystemInfo::ThrowLastError();
47 }
48 return sildt;
49 }
50
51 public:
53
62 SampleListImageDataType(Size2D<int> imageSize, int imageDimension, DataType imageDataType,
63 Point2D<int> featureWindowOrigin, Point2D<int> featureWindowLoc,
64 Size2D<int> featureWindowSize)
65 : SampleListImageDataType(ReleaseObjectGuard(CreateInternal(
66 imageSize, imageDimension, imageDataType, featureWindowLoc, featureWindowSize, featureWindowOrigin)))
67 {
68 imageSize_ = imageSize; // NOLINT(cppcoreguidelines-prefer-member-initializer)
69 imageDimension_ = imageDimension; // NOLINT(cppcoreguidelines-prefer-member-initializer)
70 imageDataType_ = imageDataType; // NOLINT(cppcoreguidelines-prefer-member-initializer)
71 featureWindowSize_ = featureWindowSize; // NOLINT(cppcoreguidelines-prefer-member-initializer)
72 featureWindowLocation_ = featureWindowLoc; // NOLINT(cppcoreguidelines-prefer-member-initializer)
73 featureWindowOrigin_ = featureWindowOrigin; // NOLINT(cppcoreguidelines-prefer-member-initializer)
74 }
75
77
84 SampleListImageDataType(Size2D<int> imageSize, int imageDimension, DataType imageDataType,
85 Point2D<int> featureWindowOrigin)
86 : SampleListImageDataType(imageSize, imageDimension, imageDataType, featureWindowOrigin, Point2D<int>(0, 0),
87 imageSize)
88 {
89 }
90
92 SampleListImageDataType &operator=(const SampleListImageDataType &other) = delete;
93 SampleListImageDataType(SampleListImageDataType &&other) noexcept = default;
94 SampleListImageDataType &operator=(SampleListImageDataType &&other) noexcept = default;
95 virtual ~SampleListImageDataType() {};
96
97 public:
99
105 void *Handle() const noexcept
106 {
107 return handle_.Handle();
108 }
109
110#if 0
112
119 static std::unique_ptr<SampleListImageDataType> FromHandle (HandleGuard<SampleListImageDataType>&& guard)
120 {
121 if (!guard.Handle ())
122 {
123 throw std::invalid_argument ("invalid sample list image data type native handle");
124 }
125 return std::unique_ptr<SampleListImageDataType>(new SampleListImageDataType(std::move(guard)));
126 }
127#endif
128
130
134 Size2D<int> ImageSize() const noexcept
135 {
136 return imageSize_;
137 }
138
140
144 int ImageDimension() const noexcept
145 {
146 return imageDimension_;
147 }
148
150
154 DataType ImageDataType() const noexcept
155 {
156 return imageDataType_;
157 }
158
160
165 {
166 return featureWindowSize_;
167 }
168
170
175 {
176 return featureWindowLocation_;
177 }
178
181
186 {
187 return featureWindowOrigin_;
188 }
189
190 private:
191 ReleaseObjectGuard handle_;
192 Size2D<int> imageSize_;
193 int imageDimension_;
194 DataType imageDataType_;
195 Point2D<int> featureWindowLocation_;
196 Size2D<int> featureWindowSize_;
197 Point2D<int> featureWindowOrigin_;
198 };
199
202
203 } /* namespace SampleDatabase */
204 CVB_END_INLINE_NS
205} /* namespace Cvb */
Data type description for an image plane.
Definition data_type.hpp:23
int NativeDescriptor() const noexcept
Native data type descriptor.
Definition data_type.hpp:312
static DataType Int8BppUnsigned() noexcept
Represents 8-bit unsigned integer pixels (bytes).
Definition data_type.hpp:41
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
T X() const noexcept
Gets the x-component of the point.
Definition point_2d.hpp:84
T Y() const noexcept
Gets the y-component of the point.
Definition point_2d.hpp:104
Descriptor for image data to be digested by an image list.
Definition sample_list_image_data_type.hpp:25
SampleListImageDataType(Size2D< int > imageSize, int imageDimension, DataType imageDataType, Point2D< int > featureWindowOrigin)
Construct an image list data type descriptor for image lists that digest images.
Definition sample_list_image_data_type.hpp:84
SampleListImageDataType(Size2D< int > imageSize, int imageDimension, DataType imageDataType, Point2D< int > featureWindowOrigin, Point2D< int > featureWindowLoc, Size2D< int > featureWindowSize)
Construct an image list data type descriptor for image lists that digest images.
Definition sample_list_image_data_type.hpp:62
DataType ImageDataType() const noexcept
Data type of the images to be added to the image list.
Definition sample_list_image_data_type.hpp:154
Size2D< int > FeatureWindowSize() const noexcept
Size of the feature window.
Definition sample_list_image_data_type.hpp:164
Point2D< int > FeatureWindowLocation() const noexcept
Location of the feature window (position of left top corner inside the image).
Definition sample_list_image_data_type.hpp:174
Size2D< int > ImageSize() const noexcept
Size of the images to be added to the image list.
Definition sample_list_image_data_type.hpp:134
int ImageDimension() const noexcept
Dimension of the images to be added to the image list.
Definition sample_list_image_data_type.hpp:144
void * Handle() const noexcept
Classic API SIL handle.
Definition sample_list_image_data_type.hpp:105
Point2D< int > FeatureWindowOrigin() const noexcept
Location of the feature window origin in pixel coordinates measured from the left top corner of the f...
Definition sample_list_image_data_type.hpp:185
Stores a pair of numbers that represents the width and the height of a subject, typically a rectangle...
Definition size_2d.hpp:20
T Height() const noexcept
Gets the vertical component of the size.
Definition size_2d.hpp:77
T Width() const noexcept
Gets the horizontal component of the size.
Definition size_2d.hpp:57
T move(T... args)
Namespace for the SampleDatabase package.
Definition decl_classification_sil.hpp:20
std::shared_ptr< SampleListImageDataType > SampleListImageDataTypePtr
Convenience shared pointer for SampleListImageDataType.
Definition sample_list_image_data_type.hpp:201
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17