CVB++ 14.1
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{
14CVB_BEGIN_INLINE_NS
15
17namespace SampleDatabase
18{
19
21
24{
25private:
26 // Internal helper constructor version
27 explicit SampleListImageDataType (ReleaseObjectGuard&& guardSilDT)
28 : handle_(std::move(guardSilDT))
29 , imageDataType_(DataType::Int8BppUnsigned()) // Arbitrary default, overriden in "real" constructor
30 , imageDimension_(0) // Arbitrary default, overriden in "real" constructor
31 {}
32
33 // Helper to create the instance
34 static CExports::TSILDATATYPE CreateInternal (Size2D<int> imageSize, int imageDimension, DataType imageDataType, Point2D<int> featureWindowLoc, Size2D<int> featureWindowSize, Point2D<int> featureWindowOrigin)
35 {
36 CExports::TSILDATATYPE sildt = CVB_CALL_CAPI (SilCreateDataTypeImage(imageSize.Width(), imageSize.Height(), imageDimension, imageDataType.NativeDescriptor(), featureWindowLoc.X(), featureWindowLoc.Y(), featureWindowSize.Width(), featureWindowSize.Height(), featureWindowOrigin.X(), featureWindowOrigin.Y()));
37 if (sildt == nullptr)
38 {
39 Utilities::SystemInfo::ThrowLastError();
40 }
41 return sildt;
42 }
43
44public:
46
55 SampleListImageDataType (Size2D<int> imageSize, int imageDimension, DataType imageDataType, Point2D<int> featureWindowOrigin, Point2D<int> featureWindowLoc, Size2D<int> featureWindowSize)
56 : SampleListImageDataType (ReleaseObjectGuard(CreateInternal (imageSize, imageDimension, imageDataType, featureWindowLoc, featureWindowSize, featureWindowOrigin)))
57 {
58 imageSize_ = imageSize; // NOLINT(cppcoreguidelines-prefer-member-initializer)
59 imageDimension_ = imageDimension; // NOLINT(cppcoreguidelines-prefer-member-initializer)
60 imageDataType_ = imageDataType; // NOLINT(cppcoreguidelines-prefer-member-initializer)
61 featureWindowSize_ = featureWindowSize; // NOLINT(cppcoreguidelines-prefer-member-initializer)
62 featureWindowLocation_ = featureWindowLoc; // NOLINT(cppcoreguidelines-prefer-member-initializer)
63 featureWindowOrigin_ = featureWindowOrigin; // NOLINT(cppcoreguidelines-prefer-member-initializer)
64 }
65
67
74 SampleListImageDataType (Size2D<int> imageSize, int imageDimension, DataType imageDataType, Point2D<int> featureWindowOrigin)
75 : SampleListImageDataType (imageSize, imageDimension, imageDataType, featureWindowOrigin, Point2D<int>(0, 0), imageSize)
76 { }
77
79 SampleListImageDataType& operator=(const SampleListImageDataType & other) = delete;
80 SampleListImageDataType (SampleListImageDataType&& other ) noexcept = default;
81 SampleListImageDataType& operator=(SampleListImageDataType&& other) noexcept = default;
82 virtual ~SampleListImageDataType () {};
83
84public:
86
92 void * Handle() const noexcept
93 {
94 return handle_.Handle();
95 }
96
97#if 0
99
106 static std::unique_ptr<SampleListImageDataType> FromHandle (HandleGuard<SampleListImageDataType>&& guard)
107 {
108 if (!guard.Handle ())
109 {
110 throw std::invalid_argument ("invalid sample list image data type native handle");
111 }
112 return std::unique_ptr<SampleListImageDataType>(new SampleListImageDataType(std::move(guard)));
113 }
114#endif
115
117
121 Size2D<int> ImageSize() const noexcept
122 {
123 return imageSize_;
124 }
125
127
131 int ImageDimension() const noexcept
132 {
133 return imageDimension_;
134 }
135
137
141 DataType ImageDataType() const noexcept
142 {
143 return imageDataType_;
144 }
145
147
152 {
153 return featureWindowSize_;
154 }
155
157
162 {
163 return featureWindowLocation_;
164 }
165
167
172 {
173 return featureWindowOrigin_;
174 }
175
176private:
177 ReleaseObjectGuard handle_;
178 Size2D<int> imageSize_;
179 int imageDimension_;
180 DataType imageDataType_;
181 Point2D<int> featureWindowLocation_;
182 Size2D<int> featureWindowSize_;
183 Point2D<int> featureWindowOrigin_;
184};
185
188
189
190} /* namespace SampleDatabase */
191CVB_END_INLINE_NS
192} /* namespace Cvb */
Data type description for an image plane.
Definition: data_type.hpp:28
int NativeDescriptor() const noexcept
Native data type descriptor.
Definition: data_type.hpp:322
static DataType Int8BppUnsigned() noexcept
Represents 8-bit unsigned integer pixels (bytes).
Definition: data_type.hpp:47
T X() const noexcept
Gets the x-component of the point.
Definition: point_2d.hpp:86
T Y() const noexcept
Gets the y-component of the point.
Definition: point_2d.hpp:106
Descriptor for image data to be digested by an image list.
Definition: sample_list_image_data_type.hpp:24
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:74
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:55
DataType ImageDataType() const noexcept
Data type of the images to be added to the image list.
Definition: sample_list_image_data_type.hpp:141
Size2D< int > FeatureWindowSize() const noexcept
Size of the feature window.
Definition: sample_list_image_data_type.hpp:151
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:161
Size2D< int > ImageSize() const noexcept
Size of the images to be added to the image list.
Definition: sample_list_image_data_type.hpp:121
int ImageDimension() const noexcept
Dimension of the images to be added to the image list.
Definition: sample_list_image_data_type.hpp:131
void * Handle() const noexcept
Classic API SIL handle.
Definition: sample_list_image_data_type.hpp:92
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:171
T Height() const noexcept
Gets the vertical component of the size.
Definition: size_2d.hpp:79
T Width() const noexcept
Gets the horizontal component of the size.
Definition: size_2d.hpp:59
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24