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))
59class LinearAccessData;
118const double CVB_M_PI = 3.14159265358979323846;
169 Unknown = CExports::CM_Unknown,
173 Mono = CExports::CM_Mono,
181 RGB = CExports::CM_RGB,
185 YUV = CExports::CM_YUV,
189 HSI = CExports::CM_HSI,
193 YCbCr = CExports::CM_YCbCr,
197 CieLUV = CExports::CM_LUV,
201 CieLab = CExports::CM_Lab,
205 HLS = CExports::CM_HLS,
209 YCC = CExports::CM_YCC,
213 HSV = CExports::CM_HSV,
308 Gaussian = CExports::TSubPixelMode::SP_Gauss
378 Ok = CExports::CVDWS_Ok,
380 Timeout = CExports::CVDWS_Timeout,
382 Abort = CExports::CVDWS_Canceled
393 Undefined = CExports::CVCPR_Undefined,
396 PixMono = CExports::CVCPR_PixMono,
398 PixRGB_R = CExports::CVCPR_PixRGB_R,
400 PixRGB_G = CExports::CVCPR_PixRGB_G,
402 PixRGB_B = CExports::CVCPR_PixRGB_B,
404 PixYUV_Y = CExports::CVCPR_PixYUV_Y,
406 PixYUV_U = CExports::CVCPR_PixYUV_U,
408 PixYUV_V = CExports::CVCPR_PixYUV_V,
410 PixHSV_H = CExports::CVCPR_PixHSV_H,
412 PixHSV_S = CExports::CVCPR_PixHSV_S,
414 PixHSV_V = CExports::CVCPR_PixHSV_V,
416 PixLAB_L = CExports::CVCPR_PixLAB_L,
418 PixLAB_A = CExports::CVCPR_PixLAB_A,
420 PixLAB_B = CExports::CVCPR_PixLAB_B,
451 Normal_X = CExports::CVCPR_Normal_X,
453 Normal_Y = CExports::CVCPR_Normal_Y,
455 Normal_Z = CExports::CVCPR_Normal_Z,
468 Custom = CExports::CVCPR_Custom
475 Horizontal = CExports::PM_Horizontal,
477 Vertical = CExports::PM_Vertical
491enum class CompositePurpose
514template <
class T>
class AsyncRef
517 AsyncRef() =
default;
522 auto ref = weakRef_.lock();
531 void Reset() noexcept { weakRef_.reset(); }
542 HandlerCarrier() noexcept = default;
543 HandlerCarrier(const HandlerCarrier& other) noexcept = default;
544 HandlerCarrier& operator=(const HandlerCarrier& other) noexcept = default;
545 HandlerCarrier(HandlerCarrier&& other) noexcept = default;
546 HandlerCarrier& operator=(HandlerCarrier&& other) noexcept = default;
547 virtual ~HandlerCarrier() = default;
550typedef std::shared_ptr<HandlerCarrier> HandlerCarrierPtr;
551typedef std::weak_ptr<HandlerCarrier> HandlerCarrierWPtr;
553class CarrierContainer;
568 friend Internal::CarrierContainer;
582 explicit operator
bool() const noexcept {
return !handlerCarrier_.expired(); }
586 : handlerCarrier_(handlerCarrier)
590 Internal::HandlerCarrierWPtr handlerCarrier_;
596typedef void(REL_CB)(
void *handle);
600template <
class T, Internal::REL_CB CB>
class SharedHandleGuard;
602template <
class T, Internal::REL_CB CB =
nullptr>
class HandleGuard
606 explicit HandleGuard(
void *handle) noexcept : handle_(handle, CB)
609 "CVB: HandleGuard need specialization, or type void with release callback!");
612 HandleGuard(
void *handle,
std::function<
void(
void *)> deleter) noexcept : handle_(handle, deleter) {}
614 void *Handle() const noexcept {
return handle_.get(); }
616 void Reset(
void *handle =
nullptr) noexcept { handle_.reset(handle); }
618 void *Release() noexcept {
return handle_.release(); }
623 friend class SharedHandleGuard<T, CB>;
626typedef HandleGuard<void, CVB_CALL_CAPI(ReleaseObjectVoid)> ReleaseObjectGuard;
628template <
class T, Internal::REL_CB CB =
nullptr>
class SharedHandleGuard
631 explicit SharedHandleGuard(HandleGuard<T, CB> &&uniqueGuard) : shandle_(std::
move(uniqueGuard.handle_)) {}
633 SharedHandleGuard(
const SharedHandleGuard& other)
noexcept=
default;
634 SharedHandleGuard &operator=(
const SharedHandleGuard &)
noexcept =
default;
635 SharedHandleGuard(SharedHandleGuard&& other)
noexcept =
default;
636 SharedHandleGuard& operator=(SharedHandleGuard&& other)
noexcept =
default;
637 ~SharedHandleGuard() =
default;
639 void *Handle() const noexcept {
return shandle_.get(); }
645typedef SharedHandleGuard<void, CVB_CALL_CAPI(ReleaseObjectVoid)> SharedReleaseObjectGuard;
653void ThrowLastError();
654void ThrowLastError(
int errorCode);
663template <
class T>
class CbCarrier :
public HandlerCarrier
677class CarrierContainer
680 CarrierContainer() noexcept {}
682 CarrierContainer(
const CarrierContainer& other) =
delete;
683 CarrierContainer& operator=(
const CarrierContainer& other) =
delete;
684 CarrierContainer(CarrierContainer&& other)
noexcept
688 carrierList_ = std::move(other.carrierList_);
695 CarrierContainer& operator=(CarrierContainer&& other) =
delete;
696 ~CarrierContainer() =
default;
698 EventCookie Register(
const HandlerCarrierPtr &handlerBase)
701 carrierList_.push_back(handlerBase);
702 return EventCookie{ handlerBase };
705 void Unregister(EventCookie eventCookie)
noexcept
708 auto handlerBase = eventCookie.handlerCarrier_.lock();
713 carrierList_.remove(handlerBase);
716 template <
class T,
class... Args>
void Call(Args &&... args)
const
721 carrierList.insert(carrierList.end(), carrierList_.begin(), carrierList_.end());
723 for (
auto& carrier : carrierList)
725 auto holder = std::dynamic_pointer_cast<CbCarrier<T>>(carrier);
726 holder->CB()(std::forward<Args>(args)...);
737template <
class OBJ,
class RES,
class... ARGS>
740 void *handle =
nullptr;
741 auto code = CExports::MakeErrorCode(call(handle));
744 Utilities::SystemInfo::ThrowLastError(code);
746 return OBJ::FromHandle(HandleGuard<OBJ>(handle), std::forward<ARGS>(args)...);
749template <
class OBJ,
class... ARGS>
752 return DoCallObjectOut<OBJ, CExports::cvbbool_t, ARGS...>(call, std::forward<ARGS>(args)...);
755template <
class OBJ,
class... ARGS>
758 return DoCallObjectOut<OBJ, CExports::cvbres_t, ARGS...>(call, std::forward<ARGS>(args)...);
763 return DoCallObjectOut<OBJ, void *>([=](
void *&handle) {
return (handle = result); });
766template <
class OBJ,
class RES,
class... ARGS>
769 void *handle =
nullptr;
770 auto code = CExports::MakeErrorCode(call(handle));
773 Utilities::SystemInfo::ThrowLastError(code);
775 return OBJ::template FromHandle<OBJ>(
typename OBJ::GuardType(handle), std::forward<ARGS>(args)...);
778template <
class OBJ,
class... ARGS>
781 return DoCallShareOut<OBJ, CExports::cvbbool_t, ARGS...>(call, std::forward<ARGS>(args)...);
784template <
class OBJ,
class... ARGS>
787 return DoCallShareOut<OBJ, CExports::cvbres_t, ARGS...>(call, std::forward<ARGS>(args)...);
790template <
class T,
class RES>
inline T DoCallValueOut(
std::function<RES(T &handle)> call)
793 auto code = CExports::MakeErrorCode(call(value));
796 Utilities::SystemInfo::ThrowLastError(code);
801template <
class T>
inline T DoBoolCallValueOut(
std::function<CExports::cvbbool_t(T &handle)> call)
803 return DoCallValueOut<T, CExports::cvbbool_t>(call);
806template <
class T>
inline T DoResCallValueOut(
std::function<CExports::cvbres_t(T &value)> call)
808 return DoCallValueOut<T, CExports::cvbres_t>(call);
811template <
class RES>
inline void DoCall(
std::function<RES()> call)
813 auto code = CExports::MakeErrorCode(call());
815 Utilities::SystemInfo::ThrowLastError(code);
818inline void DoBoolCall(
std::function<CExports::cvbbool_t()> call)
820 DoCall<CExports::cvbbool_t>(call);
823inline void DoResCall(
std::function<CExports::cvbres_t()> call)
825 DoCall<CExports::cvbres_t>(call);
831 SmartBool() noexcept = default;
832 SmartBool(
bool val) noexcept : cVal_(val ? 1 : 0) {}
835 SmartBool(CExports::cvbbool_t val) noexcept : cVal_(val) {}
838 operator bool() const noexcept {
return ((cVal_) ?
true :
false); }
840 CExports::cvbbool_t *Ptr() noexcept {
return &cVal_; }
843 CExports::cvbbool_t cVal_ = 0;
859template <
class T,
class... ARGS>
struct AllOfType;
861template <
class T,
class ARG>
struct AllOfType<T, ARG>
863 static constexpr bool Value =
868template <
class T,
class ARG,
class... ARGS>
struct AllOfType<T, ARG, ARGS...>
870 static constexpr bool Value =
873 AllOfType<T, ARGS...>::Value;
876template <
typename RET,
typename TYPE,
class RANGE>
879 *std::begin(std::declval<RANGE &>()))>::type>::type>::value,
882template <
class RET,
class TYPE,
class... ARGS>
883using VarArgRange =
typename std::enable_if<AllOfType<TYPE, ARGS...>::Value, RET>;
885template <
class TYPE,
class RANGE>
class RangeAdapter
890 explicit RangeAdapter(
const RANGE &range) : inputRef_(range)
896 "Unexpected range value type");
902 return const_cast<TYPE *
>(Data(inputRef_.get()));
906 std::size_t Size()
const {
return std::distance(std::begin(inputRef_.get()), std::end(inputRef_.get())); }
910 template <
size_t N>
const TYPE *Data(
const TYPE (&carray)[N])
const {
return carray; }
912 template <
size_t N>
const TYPE *Data(
const std::array<TYPE, N> &stdarray)
const {
return stdarray.data(); }
914 const TYPE *Data(
const std::vector<TYPE> &stdvec)
const {
return stdvec.data(); }
916 template <
class LIST>
const TYPE *Data(
const LIST &list)
const
918 if (convertedRange_.empty())
920 convertedRange_.assign(std::begin(list), std::end(list));
922 return convertedRange_.data();
930template <
class TYPE,
class RANGE>
931RangeAdapter<TYPE, RANGE> MakeRangeAdapter(
const RANGE &range,
std::size_t minSize = 1)
933 RangeAdapter<TYPE, RANGE> rangeAdapter(range);
934 if (minSize != 0 && rangeAdapter.Size() < minSize)
940struct DispatchableTypeList
944template <
class DT,
class... DTS>
945struct DispatchableTypeList<DT, DTS...>
947 using DefaultType = DT;
979template <
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:566
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.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
RotationMap
Amount of rotation to apply when mapping an image.
Definition: global.hpp:357
PanoramaDirection
Defines the direction of the panoramic image.
Definition: global.hpp:473
SubPixelMode
Method for determining sub pixel accuracy when working with the FindLocalMaxima functions.
Definition: global.hpp:292
ConversionMode
Mode used by conversion to dense point cloud.
Definition: global.hpp:504
MappingOption
Mapping options when creating a (potentially) mapped image.
Definition: global.hpp:341
WaitStatus
Status after waiting for an image to be returned.
Definition: global.hpp:376
@ Abort
The acquisition has been stopped asynchronously, there is no image buffer.
PixelDataType
Defines the numeric data type of one pixel.
Definition: global.hpp:130
ColorModel
Color model that this image is using.
Definition: global.hpp:157
CoordinateSystemType
Enumeration of the different available coordinate systems that an Area of interest may be defined in.
Definition: global.hpp:270
ConnectionState
Current connection state of the Device.
Definition: global.hpp:482
@ NotSupported
Connection state handling is not supported by the Device.
Neighborhood
Neighborhood to use in sub pixel calculation of local maxima.
Definition: global.hpp:317
DeviceUpdateMode
Defines how to treat the optional device image, when the device itself is updated.
Definition: global.hpp:232
PlaneNormalization
Plane handling for normalization.
Definition: global.hpp:257
PlaneRole
A plane role describes the components of the plane. They can coarsely be separated in two sets.
Definition: global.hpp:391
@ 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.
@ PixRGB_RGB
Red-green-blue channel value.
@ 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:980