29 #include <opencv2/highgui/highgui.hpp>
36 using CVCapturePtr = std::unique_ptr<cv::VideoCapture>;
41 if (m_camera->isOpened()) {
47 bool ok()
const override {
return m_camera && m_camera->isOpened(); }
55 CVCapturePtr m_camera;
60 ImageSourcePtr openOpenCVCamera(
int which) {
61 auto ret = ImageSourcePtr{};
62 auto cam = CVCapturePtr{
new cv::VideoCapture(which)};
63 if (!cam->isOpened()) {
67 ret.reset(
new OpenCVImageSource{std::move(cam)});
72 bool ret = m_camera->grab();
82 m_camera->retrieve(color);
83 timestamp = m_timestamp;
88 void OpenCVImageSource::storeRes() {
89 int height =
static_cast<int>(m_camera->get(CV_CAP_PROP_FRAME_HEIGHT));
90 int width =
static_cast<int>(m_camera->get(CV_CAP_PROP_FRAME_WIDTH));
91 m_res = cv::Size(width, height);
void getNow(TimeValue &tv)
Set the given TimeValue to the current time.
cv::Size resolution() const override
Get resolution of the images from this source.
void retrieveColor(cv::Mat &color, osvr::util::time::TimeValue ×tamp) override
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...