how to fix "unrecognized table variable name" error?
109 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hi. i'm running a matlab code that extracts images and forms corresponding bounding boxes, but i get the following error:
"Error using trainextract (line 7)
Unrecognized table variable name 'imds'."
the code is as follows:
clear all
close all
clc
imds = imageDatastore('C:\Users\Muhammad Sanwal\Desktop\COMSATS\The 9th Semester (FA20)\FYP pt 1\MIO-TCD-Localization\train\00000000.jpg');
%%To import data from a CSV file into MATLAB use the “readtable” function. The “readtable” function automatically detects the header and the number of lines to skip
T = readtable('C:\Users\Muhammad Sanwal\Desktop\COMSATS\The 9th Semester (FA20)\FYP pt 1\MIO-TCD-Localization\test1.csv','ReadVariableNames',false);
getdata = T.imds;
the image under test is:
can someone please help me fix this error?
note: if someone will edit this code, he/she would have to write his own location where the image is stored.
the csv file is attached as well.
0 comentarios
Respuestas (2)
Walter Roberson
el 21 de En. de 2021
imds = imageDatastore('C:\Users\Muhammad Sanwal\Desktop\COMSATS\The 9th Semester (FA20)\FYP pt 1\MIO-TCD-Localization\train\00000000.jpg');
%%To import data from a CSV file into MATLAB use the “readtable” function. The “readtable” function automatically detects the header and the number of lines to skip
T = readtable('C:\Users\Muhammad Sanwal\Desktop\COMSATS\The 9th Semester (FA20)\FYP pt 1\MIO-TCD-Localization\test1.csv','ReadVariableNames',false);
[imgfound, imgidx] = ismember(T.Var1, imds.Files);
T.img = cell(height(T),1);
for K = 1 : length(imgfound)
if imgfound(K)
T.img{K} = readimage(imds, imgidx(K));
else
T.img{K} = zeros(0, 0, 3, 'uint8');
end
end
Any image listed in the csv and is present in the imds under the exact same name will have its T.img entry set to the content of the image; any file not located in the imds will have T.img set to an empty RGB image.
2 comentarios
Walter Roberson
el 23 de En. de 2021
T = readtable('test1.csv', 'readvariablenames', false)
T.Var1
It does not come out as double as your error message indicates.
Jeremy Hughes
el 21 de En. de 2021
'ReadVariableNames',false
This tells readtable not to read variable names from the file. So all the variable names will be "Var1","Var2",..., etc.
T.imds is trying to acces the variable named "imds" which doesn't exist.
3 comentarios
Jeremy Hughes
el 21 de En. de 2021
Yes, because "imds" is not a variable name in the table T.
It's hard to say what you need to do next, because it's not clear what data you're trying to get out of that table.
If you want to read the data in the image, you should be calling,
read(imds)
Jeremy Hughes
el 21 de En. de 2021
You might also want to scan https://www.mathworks.com/help/matlab/tables.html
Ver también
Categorías
Más información sobre Image Data Workflows en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!