11 #include "namespace.hpp" 13 #include "_cexports/c_core.h" 14 #include "_cexports/c_driver.h" 17 # define CVB_FORCE_INLINE inline 21 # define CVB_FORCE_INLINE __forceinline 23 # elif __GNUC__ && __cplusplus 25 # define CVB_FORCE_INLINE inline __attribute__((always_inline)) 57 class LinearAccessData;
112 const double CVB_M_PI = 3.14159265358979323846;
163 Unknown = CExports::CM_Unknown,
167 Mono = CExports::CM_Mono,
175 RGB = CExports::CM_RGB,
179 YUV = CExports::CM_YUV,
183 HSI = CExports::CM_HSI,
187 YCbCr = CExports::CM_YCbCr,
191 CieLUV = CExports::CM_LUV,
195 CieLab = CExports::CM_Lab,
199 HLS = CExports::CM_HLS,
203 YCC = CExports::CM_YCC,
207 HSV = CExports::CM_HSV,
302 Gaussian = CExports::TSubPixelMode::SP_Gauss
353 Ok = CExports::CVDWS_Ok,
355 Timeout = CExports::CVDWS_Timeout,
357 Abort = CExports::CVDWS_Canceled
371 PixMono = CExports::CVCPR_PixMono,
373 PixRGB_R = CExports::CVCPR_PixRGB_R,
375 PixRGB_G = CExports::CVCPR_PixRGB_G,
377 PixRGB_B = CExports::CVCPR_PixRGB_B,
379 PixYUV_Y = CExports::CVCPR_PixYUV_Y,
381 PixYUV_U = CExports::CVCPR_PixYUV_U,
383 PixYUV_V = CExports::CVCPR_PixYUV_V,
385 PixHSV_H = CExports::CVCPR_PixHSV_H,
387 PixHSV_S = CExports::CVCPR_PixHSV_S,
389 PixHSV_V = CExports::CVCPR_PixHSV_V,
391 PixLAB_L = CExports::CVCPR_PixLAB_L,
393 PixLAB_A = CExports::CVCPR_PixLAB_A,
395 PixLAB_B = CExports::CVCPR_PixLAB_B,
424 Normal_X = CExports::CVCPR_Normal_X,
426 Normal_Y = CExports::CVCPR_Normal_Y,
428 Normal_Z = CExports::CVCPR_Normal_Z,
441 Custom = CExports::CVCPR_Custom
464 enum class CompositePurpose
487 template <
class T>
class AsyncRef
490 AsyncRef() =
default;
495 auto ref = weakRef_.lock();
504 void Reset() noexcept { weakRef_.reset(); }
515 HandlerCarrier() noexcept = default;
516 virtual ~HandlerCarrier() = default;
519 typedef std::shared_ptr<HandlerCarrier> HandlerCarrierPtr;
520 typedef std::weak_ptr<HandlerCarrier> HandlerCarrierWPtr;
522 class CarrierContainer;
537 friend Internal::CarrierContainer;
551 operator bool() const noexcept {
return !handlerCarrier_.expired(); }
556 Internal::HandlerCarrierWPtr handlerCarrier_;
562 typedef void(REL_CB)(
void *handle);
566 template <
class T, Internal::REL_CB CB>
class SharedHandleGuard;
568 template <
class T, Internal::REL_CB CB =
nullptr>
class HandleGuard
572 explicit HandleGuard(
void *handle) noexcept : handle_(handle, CB)
575 "CVB: HandleGuard need specialization, or type void with release callback!");
578 HandleGuard(
void *handle,
std::function<
void(
void *)> deleter) noexcept : handle_(handle, deleter) {}
580 void *Handle() const noexcept {
return handle_.get(); }
582 void Reset(
void *handle =
nullptr) noexcept { handle_.reset(handle); }
584 void *Release() noexcept {
return handle_.release(); }
589 friend class SharedHandleGuard<T, CB>;
592 typedef HandleGuard<void, CVB_CALL_CAPI(ReleaseObjectVoid)> ReleaseObjectGuard;
594 template <
class T, Internal::REL_CB CB =
nullptr>
class SharedHandleGuard
597 SharedHandleGuard(HandleGuard<T, CB> &&uniqueGuard) : shandle_(std::
move(uniqueGuard.handle_)) {}
599 SharedHandleGuard(
const SharedHandleGuard &) =
default;
600 SharedHandleGuard &operator=(
const SharedHandleGuard &) =
default;
602 void *Handle() const noexcept {
return shandle_.get(); }
608 typedef SharedHandleGuard<void, CVB_CALL_CAPI(ReleaseObjectVoid)> SharedReleaseObjectGuard;
616 void ThrowLastError();
617 void ThrowLastError(
int errorCode);
626 template <
class T>
class CbCarrier :
public HandlerCarrier
640 class CarrierContainer
643 CarrierContainer() noexcept {}
645 CarrierContainer(CarrierContainer &&other) noexcept : carrierList_(std::move(other.carrierList_)) {}
647 ~CarrierContainer() =
default;
649 EventCookie Register(
const HandlerCarrierPtr &handlerBase) noexcept
652 carrierList_.push_back(handlerBase);
653 return EventCookie(handlerBase);
656 void Unregister(EventCookie eventCookie) noexcept
659 auto handlerBase = eventCookie.handlerCarrier_.lock();
663 carrierList_.remove(handlerBase);
666 template <
class T,
class... Args>
void Call(Args &&... args)
const 671 eventHolderList.insert(eventHolderList.end(), carrierList_.begin(), carrierList_.end());
673 for (
auto &holderBase : eventHolderList)
675 auto holder = std::dynamic_pointer_cast<CbCarrier<T>>(holderBase);
676 holder->CB()(std::forward<Args>(args)...);
681 CarrierContainer &operator=(CarrierContainer &&other) noexcept =
delete;
687 template <
class OBJ,
class RES,
class... ARGS>
690 void *handle =
nullptr;
691 auto code = CExports::MakeErrorCode(call(handle));
694 Utilities::SystemInfo::ThrowLastError(code);
696 return OBJ::FromHandle(HandleGuard<OBJ>(handle), std::forward<ARGS>(args)...);
699 template <
class OBJ,
class... ARGS>
702 return DoCallObjectOut<OBJ, CExports::cvbbool_t, ARGS...>(call, std::forward<ARGS>(args)...);
705 template <
class OBJ,
class... ARGS>
708 return DoCallObjectOut<OBJ, CExports::cvbres_t, ARGS...>(call, std::forward<ARGS>(args)...);
713 return DoCallObjectOut<OBJ, void *>([=](
void *&handle) {
return (handle = result); });
716 template <
class OBJ,
class RES,
class... ARGS>
719 void *handle =
nullptr;
720 auto code = CExports::MakeErrorCode(call(handle));
723 Utilities::SystemInfo::ThrowLastError(code);
725 return OBJ::template FromHandle<OBJ>(
typename OBJ::GuardType(handle), std::forward<ARGS>(args)...);
728 template <
class OBJ,
class... ARGS>
731 return DoCallShareOut<OBJ, CExports::cvbbool_t, ARGS...>(call, std::forward<ARGS>(args)...);
734 template <
class OBJ,
class... ARGS>
737 return DoCallShareOut<OBJ, CExports::cvbres_t, ARGS...>(call, std::forward<ARGS>(args)...);
740 template <
class T,
class RES>
inline T DoCallValueOut(
std::function<RES(T &handle)> call)
743 auto code = CExports::MakeErrorCode(call(value));
746 Utilities::SystemInfo::ThrowLastError(code);
751 template <
class T>
inline T DoBoolCallValueOut(
std::function<CExports::cvbbool_t(T &handle)> call)
753 return DoCallValueOut<T, CExports::cvbbool_t>(call);
756 template <
class T>
inline T DoResCallValueOut(
std::function<CExports::cvbres_t(T &value)> call)
758 return DoCallValueOut<T, CExports::cvbres_t>(call);
761 template <
class RES>
inline void DoCall(
std::function<RES()> call)
763 auto code = CExports::MakeErrorCode(call());
765 Utilities::SystemInfo::ThrowLastError(code);
768 inline void DoBoolCall(
std::function<CExports::cvbbool_t()> call)
770 DoCall<CExports::cvbbool_t>(call);
773 inline void DoResCall(
std::function<CExports::cvbres_t()> call)
775 DoCall<CExports::cvbres_t>(call);
778 class SmartBool final
781 SmartBool() noexcept = default;
782 SmartBool(
bool val) noexcept : cVal_(val ? 1 : 0) {}
785 SmartBool(CExports::cvbbool_t val) noexcept : cVal_(val) {}
788 operator bool() const noexcept {
return ((cVal_) ?
true :
false); }
790 CExports::cvbbool_t *Ptr() noexcept {
return &cVal_; }
793 CExports::cvbbool_t cVal_ = 0;
809 template <
class T,
class... ARGS>
struct AllOfType;
811 template <
class T,
class ARG>
struct AllOfType<T, ARG>
813 static constexpr
bool Value =
818 template <
class T,
class ARG,
class... ARGS>
struct AllOfType<T, ARG, ARGS...>
820 static constexpr
bool Value =
823 AllOfType<T, ARGS...>::Value;
826 template <
typename RET,
typename TYPE,
class RANGE>
829 *std::begin(std::declval<RANGE &>()))>::type>::type>::value,
832 template <
class RET,
class TYPE,
class... ARGS>
833 using VarArgRange =
typename std::enable_if<AllOfType<TYPE, ARGS...>::Value, RET>;
835 template <
class TYPE,
class RANGE>
class RangeAdapter
840 RangeAdapter(
const RANGE &range) : inputRef_(range)
846 "Unexpected range value type");
853 return const_cast<TYPE *>(Data(inputRef_.get()));
857 std::size_t Size()
const {
return std::distance(std::begin(inputRef_.get()), std::end(inputRef_.get())); }
861 template <
size_t N>
const TYPE *Data(
const TYPE (&carray)[N])
const {
return carray; }
863 template <
size_t N>
const TYPE *Data(
const std::array<TYPE, N> &stdarray)
const {
return stdarray.data(); }
865 const TYPE *Data(
const std::vector<TYPE> &stdvec)
const {
return stdvec.data(); }
867 template <
class LIST>
const TYPE *Data(
const LIST &list)
const 869 if (convertedRange_.empty())
871 convertedRange_.assign(std::begin(list), std::end(list));
873 return convertedRange_.data();
881 template <
class TYPE,
class RANGE>
882 RangeAdapter<TYPE, RANGE> MakeRangeAdapter(
const RANGE &range,
std::size_t minSize = 1)
884 RangeAdapter<TYPE, RANGE> rangeAdapter(range);
885 if (minSize != 0 && rangeAdapter.Size() < minSize)
891 struct DispatchableTypeList
895 template <
class DT,
class... DTS>
896 struct DispatchableTypeList<DT, DTS...>
898 using DefaultType = DT;
930 template <
class PLANE_T>
PlaneNormalization
Plane handling for normalization.
Definition: global.hpp:250
Cartesian Y axis component.
Confidence(probability density / percentage) or consistency(Boolean) value.
WaitStatus
Status after waiting for an image to be returned.
Definition: global.hpp:350
The acquisition has been stopped asynchronously, there is no image buffer.
Base class of all buffers.
Definition: buffer_base.hpp:21
Planarity of points in cloud.
The Device object is currently disconnected from the remote hardware.
HandleOnly class is as it says a handle only.
Definition: handle_only.hpp:20
Cookie used to unregister event handlers.
Definition: global.hpp:534
Point components of a dense point cloud.
Definition: dense_components_pointers_3d.hpp:14
Cartesian W axis component (homogeneous coordinates).
Cartesian Z axis component.
Everything is fine, a new image arrived.
Provides tokens and signals tokens cancellation.
Definition: cancellation_token_source.hpp:19
Connection state handling is not supported by the Device.
ConnectionState
Current connection state of the Device.
Definition: global.hpp:454
Area of the blob in pixels.
ConversionMode
Mode used by conversion to dense point cloud.
Definition: global.hpp:476
The Device object is currently connected to the remote hardware.
Neighborhood
Neighborhood to use in sub pixel calculation of local maxima.
Definition: global.hpp:310
Cylindrical radius component.
Mapped image of two merged source images.
Definition: panoramic_mapped_image.hpp:18
Spherical inclination/polar angle component.
Polar azimuth angle component.
Spherical azimuth angle component.
MappingOption
Mapping options when creating a (potentially) mapped image.
Definition: global.hpp:334
Value(luminance) channel value.
DeviceUpdateMode
Defines how to treat the optional device image, when the device itself is updated.
Definition: global.hpp:225
Variation of points in cloud.
Root namespace for the Image Manager interface.
Definition: version.hpp:11
A wrapped image wraps another pixel buffer without owning it.
Definition: decl_wrapped_image.hpp:28
The Common Vision Blox image.
Definition: decl_image.hpp:44
Lazy enumeration of planes.
Definition: decl_plane_enumerator.hpp:27
Spherical radius component.
Images are stitched vertically.
CoordinateSystemType
Enumeration of the different available coordinate systems that an Area of interest may be defined in.
Definition: global.hpp:263
Green-red chrominance channel.
PanoramaDirection
Defines the direction of the panoramic image.
Definition: global.hpp:445
Cylindrical Z axis component.
Cylindrical azimuth angle component.
Point components of the point cloud.
Definition: components_pointers_3d.hpp:18
PixelDataType
Defines the numeric data type of one pixel.
Definition: global.hpp:123
Images are stitched horizontally.
Blue chrominance channel.
Plane information container.
Definition: decl_plane.hpp:26
PlaneRole
A plane role describes the components of the plane. They can coarsely be separated in two sets.
Definition: global.hpp:365
ColorModel
Color model that this image is using.
Definition: global.hpp:150
Same as PixMono, but to distinguish YUV model.
A token to enable cancellation on wait operations.
Definition: cancellation_token.hpp:19
SubPixelMode
Method for determining sub pixel accuracy when working with the FindLocalMaxima functions.
Definition: global.hpp:285
Curvature of points in cloud.
Definition: global.hpp:931
A timeout occurred, no image buffer has been returned.
Component class is a container for CVB objects.
Definition: decl_composite.hpp:44
Cartesian X axis component.
PFNC buffer class implementing a pfnc buffer.
Definition: pfnc_buffer.hpp:15
Blue-yellow chrominance channel.
Linearity of points in cloud.
Point components of a sparse point cloud.
Definition: global.hpp:117
Generic CVB physical device.
Definition: decl_device.hpp:38
Sphericity of points in cloud.
Monochromatic, linear luminance value.
DataType
Describes the contents of a VariableNode.
Definition: opcua.hpp:186
Gets the value for an info key name.