CVB++ 15.0
detail_image_rect.hpp
1#pragma once
2
3#include "../../global.hpp"
4
5#include "../_decl/decl_image_rect.hpp"
6
7#include "../../_decl/decl_device.hpp"
8#include "../../utilities/system_info.hpp"
9
10namespace Cvb
11{
12
13 CVB_BEGIN_INLINE_NS
14
15 namespace Driver
16 {
17
19 {
20#ifdef max
21# undef max
22#endif
25
26 CExports::IMG dummy = nullptr;
27
28 auto result = CExports::IRImageSize(parent_->Handle(), CExports::IMAGERECT_CMD_VALIDATE, width, height, dummy);
29 if (result < 0)
30 std::rethrow_exception(CvbException::FromCvbResult(result, "failed get sensor size"));
31
32 return Size2D<int>(static_cast<int>(width), static_cast<int>(height));
33 }
34
36 {
37 CExports::cvbdim_t width = 0;
38 CExports::cvbdim_t height = 0;
39
40 CExports::IMG dummy = nullptr;
41
42 auto result = CExports::IRImageSize(parent_->Handle(), CExports::IMAGERECT_CMD_GET, width, height, dummy);
43 if (result < 0)
44 std::rethrow_exception(CvbException::FromCvbResult(result, "failed get current size"));
45
46 return Size2D<int>(static_cast<int>(width), static_cast<int>(height));
47 }
48
50 {
51 auto width = static_cast<CExports::cvbdim_t>(size.Width());
52 auto height = static_cast<CExports::cvbdim_t>(size.Height());
53
54 CExports::IMG dummy = nullptr;
55
56 auto validateResult =
57 CExports::IRImageSize(parent_->Handle(), CExports::IMAGERECT_CMD_VALIDATE, width, height, dummy);
58 if (validateResult != ErrorCodes::CVB_NOTSUPPORTED && validateResult < 0)
59 std::rethrow_exception(CvbException::FromCvbResult(validateResult, "failed validate image rectangle size"));
60
61 CExports::IMG handle = nullptr;
62 auto setResult = CExports::IRImageSize(parent_->Handle(), CExports::IMAGERECT_CMD_SET, width, height, handle);
63 if (setResult < 0)
64 std::rethrow_exception(CvbException::FromCvbResult(setResult, "failed set image rectangle size"));
65
66 HandleGuard<Device> guard(handle);
67 Parent()->ChangeHandle(std::move(guard), mode);
68 }
69
71 {
72 CExports::cvbdim_t width = 0;
73 CExports::cvbdim_t height = 0;
74
75 auto result = CExports::IRImageOffset(parent_->Handle(), CExports::IMAGERECT_CMD_GET, width, height);
76 if (result < 0)
77 std::rethrow_exception(CvbException::FromCvbResult(result, "failed get current offset"));
78
79 return Point2D<int>(static_cast<int>(width), static_cast<int>(height));
80 }
81
83 {
84 auto width = static_cast<CExports::cvbdim_t>(point.X());
85 auto height = static_cast<CExports::cvbdim_t>(point.Y());
86
87 auto validateResult = CExports::IRImageOffset(parent_->Handle(), CExports::IMAGERECT_CMD_VALIDATE, width, height);
88 if (validateResult < 0)
89 std::rethrow_exception(CvbException::FromCvbResult(validateResult, "failed validate offset"));
90
91 auto setResult = CExports::IRImageOffset(parent_->Handle(), CExports::IMAGERECT_CMD_SET, width, height);
92 if (setResult < 0)
93 std::rethrow_exception(CvbException::FromCvbResult(setResult, "failed set offset"));
94 }
95
97 {
98 CExports::cvbdim_t dummy = 0;
99
100 CExports::IMG handle = nullptr;
101
102 auto setResult = CExports::IRImageSize(parent_->Handle(), CExports::IMAGERECT_CMD_RESET, dummy, dummy, handle);
103 if (setResult < 0)
104 std::rethrow_exception(CvbException::FromCvbResult(setResult, "failed update image rect"));
105
106 HandleGuard<Device> guard(handle);
107 Parent()->ChangeHandle(std::move(guard), mode);
108 }
109
110 } // namespace Driver
111
112 CVB_END_INLINE_NS
113
114} // namespace Cvb
Size2D< int > Size() const
Gets the current rectangle size.
Definition detail_image_rect.hpp:35
Size2D< int > SensorSize() const
Gets the sensor size.
Definition detail_image_rect.hpp:18
void SetOffset(Point2D< int > point)
Sets the offset of the image rectangle.
Definition detail_image_rect.hpp:82
Point2D< int > Offset() const
Gets the offset of the image rectangle.
Definition detail_image_rect.hpp:70
void ApplySize(Size2D< int > size, DeviceUpdateMode mode)
Sets the size.
Definition detail_image_rect.hpp:49
DevicePtr Parent() const noexcept
Gets the parent device of this interface.
Definition decl_image_rect.hpp:31
void Update(DeviceUpdateMode mode)
Updates the CVB buffer according to the current device settings.
Definition detail_image_rect.hpp:96
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
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 max(T... args)
T move(T... args)
Namespace for driver or device related operations.
Definition decl_composite.hpp:28
const int CVB_NOTSUPPORTED
A certain feature is not supported.
Definition exception.hpp:59
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
DeviceUpdateMode
Defines how to treat the optional device image, when the device itself is updated.
Definition global.hpp:252
T rethrow_exception(T... args)