-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemo.m
56 lines (48 loc) · 2.2 KB
/
demo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
%//%************************************************************************%
%//%* RGBD to point cloud *%
%//%* *%
%//%* Author: Dr. Preetham Manjunatha *%
%//%* GitHub: https://github.com/preethamam *%
%//%* *%
%//%************************************************************************%
%//%* *%
%//%* University of Southern california, *%
%//%* Los Angeles, California. *%
%//%************************************************************************%
%% Start parameters
%--------------------------------------------------------------------------
clear; close all; clc;
Start = tic;
%% Inputs
%--------------------------------------------------------------------------
% Read the RGB and D images
color = imread("images/redwood_847.png");
depth = imread("images/redwood_847d.png");
% Json filename
json_filename = [];
% Output point cloud filename
file_name = 'output.pcd';
% Camera intrinsics
camera_intrinsic.cx = 319.5;
camera_intrinsic.cy = 239.5;
camera_intrinsic.fx = 525;
camera_intrinsic.fy = 525;
camera_intrinsic.depth_scale = 1000; % Depth scale (constant) to convert mm to m vice-versa
camera_intrinsic.width = 640;
camera_intrinsic.height = 480;
%% Object callback
%--------------------------------------------------------------------------
obj = rgbd2pointcloud(color, depth, camera_intrinsic, json_filename);
[xyz, rgb] = obj.xyz_rgb();
obj.write2file(xyz, rgb, file_name)
%% Display the point cloud
%--------------------------------------------------------------------------
figure;
pcshow('output.pcd', 'VerticalAxis', 'x', 'VerticalAxisDir', 'down')
xlabel("X")
ylabel("Y")
zlabel("Z")
%% End parameters
%--------------------------------------------------------------------------
Runtime = toc(Start);
disp(Runtime);