Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClientKit: Remove dependency on OpenCV from Imaging. #210

Merged
merged 5 commits into from
Nov 6, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update Imaging sample to work with the OpenCVTypeDispatch directly.
  • Loading branch information
CrossVR committed Nov 3, 2015
commit 77a459e10bbd83d99c1a8d754bb22d9fb3e6af96
14 changes: 10 additions & 4 deletions examples/clients/Imaging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <osvr/ClientKit/Context.h>
#include <osvr/ClientKit/Interface.h>
#include <osvr/ClientKit/Imaging.h>
#include <osvr/Util/OpenCVTypeDispatch.h>

// Library/third-party includes
#include <opencv2/highgui/highgui.hpp>
Expand All @@ -44,19 +45,24 @@ bool gotSomething = false;
void imagingCallback(void *userdata,
osvr::util::time::TimeValue const &timestamp,
osvr::clientkit::ImagingReport report) {
if (report.frame.empty()) {
// Convert the image pointer into an OpenCV matrix.
cv::Mat frame(report.metadata.height, report.metadata.width,
osvr::util::computeOpenCVMatType(report.metadata),
report.buffer.get());

if (frame.empty()) {
std::cout << "Error, frame empty!" << std::endl;
return;
}

/// The first time, let's print some info.
if (!gotSomething) {
gotSomething = true;
std::cout << "Got first report: image is " << report.frame.cols << "x"
<< report.frame.rows << std::endl;
std::cout << "Got first report: image is " << frame.cols << "x"
<< frame.rows << std::endl;
}

cv::imshow(windowNameAndInstructions, report.frame);
cv::imshow(windowNameAndInstructions, frame);
osvr::clientkit::ImagingReport &lastReport =
*static_cast<osvr::clientkit::ImagingReport *>(userdata);
lastReport = report;
Expand Down