Borrar filtros
Borrar filtros

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

23 visualizaciones (últimos 30 días)
gaurav
gaurav el 9 de Abr. de 2024
Respondida: Chandrika el 19 de Jul. de 2024 a las 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 comentarios
cui,xingxing
cui,xingxing el 9 de Abr. de 2024
Can you briefly share a txt to mat file that best describes the problem?
gaurav
gaurav el 9 de Abr. de 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

Iniciar sesión para comentar.

Respuestas (1)

Chandrika
Chandrika el 19 de Jul. de 2024 a las 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

Categorías

Más información sobre Labeling, Segmentation, and Detection en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by