Converting the label info in .txt file to .mat file
4 ビュー (過去 30 日間)
古いコメントを表示
i have label info of lidar data in txt format and there are more than 2500 files i want to convert to .mat file for to be able to use it in matlab for object detection using this Lidar Object Detection Using Complex-YOLO v4 Network.
So please help me with this.
2 件のコメント
cui,xingxing
2024 年 4 月 9 日
Can you briefly share a txt to mat file that best describes the problem?
回答 (1 件)
Chandrika
2024 年 7 月 19 日
Hello Gaurav,
For converting a set of ".txt" files containing label information of your lidar data into ".mat" format, you may read the ".txt" files using the "readmatrix" function and then save the data into ".mat" format. For your reference on the same, I am attaching below a sample code snippet:
% Define the folders containing the ".txt" files and ".mat" files
txtFolder = 'path_to_folder_having_txt_files';
matFolder = 'path_to_folder_to_save_mat_files';
% Create a destination folder to save the ".mat" files
if ~exist(matFolder, 'dir')
mkdir(matFolder);
end
txtFiles = dir(fullfile(txtFolder, '*.txt'));
% Loop through each TXT file, read the data, and save it as a MAT file
for i = 1:length(txtFiles)
txtFilePath = fullfile(txtFolder, txtFiles(i).name);
% Read the data from the ".txt" file using "readmatrix" funcion
labelData = readmatrix(txtFilePath);
[~, name, ~] = fileparts(txtFiles(i).name);
matFilePath = fullfile(matFolder, [name, '.mat']);
% Save the label data into a ".mat" file
save(matFilePath, 'labelData');
end
For more information on the "readmatrix" and "save" functions, you may refer the following MathWorks documentation links:
- https://www.mathworks.com/help/matlab/ref/readmatrix.html
- https://www.mathworks.com/help/matlab/ref/save.html
I hope you find the suggested workaround useful!
Regards,
Chandrika
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!