CVB++ 14.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{
14CVB_BEGIN_INLINE_NS
15
17namespace SampleDatabase
18{
19
21
24{
25private:
26 // Internal helper constructor version
27 SampleListImageDataType (ReleaseObjectGuard&& guardSilDT)
28 : handle_(std::move(guardSilDT)),
29 imageDataType_(DataType::Int8BppUnsigned()) // Arbitrary default, overriden in "real" constructor
30 {}
31
32 // Helper to create the instance
33 static CExports::TSILDATATYPE CreateInternal (Size2D<int> imageSize, int imageDimension, DataType imageDataType, Point2D<int> featureWindowLoc, Size2D<int> featureWindowSize, Point2D<int> featureWindowOrigin)
34 {
35 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()));
36 if (sildt == nullptr)
37 {
38 Utilities::SystemInfo::ThrowLastError();
39 }
40 return sildt;
41 }
42
43public:
45
54 SampleListImageDataType (Size2D<int> imageSize, int imageDimension, DataType imageDataType, Point2D<int> featureWindowOrigin, Point2D<int> featureWindowLoc, Size2D<int> featureWindowSize)
55 : SampleListImageDataType (ReleaseObjectGuard(CreateInternal (imageSize, imageDimension, imageDataType, featureWindowLoc, featureWindowSize, featureWindowOrigin)))
56 {
57 imageSize_ = imageSize;
58 imageDimension_ = imageDimension;
59 imageDataType_ = imageDataType;
60 featureWindowSize_ = featureWindowSize;
61 featureWindowLocation_ = featureWindowLoc;
62 featureWindowOrigin_ = featureWindowOrigin;
63 }
64
66
73 SampleListImageDataType (Size2D<int> imageSize, int imageDimension, DataType imageDataType, Point2D<int> featureWindowOrigin)
74 : SampleListImageDataType (imageSize, imageDimension, imageDataType, featureWindowOrigin, Point2D<int>(0, 0), imageSize)
75 { }
76
77
79
80 SampleListImageDataType& operator=(SampleListImageDataType&&) noexcept = default;
81
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:73
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:54
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