1 | initial version |
Managed to produce a depth image using the kinect v1 camera with openCV 4. The issues were :
Wrong pointer assignment creating the cv::Mat
data structure (as pointed out by sjhalayka and berak)
Bug in the openCV library with imshow() when using CV_16UC1 (as pointed out by berak). An upgrade from 4.0.0 to dev libs fixed this (or you can use convertTo()
). Also needed to use waitkey()
with imshow()
.
Correcting the depth callback function in the sample code. The original code (cppview.cpp) created an overlaid of images when using imshow().
Replacing the code fixed the problem, The depth data size should be 16 bits (the rgb data is only 8 bits per channel).
// access kinect depth buffer
void DepthCallback (void* _depth, uint32_t timestamp) {
Mtx::ScopedLock lock(m_depth_mutex);
m_buffer_depth.clear();
uint16_t* call_depth = static_cast<uint16_t*>(_depth);
for (size_t i = 0; i < 640*480 ; i++) {
m_buffer_depth.push_back(call_depth[i]);
}
m_new_depth_frame = true;
}