| 42 | bool gotSomething = false; |
| 43 | |
| 44 | void imagingCallback(void *userdata, |
| 45 | osvr::util::time::TimeValue const ×tamp, |
| 46 | osvr::clientkit::ImagingReportOpenCV report) { |
| 47 | if (report.frame.empty()) { |
| 48 | std::cout << "Error, frame empty!" << std::endl; |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | /// The first time, let's print some info. |
| 53 | if (!gotSomething) { |
| 54 | gotSomething = true; |
| 55 | std::cout << "Got first report: image is " << report.frame.cols << "x" |
| 56 | << report.frame.rows << std::endl; |
| 57 | } |
| 58 | |
| 59 | cv::imshow(windowNameAndInstructions, report.frame); |
| 60 | osvr::clientkit::ImagingReportOpenCV &lastReport = |
| 61 | *static_cast<osvr::clientkit::ImagingReportOpenCV *>(userdata); |
| 62 | lastReport = report; |
| 63 | } |
| 64 | int main() { |
| 65 | osvr::clientkit::ClientContext context("com.osvr.exampleclients.Imaging"); |
| 66 | |