reading "depth raw12" file from ToF camera

2 Ansichten (letzte 30 Tage)
ran shmulevitch
ran shmulevitch am 31 Mai 2022
Beantwortet: Amish am 6 Feb. 2025
the ToF camera generates a depth map which is exported in a format called "depth raw12". i want to convert the image into a matrix so i can perform aritmatic functions on the 3 dimensional information.
the specific type of camera is Vzense 560C pro . the output file is 3 numbers per row. if needed, i can attach a sample of the output file

Antworten (1)

Amish
Amish am 6 Feb. 2025
Hi Ran,
If you want to convert the "depth raw12" data from your Vzense 560C Pro ToF camera into a matrix for arithmetic operations, you need to understand the format of the data and then parse it accordingly.
Since you mentioned that the output file consists of 3 numbers per row, it's likely that each row represents a pixel's depth information in some encoded format. "Raw12" typically means that each depth value is encoded in 12 bits. You need to decode these values properly to get the actual depth information.
Here is a generic code that you can extend for your use case:
% Read the data file
filename = 'path_to_your_file.txt';
data = readmatrix(filename);
% Assuming the file has 3 columns per row
% If each row corresponds to a single depth value, decode accordingly
rows = data(:, 1);
cols = data(:, 2);
encodedDepth = data(:, 3);
% Decode the depth values assuming they are in a 12-bit format
depthValues = bitshift(encodedDepth, -4); % This is an example for decoding, adjust as per necessary
% size of the depth map
maxRow = max(rows);
maxCol = max(cols);
depthMatrix = zeros(maxRow, maxCol);
for i = 1:length(rows)
depthMatrix(rows(i), cols(i)) = depthValues(i);
end
% Now you can perform arithmetic operations on depthMatrix -
Documentation of the functions mentioned in the above code are:
Hope this helps!

Kategorien

Mehr zu MATLAB Support Package for USB Webcams finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by