mirror of
https://github.com/storytold/LiveScan3D.git
synced 2026-10-09 00:09:58 +00:00
Change snake_case to camelCase, removed unused code, change interpolation to INTER_LINEAR, removed .exe files
This commit is contained in:
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -28,15 +28,14 @@ private:
|
||||
k4a_image_t colorImage = NULL;
|
||||
k4a_image_t depthImage = NULL;
|
||||
k4a_image_t pointCloudImage = NULL;
|
||||
k4a_image_t transformed_depth_image = NULL;
|
||||
k4a_image_t transformedDepthImage = NULL;
|
||||
k4a_image_t colorImageInDepth = NULL;
|
||||
k4a_image_t depthImageInColor = NULL;
|
||||
k4a_image_t color_image_downscaled = NULL;
|
||||
int color_image_downscaled_width;
|
||||
int color_image_downscaled_height;
|
||||
k4a_image_t colorImageDownscaled = NULL;
|
||||
int colorImageDownscaledWidth;
|
||||
int colorImageDownscaledHeight;
|
||||
k4a_transformation_t transformation = NULL;
|
||||
k4a_transformation_t transformation_color_downscaled = NULL;
|
||||
cv::Mat color_to_opencv(const k4a_image_t im);
|
||||
k4a_transformation_t transformationColorDownscaled = NULL;
|
||||
void UpdateDepthPointCloud();
|
||||
void UpdateDepthPointCloudForColorFrame();
|
||||
};
|
||||
@@ -16,8 +16,8 @@ AzureKinectCapture::~AzureKinectCapture()
|
||||
k4a_image_release(pointCloudImage);
|
||||
k4a_image_release(colorImageInDepth);
|
||||
k4a_image_release(depthImageInColor);
|
||||
k4a_image_release(transformed_depth_image);
|
||||
k4a_image_release(color_image_downscaled);
|
||||
k4a_image_release(transformedDepthImage);
|
||||
k4a_image_release(colorImageDownscaled);
|
||||
k4a_transformation_destroy(transformation);
|
||||
k4a_device_close(kinectSensor);
|
||||
}
|
||||
@@ -89,20 +89,20 @@ bool AzureKinectCapture::Initialize()
|
||||
|
||||
//We calculate the minimum size that the color Image can be, while preserving its aspect ration
|
||||
float rescaleRatio = (float)calibration.color_camera_calibration.resolution_height / (float)depth_camera_height;
|
||||
color_image_downscaled_height = depth_camera_height;
|
||||
color_image_downscaled_width = calibration.color_camera_calibration.resolution_width / rescaleRatio;
|
||||
colorImageDownscaledHeight = depth_camera_height;
|
||||
colorImageDownscaledWidth = calibration.color_camera_calibration.resolution_width / rescaleRatio;
|
||||
|
||||
//We don't only need the size in pixels of the downscaled color image, but also a new k4a_calibration_t which fits the new
|
||||
//sizes
|
||||
k4a_calibration_t calibration_color_downscaled;
|
||||
memcpy(&calibration_color_downscaled, &calibration, sizeof(k4a_calibration_t));
|
||||
calibration_color_downscaled.color_camera_calibration.resolution_width /= rescaleRatio;
|
||||
calibration_color_downscaled.color_camera_calibration.resolution_height /= rescaleRatio;
|
||||
calibration_color_downscaled.color_camera_calibration.intrinsics.parameters.param.cx /= rescaleRatio;
|
||||
calibration_color_downscaled.color_camera_calibration.intrinsics.parameters.param.cy /= rescaleRatio;
|
||||
calibration_color_downscaled.color_camera_calibration.intrinsics.parameters.param.fx /= rescaleRatio;
|
||||
calibration_color_downscaled.color_camera_calibration.intrinsics.parameters.param.fy /= rescaleRatio;
|
||||
transformation_color_downscaled = k4a_transformation_create(&calibration_color_downscaled);
|
||||
k4a_calibration_t calibrationColorDownscaled;
|
||||
memcpy(&calibrationColorDownscaled, &calibration, sizeof(k4a_calibration_t));
|
||||
calibrationColorDownscaled.color_camera_calibration.resolution_width /= rescaleRatio;
|
||||
calibrationColorDownscaled.color_camera_calibration.resolution_height /= rescaleRatio;
|
||||
calibrationColorDownscaled.color_camera_calibration.intrinsics.parameters.param.cx /= rescaleRatio;
|
||||
calibrationColorDownscaled.color_camera_calibration.intrinsics.parameters.param.cy /= rescaleRatio;
|
||||
calibrationColorDownscaled.color_camera_calibration.intrinsics.parameters.param.fx /= rescaleRatio;
|
||||
calibrationColorDownscaled.color_camera_calibration.intrinsics.parameters.param.fy /= rescaleRatio;
|
||||
transformationColorDownscaled = k4a_transformation_create(&calibrationColorDownscaled);
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> start = std::chrono::system_clock::now();
|
||||
bool bTemp;
|
||||
@@ -144,7 +144,7 @@ bool AzureKinectCapture::AcquireFrame()
|
||||
}
|
||||
|
||||
k4a_image_release(colorImage);
|
||||
k4a_image_release(color_image_downscaled);
|
||||
k4a_image_release(colorImageDownscaled);
|
||||
k4a_image_release(depthImage);
|
||||
|
||||
colorImage = k4a_capture_get_color_image(capture);
|
||||
@@ -155,23 +155,23 @@ bool AzureKinectCapture::AcquireFrame()
|
||||
return false;
|
||||
}
|
||||
|
||||
//We need to resize the color image, so that it's height fits the depth camera height, while preserving the aspect ratio of the color camera
|
||||
//We need to resize the color image, so that it's height fits the depth camera height, while preserving the aspect ratio of the color camera:
|
||||
|
||||
//Convert the k4a_image to an OpenCV Mat
|
||||
cv::Mat cImg = cv::Mat(k4a_image_get_height_pixels(colorImage), k4a_image_get_width_pixels(colorImage), CV_8UC4, k4a_image_get_buffer(colorImage));
|
||||
|
||||
//Resize the k4a_image to the precalculated size. Takes quite along time, maybe there is a faster algorithm?
|
||||
cv::resize(cImg, cImg, cv::Size(color_image_downscaled_width, color_image_downscaled_height), cv::INTER_NEAREST);
|
||||
cv::resize(cImg, cImg, cv::Size(colorImageDownscaledWidth, colorImageDownscaledHeight), cv::INTER_LINEAR);
|
||||
|
||||
//Create a k4a_image from the resized OpenCV Mat. Code taken from here: https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/978#issuecomment-566002061
|
||||
k4a_image_create(K4A_IMAGE_FORMAT_COLOR_BGRA32, cImg.cols, cImg.rows, cImg.cols * 4 * (int)sizeof(uint8_t), &color_image_downscaled);
|
||||
memcpy(k4a_image_get_buffer(color_image_downscaled), &cImg.ptr<cv::Vec4b>(0)[0], cImg.rows * cImg.cols * sizeof(cv::Vec4b));
|
||||
k4a_image_create(K4A_IMAGE_FORMAT_COLOR_BGRA32, cImg.cols, cImg.rows, cImg.cols * 4 * (int)sizeof(uint8_t), &colorImageDownscaled);
|
||||
memcpy(k4a_image_get_buffer(colorImageDownscaled), &cImg.ptr<cv::Vec4b>(0)[0], cImg.rows * cImg.cols * sizeof(cv::Vec4b));
|
||||
|
||||
|
||||
if (pColorRGBX == NULL)
|
||||
{
|
||||
nColorFrameHeight = k4a_image_get_height_pixels(color_image_downscaled);
|
||||
nColorFrameWidth = k4a_image_get_width_pixels(color_image_downscaled);
|
||||
nColorFrameHeight = k4a_image_get_height_pixels(colorImageDownscaled);
|
||||
nColorFrameWidth = k4a_image_get_width_pixels(colorImageDownscaled);
|
||||
pColorRGBX = new RGB[nColorFrameWidth * nColorFrameHeight];
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ bool AzureKinectCapture::AcquireFrame()
|
||||
|
||||
|
||||
|
||||
memcpy(pColorRGBX, k4a_image_get_buffer(color_image_downscaled), nColorFrameWidth * nColorFrameHeight * sizeof(RGB));
|
||||
memcpy(pColorRGBX, k4a_image_get_buffer(colorImageDownscaled), nColorFrameWidth * nColorFrameHeight * sizeof(RGB));
|
||||
memcpy(pDepth, k4a_image_get_buffer(depthImage), nDepthFrameHeight * nDepthFrameWidth * sizeof(UINT16));
|
||||
|
||||
k4a_capture_release(capture);
|
||||
@@ -194,9 +194,9 @@ bool AzureKinectCapture::AcquireFrame()
|
||||
|
||||
void AzureKinectCapture::UpdateDepthPointCloudForColorFrame()
|
||||
{
|
||||
if (transformed_depth_image == NULL)
|
||||
if (transformedDepthImage == NULL)
|
||||
{
|
||||
k4a_image_create(K4A_IMAGE_FORMAT_DEPTH16, nColorFrameWidth, nColorFrameHeight, nColorFrameWidth * (int)sizeof(uint16_t), &transformed_depth_image);
|
||||
k4a_image_create(K4A_IMAGE_FORMAT_DEPTH16, nColorFrameWidth, nColorFrameHeight, nColorFrameWidth * (int)sizeof(uint16_t), &transformedDepthImage);
|
||||
}
|
||||
|
||||
if (pointCloudImage == NULL)
|
||||
@@ -204,9 +204,9 @@ void AzureKinectCapture::UpdateDepthPointCloudForColorFrame()
|
||||
k4a_image_create(K4A_IMAGE_FORMAT_CUSTOM, nColorFrameWidth, nColorFrameHeight, nColorFrameWidth * 3 * (int)sizeof(int16_t), &pointCloudImage);
|
||||
}
|
||||
|
||||
k4a_transformation_depth_image_to_color_camera(transformation_color_downscaled, depthImage, transformed_depth_image);
|
||||
k4a_transformation_depth_image_to_color_camera(transformationColorDownscaled, depthImage, transformedDepthImage);
|
||||
|
||||
k4a_transformation_depth_image_to_point_cloud(transformation_color_downscaled, transformed_depth_image, K4A_CALIBRATION_TYPE_COLOR, pointCloudImage);
|
||||
k4a_transformation_depth_image_to_point_cloud(transformationColorDownscaled, transformedDepthImage, K4A_CALIBRATION_TYPE_COLOR, pointCloudImage);
|
||||
}
|
||||
|
||||
void AzureKinectCapture::UpdateDepthPointCloud()
|
||||
@@ -264,7 +264,7 @@ void AzureKinectCapture::MapDepthFrameToColorSpace(UINT16 *pDepthInColorSpace)
|
||||
&depthImageInColor);
|
||||
}
|
||||
|
||||
k4a_transformation_depth_image_to_color_camera(transformation_color_downscaled, depthImage, depthImageInColor);
|
||||
k4a_transformation_depth_image_to_color_camera(transformationColorDownscaled, depthImage, depthImageInColor);
|
||||
|
||||
memcpy(pDepthInColorSpace, k4a_image_get_buffer(depthImageInColor), nColorFrameHeight * nColorFrameWidth * (int)sizeof(uint16_t));
|
||||
}
|
||||
@@ -278,19 +278,9 @@ void AzureKinectCapture::MapColorFrameToDepthSpace(RGB* pColorInDepthSpace)
|
||||
&colorImageInDepth);
|
||||
}
|
||||
|
||||
k4a_transformation_color_image_to_depth_camera(transformation_color_downscaled, depthImage, colorImage, colorImageInDepth);
|
||||
k4a_transformation_color_image_to_depth_camera(transformationColorDownscaled, depthImage, colorImage, colorImageInDepth);
|
||||
|
||||
memcpy(pColorInDepthSpace, k4a_image_get_buffer(colorImageInDepth), nDepthFrameHeight * nDepthFrameWidth * 4 * (int)sizeof(uint8_t));
|
||||
}
|
||||
|
||||
|
||||
|
||||
cv::Mat AzureKinectCapture::color_to_opencv(const k4a_image_t im)
|
||||
{
|
||||
cv::Mat cv_image_with_alpha(k4a_image_get_height_pixels(im), k4a_image_get_width_pixels(im), CV_8UC4, k4a_image_get_buffer(im));
|
||||
cv::Mat cv_image_no_alpha;
|
||||
cv::cvtColor(cv_image_with_alpha, cv_image_no_alpha, cv::COLOR_BGRA2BGR);
|
||||
return cv_image_no_alpha;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user