OpenKinect / libfreenect2

Open source drivers for the Kinect for Windows v2 device
2.08k stars 752 forks source link

Differentiating the 9 available phase matrix from each other #1059

Closed HIMA-MB02 closed 5 years ago

HIMA-MB02 commented 5 years ago

We have written a code for getting the raw phase images for the depth matrix, but we are unable to identify each individual phase image matrix from each other. Which variable stores these 9 raw phase images and how do we obtain them individually.

`bool protonect_shutdown = false;

int main(int argc, char argv[]) { //Defining structures libfreenect2::Freenect2 freenect2; libfreenect2::Freenect2Device dev = 0; libfreenect2::PacketPipeline *pipeline = 0;

//Defining Variables bool enable_rgb = false; bool enable_depth = true; int framecount = 0; int framemax = 1; cv::string serial; cv::Mat depthmat;

//Enumerating kinectv2 devices if (freenect2.enumerateDevices() == 0) { std::cout << "no device connected!" << std::endl; return -1; } if (serial == "") { serial = freenect2.getDefaultDeviceSerialNumber(); }

//Creating CPU pipeline pipeline = new libfreenect2::CpuPacketPipeline();

//Open Device dev = freenect2.openDevice(serial, pipeline);

//Attach Framelisteners to the device to receive images frames int types = 0; if (enable_depth) types |= libfreenect2::Frame::Ir | libfreenect2::Frame::Depth; libfreenect2::SyncMultiFrameListener listener(types); libfreenect2::FrameMap frames; dev->setIrAndDepthFrameListener(&listener);

//Start the device if (!enable_rgb && enable_depth) { if (!dev->start()) return -1; } else { if (!dev->startStreams(enable_rgb, enable_depth)) return -1; } std::cout << "device serial: " << dev->getSerialNumber() << std::endl; std::cout << "device firmware: " << dev->getFirmwareVersion() << std::endl;

//Start receiving frames while (framecount < framemax) { if (!listener.waitForNewFrame(frames, 10 1000)) // 10 sconds { std::cout << "timeout!" << std::endl; return -1; } libfreenect2::Frame depth = frames[libfreenect2::Frame::Depth]; depth->format = libfreenect2::Frame::Raw; cv::Mat(depth->height, depth->width, CV_32FC1, depth->data).copyTo(depthmat); listener.release(frames); cout << " DATA " << depth->height << " DATA " << depth->width << endl; framecount++; }

//Stop the device dev->stop(); dev->close(); } `

floe commented 5 years ago

See discussion in #821.