Hospital_Soldiers

The models below have been created by converting video recordings of the subject into point clouds using computer vision software. The models were then imported into MATLAB and visualized using the following code.

clc;

clear all;

% Path to the PLY file

plyFilePath1 = 'G:\My Drive\Hospital\campaign 2024\incision p2\point clouds\point1.ply';

plyFilePath2 = 'G:\My Drive\Hospital\campaign 2024\incision p2\point clouds\Gal-ad - Cloud.ply';

% Specify the output PLY file path

outputFilePath = 'G:\My Drive\Hospital\campaign 2024\incision p2\point clouds\final\pointCloud.ply';

% Read and rotate the point cloud

Rvector1 = [0,0,90];

Rvector2 = [90,0,0];

rotatedPtCloud1 = readAndRotatePointCloud(plyFilePath1,Rvector1);

rotatedPtCloud2 = readAndRotatePointCloud(plyFilePath2,Rvector2);

displayPointCloud(rotatedPtCloud1);

% displayPointCloud(rotatedPtCloud2);

% Scale the point cloud

scaledPtCloud1 = scalePointCloud (rotatedPtCloud1,1.5);

scaledPtCloud2 = scalePointCloud (rotatedPtCloud2,1);

% Call the function to center the point cloud at (0, 0, 0)

centeredPtCloud1 = centerPointCloud(scaledPtCloud1);

centeredPtCloud2 = centerPointCloud(scaledPtCloud2);

% Define coordinate ranges for filtering (X, Y, Z) for first point cloud

xRange1 = [-3 2];

yRange1 = [-2 1];

zRange1 = [-2 2];

% Filter the point cloud based on specified coordinate ranges

filteredPtCloud2 = filterPointCloud(centeredPtCloud2, xRange1, yRange1, zRange1);

% Translate the point clouds

translationVector1 = [-1.7, 0.5, 1.4];

translationVector2 = [0, 0, 0];

% Call the function to translate the point cloud

translatedPtCloud1 = translatePointCloud(centeredPtCloud1, translationVector1);

translatedPtCloud2 = translatePointCloud(filteredPtCloud2, translationVector2);

% displayPointCloud(translatedPtCloud1);

% displayPointCloud(translatedPtCloud2);

% Combine point clouds

combinedPtCloud = mergePointClouds(translatedPtCloud1, translatedPtCloud2);

displayPointCloud(combinedPtCloud);

% % Save the filtered point cloud

% saveFilteredPointCloud(combinedPtCloud, outputFilePath)

function displayPointCloud(ptCloud)

% Create a figure to display the point cloud

figure;

pcshow(ptCloud);

title('Rotated 3D Point Cloud');

xlabel('X');

ylabel('Y');

zlabel('Z');

grid on;

axis equal; % Equal scaling for all axes

view(3); % Set the default 3D view

en

function combinedPtCloud = mergePointClouds(ptCloud1, ptCloud2)

% Check if both inputs are valid pointCloud objects

if ~isa(ptCloud1, 'pointCloud') || ~isa(ptCloud2, 'pointCloud')

error('Both inputs must be valid pointCloud objects.');

end

% Concatenate the point locations (XYZ coordinates) of both point clouds

combinedPoints = [ptCloud1.Location; ptCloud2.Location];

% Check if both point clouds have color data

if ~isempty(ptCloud1.Color) && ~isempty(ptCloud2.Color)

% Concatenate the color data if both point clouds have colors

combinedColors = [ptCloud1.Color; ptCloud2.Color];

% Create a new point cloud object with the combined points and colors

combinedPtCloud = pointCloud(combinedPoints, 'Color', combinedColors);

else

% If no color data is available, create the point cloud without color

combinedPtCloud = pointCloud(combinedPoints);

end

end

%% Function to save the filtered point cloud to a PLY file

function saveFilteredPointCloud(filteredPtCloud, outputFilePath)

% Save the filtered point cloud to a PLY file

pcwrite(filteredPtCloud, outputFilePath, 'PLYFormat', 'Binary');

disp(['Filtered point cloud saved to: ', outputFilePath]);

end