フィルターのクリア

Converting the label info in .txt file to .mat file

23 ビュー (過去 30 日間)
gaurav
gaurav 2024 年 4 月 9 日
回答済み: Chandrika 2024 年 7 月 19 日 14:29
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
cui,xingxing 2024 年 4 月 9 日
Can you briefly share a txt to mat file that best describes the problem?
gaurav
gaurav 2024 年 4 月 9 日
I have a lidar dataset whoose labels are in txt format and I want to perform perform object detection using complex yolo documentation which need the labels in .mat format but i am not able to do so.
Is it possible to convert these txt files into a single mat file.
Or do I need to make changes in the code so it will be able to take txt file as input for label info if so can you provide me with any example of same

サインインしてコメントする。

回答 (1 件)

Chandrika
Chandrika 2024 年 7 月 19 日 14:29
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:
I hope you find the suggested workaround useful!
Regards,
Chandrika

カテゴリ

Help Center および File ExchangeLabeling, Segmentation, and Detection についてさらに検索

タグ

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by