30 #include "com_osvr_VideoCapture_OpenCV_json.h"
33 #include <opencv2/core/core.hpp>
34 #include <opencv2/core/operations.hpp>
36 #include <opencv2/core/version.hpp>
37 #if CV_MAJOR_VERSION == 2 || CV_VERSION_EPOCH == 2
38 #include <opencv2/highgui/highgui.hpp>
40 #include <opencv2/videoio.hpp>
43 #include <boost/noncopyable.hpp>
44 #include <boost/lexical_cast.hpp>
54 class CameraDevice : boost::noncopyable {
57 : m_camera(cameraNum), m_channel(channel) {
67 std::ostringstream os;
68 os <<
"Camera" << cameraNum <<
"_" << m_channel;
71 m_dev.initAsync(ctx, os.str(), opts);
77 m_dev.sendJsonDescriptor(
81 m_dev.registerUpdateCallback(
this);
84 OSVR_ReturnCode update() {
85 if (!m_camera.isOpened()) {
95 bool grabbed = m_camera.grab();
101 bool retrieved = m_camera.retrieve(m_frame, m_channel);
118 cv::VideoCapture m_camera;
123 class CameraDetection {
125 CameraDetection() : m_found(false) {}
134 cv::VideoCapture cap(0);
135 if (!cap.isOpened()) {
159 context.registerHardwareDetectCallback(
new CameraDetection());
Wrapper class for OSVR_DeviceToken.
void getNow(TimeValue &tv)
Set the given TimeValue to the current time.
std::string makeString(const char(&arrayLiteral)[N])
Safely and easily convert a literal array of characters (like from osvr_json_to_c) into a std::string...
A class wrapping a cv::Mat representing a frame, as well as the sensor ID it corresponds to...
C++ wrapper class for the opaque plugin context.
Structure used internally to construct the desired type of device.
Header with a convenience function to make a std::string out of a non-null-terminated char array (str...
A class wrapping an imaging interface for a device.
Base class for connection-specific message type registration.
#define OSVR_RETURN_FAILURE
The "failure" value for an OSVR_ReturnCode.
T * registerObjectForDeletion(OSVR_PluginRegContext ctx, T *obj)
Registers an object to be destroyed with delete when the plugin is unloaded.
#define OSVR_RETURN_SUCCESS
The "success" value for an OSVR_ReturnCode.
OSVR_DeviceInitOptions osvrDeviceCreateInitOptions(OSVR_PluginRegContext ctx)
Create a OSVR_DeviceInitOptions object.
Header including the full PluginKit C++ interface.
#define OSVR_PLUGIN(PLUGIN_NAME)
This macro begins the entry point function of your plugin.
OSVR_EXTERN_C_BEGIN typedef void * OSVR_PluginRegContext
A context pointer passed in to your plugin's entry point and other locations of control flow transfer...