Effacer les filtres
Effacer les filtres

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

23 vues (au cours des 30 derniers jours)
gaurav
gaurav le 9 Avr 2024
Réponse apportée : Chandrika le 19 Juil 2024 à 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 commentaires
cui,xingxing
cui,xingxing le 9 Avr 2024
Can you briefly share a txt to mat file that best describes the problem?
gaurav
gaurav le 9 Avr 2024
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

Connectez-vous pour commenter.

Réponses (1)

Chandrika
Chandrika le 19 Juil 2024 à 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

Catégories

En savoir plus sur Labeling, Segmentation, and Detection dans Help Center et File Exchange

Tags

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by