I'm a newbie for Kinect for Azure. I think Kinect for Azure is great product. I think the class of k4a_image_t is similar to cv::Mat in opencv. For many application for computer vision is coded with cv::mat of opencv. Could you add a transform function of change k4a_image_t to cv::Mat of opencv? I think this will give helps to persons who are familiar with opencv. And Let us easily change many application which are coded with cv::Mat of opencv with Kinect for Azure sensor.
First, get the image buffer from the capture. Then,
For depth, cv::Mat mat = cv::Mat(height, width, CV_16UC1, depth_buffer, AUTO_SETP).clone();
For color, cv::Mat mat = cv::Mat(height, width, CV_8UC4, color_buffer, AUTO_SETP).clone();
Remeber to use clone() or copyTo() to get the copy of the buffer data.
Thank you very much
在 2019-07-29 16:25:34,fanyx notifications@github.com 写道:
First, get the image buffer from the capture. Then,
For depth, cv::Mat mat = cv::Mat(height, width, CV_16UC1, depth_buffer, AUTO_SETP).clone();
For color, cv::Mat mat = cv::Mat(height, width, CV_8UC4, color_buffer, AUTO_SETP).clone();
Remeber to use clone() or copyTo() to get the copy of the buffer data.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
@YuXinFan Thank you for the comment.
@nonlinear1 Thanks for the feedback, yes, I also uses opencv a lot and indeed such helper function can be really helpful. However, to keep the SDK interface clean and not introduce extra dependencies, we provide the raw buffer of the images. User has the freedom to convert the buffer to any format they like. Other than the helper that @YuXinFan kindly provided, you can also take a look this sample:
https://github.com/microsoft/Azure-Kinect-Samples/blob/master/opencv-kinfu-samples/main.cpp, and this helper also can make your ask work
template<typename T> Mat create_mat_from_buffer(T *data, int width, int height, int channels = 1)
{
Mat mat(height, width, CV_MAKETYPE(DataType<T>::type, channels));
memcpy(mat.data, data, width * height * channels * sizeof(T));
return mat;
}
@nonlinear1 Let us know if you have any more questions, or we can close this issue :)
Thank you very much. I think I totally understand this issue and you can close this issue
Most helpful comment
Thank you very much. I think I totally understand this issue and you can close this issue