Created
December 21, 2014 13:37
-
-
Save treaded/28ee60bc9b44b3e3991d to your computer and use it in GitHub Desktop.
save image on key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Protonect.cpp.bak 2014-12-21 16:01:41.000000000 +0900 | |
+++ Protonect.cpp 2014-12-21 18:26:10.000000000 +0900 | |
@@ -38,6 +38,11 @@ | |
bool shutdown = false; | |
+cv::Mat mat_ir_raw; | |
+cv::Mat mat_ir; | |
+cv::Mat mat_depth_raw; | |
+cv::Mat mat_depth; | |
+ | |
void sigint_handler(int s) | |
{ | |
shutdown = true; | |
@@ -91,6 +96,31 @@ | |
cv::imshow("depth", cv::Mat(depth->height, depth->width, CV_32FC1, depth->data) / 4500.0f); | |
int key = cv::waitKey(1); | |
+ //std::cout << "key: " << key << std::endl; | |
+ // p:112, i:105, d:100, r:114 | |
+ if (key > 0 && ((key & 0xFF) == 114)) { | |
+ // save "rgb" image | |
+ if (cv::imwrite("rgb.jpg", cv::Mat(rgb->height, rgb->width, CV_8UC3, rgb->data))) { | |
+ std::cout << "rgb image saved" << std::endl; | |
+ } | |
+ } else if (key > 0 && ((key & 0xFF) == 105)) { | |
+ // save "ir" image | |
+ //if (cv::imwrite("ir.jpg", cv::Mat(ir->height, ir->width, CV_32FC1, ir->data) / 20000.0f)) { | |
+ mat_ir_raw = cv::Mat(ir->height, ir->width, CV_32FC1, ir->data) / 20000.0f; | |
+ mat_ir_raw.convertTo(mat_ir, CV_8UC1, 255.0); | |
+ if (cv::imwrite("ir.jpg", mat_ir)) { | |
+ std::cout << "ir image saved" << std::endl; | |
+ } | |
+ } else if (key > 0 && ((key & 0xFF) == 100)) { | |
+ // save "depth" image | |
+ //if (cv::imwrite("depth.jpg", cv::Mat(depth->height, depth->width, CV_32FC1, depth->data) / 4500.0f)) { | |
+ mat_depth_raw = cv::Mat(depth->height, depth->width, CV_32FC1, depth->data) / 4500.0f; | |
+ mat_depth_raw.convertTo(mat_depth, CV_8UC1, 255.0); | |
+ if (cv::imwrite("depth.jpg", mat_depth)) { | |
+ std::cout << "depth image saved" << std::endl; | |
+ } | |
+ } | |
+ | |
shutdown = shutdown || (key > 0 && ((key & 0xFF) == 27)); // shutdown on escape | |
listener.release(frames); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment