25 #ifndef INCLUDED_ImagingInterface_h_GUID_E9CA5277_A0F5_488E_9E65_8541D437187C 26 #define INCLUDED_ImagingInterface_h_GUID_E9CA5277_A0F5_488E_9E65_8541D437187C 36 #include <opencv2/core/core.hpp> 51 class ImagingMessage {
62 std::size_t bytes = frame.total() * frame.elemSize();
65 std::memcpy(m_buf, frame.data, bytes);
66 m_frame = cv::Mat(frame.size(), frame.type(), m_buf);
74 cv::Mat
const &
getFrame()
const {
return m_frame; }
105 OSVR_ReturnCode ret =
108 throw std::logic_error(
"Could not initialize an Imaging " 109 "Interface with the device options " 119 throw std::logic_error(
120 "Must initialize the imaging interface before using it!");
122 cv::Mat
const &frame(message.getFrame());
124 util::opencvNumberTypeData(frame.type());
126 metadata.
channels = frame.channels();
127 metadata.depth =
static_cast<OSVR_ImageDepth
>(typedata.getSize());
128 metadata.width = frame.cols;
129 metadata.height = frame.rows;
130 metadata.type = typedata.isFloatingPoint()
131 ? OSVR_IVT_FLOATING_POINT
132 : (typedata.isSigned() ? OSVR_IVT_SIGNED_INT
133 : OSVR_IVT_UNSIGNED_INT);
136 dev, m_iface, metadata, message.getBuf(), message.getSensor(),
139 throw std::runtime_error(
"Could not send imaging message!");
150 #endif // INCLUDED_ImagingInterface_h_GUID_E9CA5277_A0F5_488E_9E65_8541D437187C
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrDeviceImagingReportFrame(OSVR_IN_PTR OSVR_DeviceToken dev, OSVR_IN_PTR OSVR_ImagingDeviceInterface iface, OSVR_IN OSVR_ImagingMetadata metadata, OSVR_IN_PTR OSVR_ImageBufferElement *imageData, OSVR_IN OSVR_ChannelCount sensor, OSVR_IN_PTR OSVR_TimeValue const *timestamp) OSVR_FUNC_NONNULL((1
Report a frame for a sensor.
uint32_t OSVR_ChannelCount
The integer type specifying a number of channels/sensors or a channel/sensor index.
Definition: ChannelCountC.h:51
Wrapper class for OSVR_DeviceToken.
Definition: DeviceInterface.h:93
Runtime data on numeric types.
Definition: NumberTypeManipulation.h:47
ImagingInterface(OSVR_ImagingDeviceInterface iface=NULL)
Default constructor or constructor from an existing OSVR_ImagingDeviceInterface (assumed to be regist...
Definition: ImagingInterface.h:98
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
A class wrapping a cv::Mat representing a frame, as well as the sensor ID it corresponds to...
Definition: ImagingInterface.h:55
typedefOSVR_EXTERN_C_BEGIN struct OSVR_ImagingDeviceInterfaceObject * OSVR_ImagingDeviceInterface
Opaque type used in conjunction with a device token to send data on an imaging interface.
Definition: ImagingInterfaceC.h:58
ImagingInterface(OSVR_DeviceInitOptions opts, OSVR_ChannelCount numSensors=1)
Constructor that registers an imaging interface with the device init options object.
Definition: ImagingInterface.h:103
OSVR_ChannelCount getSensor() const
Gets the sensor number.
Definition: ImagingInterface.h:80
Structure used internally to construct the desired type of device.
Definition: DeviceInitObject.h:59
OSVR_ImageBufferElement * getBuf() const
Retrieves the (cloned) buffer pointer.
Definition: ImagingInterface.h:77
A class wrapping an imaging interface for a device.
Definition: ImagingInterface.h:93
Header defining an aligned memory allocator.
#define OSVR_RETURN_SUCCESS
The "success" value for an OSVR_ReturnCode.
Definition: ReturnCodesC.h:45
void send(DeviceToken &dev, ImagingMessage const &message, OSVR_TimeValue const ×tamp)
Send method - usually called by osvr::pluginkit::DeviceToken::send()
Definition: ImagingInterface.h:116
cv::Mat const & getFrame() const
Retrieves a reference to the cv::Mat object.
Definition: ImagingInterface.h:74
void * alignedAlloc(size_t bytes, size_t alignment=OSVR_DEFAULT_ALIGN_SIZE)
Aligned allocation function, gives a pointer to a block of memory aligned to a memory boundary...
Definition: AlignedMemory.h:45
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
unsigned char OSVR_ImageBufferElement
Type for raw buffer access to image data.
Definition: ImagingReportTypesC.h:53
Definition: ProjectionMatrix.h:77
void alignedFree(void *p)
Aligned deallocation function, uses the pointer to the original memory block to deallocate it...
Definition: AlignedMemory.h:56
Header providing C++ interface wrappers around functionality in DeviceInterfaceC.h.
ImagingMessage(cv::Mat const &frame, OSVR_ChannelCount sensor=0)
Constructor, optionally taking a sensor number.
Definition: ImagingInterface.h:60
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrDeviceImagingConfigure(OSVR_INOUT_PTR OSVR_DeviceInitOptions opts, OSVR_OUT_PTR OSVR_ImagingDeviceInterface *iface, OSVR_IN OSVR_ChannelCount numSensors OSVR_CPP_ONLY(=1)) OSVR_FUNC_NONNULL((1
Specify that your device will implement the Imaging interface.