reading "depth raw12" file from ToF camera

3 ビュー (過去 30 日間)
ran shmulevitch
ran shmulevitch 2022 年 5 月 31 日
回答済み: Amish 2025 年 2 月 6 日 11:04
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

回答 (1 件)

Amish
Amish 2025 年 2 月 6 日 11:04
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!

カテゴリ

Help Center および File ExchangeMATLAB Support Package for IP Cameras についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by