how to fix "unrecognized table variable name" error?
조회 수: 132 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Walter Roberson
2021년 1월 21일
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.
Jeremy Hughes
2021년 1월 21일
'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
Jeremy Hughes
2021년 1월 21일
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
2021년 1월 21일
You might also want to scan https://www.mathworks.com/help/matlab/tables.html
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!