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))
57class LinearAccessData;
112const 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
368 Undefined = CExports::CVCPR_Undefined,
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
448 Horizontal = CExports::PM_Horizontal,
450 Vertical = CExports::PM_Vertical
464enum class CompositePurpose
487template <
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;
519typedef std::shared_ptr<HandlerCarrier> HandlerCarrierPtr;
520typedef std::weak_ptr<HandlerCarrier> HandlerCarrierWPtr;
522class CarrierContainer;
537 friend Internal::CarrierContainer;
551 operator
bool() const noexcept {
return !handlerCarrier_.expired(); }
556 Internal::HandlerCarrierWPtr handlerCarrier_;
562typedef void(REL_CB)(
void *handle);
566template <
class T, Internal::REL_CB CB>
class SharedHandleGuard;
568template <
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>;
592typedef HandleGuard<void, CVB_CALL_CAPI(ReleaseObjectVoid)> ReleaseObjectGuard;
594template <
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(); }
608typedef SharedHandleGuard<void, CVB_CALL_CAPI(ReleaseObjectVoid)> SharedReleaseObjectGuard;
616void ThrowLastError();
617void ThrowLastError(
int errorCode);
626template <
class T>
class CbCarrier :
public HandlerCarrier
640class 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;
687template <
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)...);
699template <
class OBJ,
class... ARGS>
702 return DoCallObjectOut<OBJ, CExports::cvbbool_t, ARGS...>(call, std::forward<ARGS>(args)...);
705template <
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); });
716template <
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)...);
728template <
class OBJ,
class... ARGS>
731 return DoCallShareOut<OBJ, CExports::cvbbool_t, ARGS...>(call, std::forward<ARGS>(args)...);
734template <
class OBJ,
class... ARGS>
737 return DoCallShareOut<OBJ, CExports::cvbres_t, ARGS...>(call, std::forward<ARGS>(args)...);
740template <
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);
751template <
class T>
inline T DoBoolCallValueOut(
std::function<CExports::cvbbool_t(T &handle)> call)
753 return DoCallValueOut<T, CExports::cvbbool_t>(call);
756template <
class T>
inline T DoResCallValueOut(
std::function<CExports::cvbres_t(T &value)> call)
758 return DoCallValueOut<T, CExports::cvbres_t>(call);
761template <
class RES>
inline void DoCall(
std::function<RES()> call)
763 auto code = CExports::MakeErrorCode(call());
765 Utilities::SystemInfo::ThrowLastError(code);
768inline void DoBoolCall(
std::function<CExports::cvbbool_t()> call)
770 DoCall<CExports::cvbbool_t>(call);
773inline void DoResCall(
std::function<CExports::cvbres_t()> call)
775 DoCall<CExports::cvbres_t>(call);
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;
809template <
class T,
class... ARGS>
struct AllOfType;
811template <
class T,
class ARG>
struct AllOfType<T, ARG>
813 static constexpr bool Value =
818template <
class T,
class ARG,
class... ARGS>
struct AllOfType<T, ARG, ARGS...>
820 static constexpr bool Value =
823 AllOfType<T, ARGS...>::Value;
826template <
typename RET,
typename TYPE,
class RANGE>
829 *std::begin(std::declval<RANGE &>()))>::type>::type>::value,
832template <
class RET,
class TYPE,
class... ARGS>
833using VarArgRange =
typename std::enable_if<AllOfType<TYPE, ARGS...>::Value, RET>;
835template <
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();
881template <
class TYPE,
class RANGE>
882RangeAdapter<TYPE, RANGE> MakeRangeAdapter(
const RANGE &range,
std::size_t minSize = 1)
884 RangeAdapter<TYPE, RANGE> rangeAdapter(range);
885 if (minSize != 0 && rangeAdapter.Size() < minSize)
891struct DispatchableTypeList
895template <
class DT,
class... DTS>
896struct DispatchableTypeList<DT, DTS...>
898 using DefaultType = DT;
930template <
class PLANE_T>
Base class of all buffers.
Definition: buffer_base.hpp:22
A token to enable cancellation on wait operations.
Definition: cancellation_token.hpp:20
Provides tokens and signals tokens cancellation.
Definition: cancellation_token_source.hpp:20
Point components of the point cloud.
Definition: components_pointers_3d.hpp:19
Component class is a container for CVB objects.
Definition: decl_composite.hpp:45
Point components of a dense point cloud.
Definition: dense_components_pointers_3d.hpp:15
Generic CVB physical device.
Definition: decl_device.hpp:39
Cookie used to unregister event handlers.
Definition: global.hpp:535
EventCookie() noexcept=default
Creates an empty cookie for convenience.
HandleOnly class is as it says a handle only.
Definition: handle_only.hpp:21
The Common Vision Blox image.
Definition: decl_image.hpp:45
PFNC buffer class implementing a pfnc buffer.
Definition: pfnc_buffer.hpp:17
Mapped image of two merged source images.
Definition: panoramic_mapped_image.hpp:20
Lazy enumeration of planes.
Definition: decl_plane_enumerator.hpp:28
Plane information container.
Definition: decl_plane.hpp:28
Point components of a sparse point cloud.
Definition: sparse_components_pointers_3d.hpp:14
A wrapped image wraps another pixel buffer without owning it.
Definition: decl_wrapped_image.hpp:30
@ Size
Area of the blob in pixels.
DataType
Describes the contents of a VariableNode.
Definition: opcua.hpp:187
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
PanoramaDirection
Defines the direction of the panoramic image.
Definition: global.hpp:446
SubPixelMode
Method for determining sub pixel accuracy when working with the FindLocalMaxima functions.
Definition: global.hpp:286
ConversionMode
Mode used by conversion to dense point cloud.
Definition: global.hpp:477
MappingOption
Mapping options when creating a (potentially) mapped image.
Definition: global.hpp:335
WaitStatus
Status after waiting for an image to be returned.
Definition: global.hpp:351
@ Abort
The acquisition has been stopped asynchronously, there is no image buffer.
PixelDataType
Defines the numeric data type of one pixel.
Definition: global.hpp:124
ColorModel
Color model that this image is using.
Definition: global.hpp:151
CoordinateSystemType
Enumeration of the different available coordinate systems that an Area of interest may be defined in.
Definition: global.hpp:264
ConnectionState
Current connection state of the Device.
Definition: global.hpp:455
@ NotSupported
Connection state handling is not supported by the Device.
Neighborhood
Neighborhood to use in sub pixel calculation of local maxima.
Definition: global.hpp:311
DeviceUpdateMode
Defines how to treat the optional device image, when the device itself is updated.
Definition: global.hpp:226
PlaneNormalization
Plane handling for normalization.
Definition: global.hpp:251
PlaneRole
A plane role describes the components of the plane. They can coarsely be separated in two sets.
Definition: global.hpp:366
@ PixYUV_Y
Same as PixMono, but to distinguish YUV model.
@ PixLAB_A
Green-red chrominance channel.
@ PixRGB_R
Red channel value.
@ PointVariation
Variation of points in cloud.
@ CoordCartesian_W
Cartesian W axis component (homogeneous coordinates).
@ CoordCartesian_Y
Cartesian Y axis component.
@ PointPlanarity
Planarity of points in cloud.
@ CoordCartesian_X
Cartesian X axis component.
@ CoordPolar_Phi
Polar azimuth angle component.
@ PixConfidence
Confidence(probability density / percentage) or consistency(Boolean) value.
@ PixLAB_B
Blue-yellow chrominance channel.
@ PointSphericity
Sphericity of points in cloud.
@ PointCurvature
Curvature of points in cloud.
@ PixRGB_B
Blue channel value.
@ CoordCylindrical_Phi
Cylindrical azimuth angle component.
@ CoordCylindrical_Rho
Cylindrical radius component.
@ CoordCartesian_Z
Cartesian Z axis component.
@ CoordSpherical_Phi
Spherical azimuth angle component.
@ PointLinearity
Linearity of points in cloud.
@ PixYUV_V
Red chrominance channel.
@ CoordPolar_Rho
Polar radius component.
@ PixHSV_V
Value(luminance) channel value.
@ PixYUV_U
Blue chrominance channel.
@ PixLAB_L
Lightness channel value.
@ CoordCylindrical_Z
Cylindrical Z axis component.
@ PixRGB_G
Green channel value.
@ PixHSV_H
Hue channel value.
@ CoordSpherical_Theta
Spherical inclination/polar angle component.
@ PixMono
Monochromatic, linear luminance value.
@ CoordSpherical_Rho
Spherical radius component.
Definition: global.hpp:931