32 #include <opencv2/core/core.hpp>
33 #include <opencv2/highgui/highgui.hpp>
34 #include <opencv2/imgproc/imgproc.hpp>
46 if (!m_camera.isOpened()) {
47 std::cerr <<
"Couldn't open camera" << std::endl;
51 height =
static_cast<int>(m_camera.get(CV_CAP_PROP_FRAME_HEIGHT));
52 width =
static_cast<int>(m_camera.get(CV_CAP_PROP_FRAME_WIDTH));
57 bool isOculusCamera = (width == 376) && (height == 480);
59 std::cerr <<
"This standalone app doesn't have Oculus support."
64 std::cout <<
"Got image of size " << width <<
"x" << height
65 <<
", Format " << m_camera.get(CV_CAP_PROP_FORMAT)
66 <<
", Mode " << m_camera.get(CV_CAP_PROP_MODE) << std::endl;
70 double cx = width / 2.0;
71 double cy = height / 2.0;
75 m_vbtracker.addSensor(osvr::vbtracker::createHDKLedIdentifier(0),
77 osvr::vbtracker::OsvrHdkLedLocations_SENSOR0,
78 osvr::vbtracker::OsvrHdkLedDirections_SENSOR0);
79 m_vbtracker.addSensor(osvr::vbtracker::createHDKLedIdentifier(1),
81 osvr::vbtracker::OsvrHdkLedLocations_SENSOR1,
82 osvr::vbtracker::OsvrHdkLedDirections_SENSOR1);
88 if (!m_valid || !m_camera.isOpened()) {
91 if (!m_camera.grab()) {
96 if (!m_camera.retrieve(m_frame, m_channel)) {
105 cv::cvtColor(m_frame, m_imageGray, CV_RGB2GRAY);
108 m_frame, m_imageGray, tv,
110 std::cout <<
"Sensor " << sensor <<
": Translation "
117 bool m_valid =
false;
119 cv::VideoCapture m_camera;
uint32_t OSVR_ChannelCount
The integer type specifying a number of channels/sensors or a channel/sensor index.
void getNow(TimeValue &tv)
Set the given TimeValue to the current time.
OSVR_Quaternion rotation
Orientation as a unit quaternion.
bool processImage(cv::Mat frame, cv::Mat grayImage, OSVR_TimeValue const &tv, PoseHandler handler)
The main method that processes an image into tracked poses.
A structure defining a 3D (6DOF) rigid body pose: translation and rotation.
OSVR_Vec3 translation
Position vector.