MCPcopy Create free account
hub / github.com/OpenKinect/libfreenect2 / record

Method record

tools/streamer_recorder/recorder.cpp:89–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void Recorder::record(libfreenect2::Frame* frame, const std::string& frame_type)
90{
91 if(frame_type == "depth")
92 {
93 // std::cout << "Run Recorder." << std::endl;
94 cvMat_frame = cv::Mat(frame->height, frame->width, CV_32FC1, frame->data) / 10;
95 // TODO: handle relative path + check Windows / UNIX compat.
96 oss_recordPath << "../recordings/depth/" << std::setw( 5 ) << std::setfill( '0' ) << frameID << ".depth";
97 }
98 else if (frame_type == "registered" || frame_type == "rgb")
99 {
100 cvMat_frame = cv::Mat(frame->height, frame->width, CV_8UC4, frame->data);
101 // TODO: handle relative path + check Windows / UNIX compat.
102 oss_recordPath << "../recordings/regist/" << std::setw( 5 ) << std::setfill( '0' ) << frameID << ".jpg";
103 // std::cout << frame->height << ":" << frame->width << ":" << frame->bytes_per_pixel << std::endl;
104 }
105
106 recordPath = oss_recordPath.str();
107
108 // SAVE IMAGE
109 cv::imwrite(recordPath, cvMat_frame, img_comp_param); //write the image to file
110 // std::cout << recordPath << std::endl;
111
112 // show image
113 // cv::namedWindow( "recorded frame", CV_WINDOW_AUTOSIZE);
114 // cv::imshow("recorded frame", cvMat_frame);
115 // cv::waitKey(0);
116
117 // reset ostr
118 oss_recordPath.str("");
119 oss_recordPath.clear();
120
121 // feedback on current recording state
122 if(frameID % 100 == 0)
123 std::cout << "-> " << frameID << "/" << MAX_FRAME_ID << " recorded frames/maxFrameID (" << frame_type << ")" << std::endl;
124
125 /////// RECORD VIDEO, NOT READY YET (RECORD IMAGE FOR NOW) ///////
126
127 // cv::Mat frame_depth = cv::Mat(depth->height, depth->width, CV_32FC1, depth->data) / 4500.0f;
128 // cv::convertScaleAbs(frame_depth, frame_depth);
129
130 // DISPLAY INFOS
131 // std::cout << "kinect (h,w): " << depth->height << "," << depth->width << std::endl;
132
133 // cv::Size s = frame_depth.size();
134 // double rows = s.height;
135 // double cols = s.width;
136 // std::cout << "cvMat (h,w): " << rows << "," << cols << std::endl;
137
138 // RECORD VIDEO
139 // std::cout << "11111" << std::endl;
140 // std::cout << "Img channels: " << frame_depth.channels() << std::endl;
141 // std::cout << "Img depth: " << frame_depth.depth() << std::endl;
142 // std::cout << "Img type: " << frame_depth.type() << std::endl;
143
144 // frame_depth.convertTo(frame_depth, CV_8UC1); // IPL_DEPTH_8U
145 // cv::cvtColor(frame_depth, frame_depth, CV_GRAY2BGR); // convert image to RGB
146

Callers 1

mainFunction · 0.80

Calls 1

MatClass · 0.85

Tested by

no test coverage detected