|
28 | 28 | #include <iostream>
|
29 | 29 | #include <signal.h>
|
30 | 30 |
|
31 |
| -//#include <opencv2/opencv.hpp> |
32 |
| - |
| 31 | +#ifdef LIBFREENECT2_OPENCV_FOUND |
| 32 | +#include <opencv2/opencv.hpp> |
| 33 | +#endif |
33 | 34 | #include <libfreenect2/libfreenect2.hpp>
|
34 | 35 | #include <libfreenect2/frame_listener_impl.h>
|
35 | 36 | #include <libfreenect2/threading.h>
|
36 | 37 | #include <libfreenect2/registration.h>
|
37 | 38 | #include <libfreenect2/packet_pipeline.h>
|
| 39 | +#ifdef LIBFREENECT2_WITH_OPENGL_SUPPORT |
| 40 | +#include "viewer.h" |
| 41 | +#endif |
| 42 | + |
38 | 43 |
|
39 | 44 | bool protonect_shutdown = false;
|
40 | 45 |
|
@@ -135,24 +140,34 @@ int main(int argc, char *argv[])
|
135 | 140 |
|
136 | 141 | libfreenect2::Registration* registration = new libfreenect2::Registration(dev->getIrCameraParams(), dev->getColorCameraParams());
|
137 | 142 |
|
| 143 | + Viewer viewer; |
| 144 | + viewer.initialize(); |
| 145 | + |
138 | 146 | while(!protonect_shutdown)
|
139 | 147 | {
|
140 | 148 | listener.waitForNewFrame(frames);
|
141 | 149 | libfreenect2::Frame *rgb = frames[libfreenect2::Frame::Color];
|
142 | 150 | libfreenect2::Frame *ir = frames[libfreenect2::Frame::Ir];
|
143 | 151 | libfreenect2::Frame *depth = frames[libfreenect2::Frame::Depth];
|
144 | 152 |
|
145 |
| - //cv::imshow("rgb", cv::Mat(rgb->height, rgb->width, CV_8UC4, rgb->data)); |
146 |
| - //cv::imshow("ir", cv::Mat(ir->height, ir->width, CV_32FC1, ir->data) / 20000.0f); |
147 |
| - //cv::imshow("depth", cv::Mat(depth->height, depth->width, CV_32FC1, depth->data) / 4500.0f); |
148 |
| - |
149 |
| - registration->apply(rgb,depth,&undistorted,®istered); |
| 153 | + registration->apply(rgb, depth, &undistorted, ®istered); |
150 | 154 |
|
151 |
| - //cv::imshow("undistorted", cv::Mat(undistorted.height, undistorted.width, CV_32FC1, undistorted.data) / 4500.0f); |
152 |
| - //cv::imshow("registered", cv::Mat(registered.height, registered.width, CV_8UC4, registered.data)); |
| 155 | +#if defined(LIBFREENECT2_WITH_OPENGL_SUPPORT) && !defined(LIBFREENECT2_OPENCV_FOUND) |
| 156 | + viewer.addFrame("RGB", rgb); |
| 157 | + viewer.addFrame("ir", ir); |
| 158 | + viewer.addFrame("depth", depth); |
| 159 | + viewer.addFrame("registered", ®istered); |
153 | 160 |
|
154 |
| - int key = 1;//cv::waitKey(1); |
| 161 | + protonect_shutdown = viewer.render(); |
| 162 | +#else |
| 163 | + cv::imshow("rgb", cv::Mat(rgb->height, rgb->width, CV_8UC4, rgb->data)); |
| 164 | + cv::imshow("ir", cv::Mat(ir->height, ir->width, CV_32FC1, ir->data) / 20000.0f); |
| 165 | + cv::imshow("depth", cv::Mat(depth->height, depth->width, CV_32FC1, depth->data) / 4500.0f); |
| 166 | + cv::imshow("undistorted", cv::Mat(undistorted.height, undistorted.width, CV_32FC1, undistorted.data) / 4500.0f); |
| 167 | + cv::imshow("registered", cv::Mat(registered.height, registered.width, CV_8UC4, registered.data)); |
| 168 | + int key = cv::waitKey(1); |
155 | 169 | protonect_shutdown = protonect_shutdown || (key > 0 && ((key & 0xFF) == 27)); // shutdown on escape
|
| 170 | +#endif |
156 | 171 |
|
157 | 172 | listener.release(frames);
|
158 | 173 | //libfreenect2::this_thread::sleep_for(libfreenect2::chrono::milliseconds(100));
|
|
0 commit comments