Imagedatastore can not find files
42 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Marina Ghobrial
le 24 Juil 2021
Commenté : Image Analyst
le 24 Juil 2021
Hi,
I keep getting the following errors when I run this code.
Cannot find files or folders matching: 'photos\x'."
I was trying to use ANN to be able to tell different categories. However, for some reason matlab is not reading my images. I tried different methods such as dividing the code down to multiple imds such as
% imds1 = imageDatastore('C:\Users\OneDrive\Desktop\photos\x', 'FileExtensions',{'.HEIC'})
% imds2 = imageDatastore('C:\Users\OneDrive\Desktop\photos\y','FileExtensions',{'.HEIC'})
% imds3 = imageDatastore('C:\Users\OneDrive\Desktop\photos\z','FileExtensions',{'.HEIC'})
% imds4 = imageDatastore('C:\Users\OneDrive\Desktop\photos\a','FileExtensions',{'.HEIC'})
% imds5 = imageDatastore('C:\Users\OneDrive\Desktop\photos\b','FileExtensions',{'.HEIC'})
which was able to read the photos but was not able to determine which category it belonged to.
The code is:
categories = {'x','y','z','a','b'};
rootFolder = 'photos';
imds = imageDatastore (fullfile(rootFolder, categories), ...
'LabelSource',"foldernames", 'IncludeSubfolders',true);
Please Help, Thank you in advance!
0 commentaires
Réponse acceptée
Image Analyst
le 24 Juil 2021
Modifié(e) : Image Analyst
le 24 Juil 2021
Did you look at what the fullfile() returns? Let's pull it out separately and see
categories = {'x','y','z','a','b'};
rootFolder = 'photos';
filePattern = fullfile(rootFolder, categories)
imds = imageDatastore(filePattern, ...
'LabelSource',"foldernames", 'IncludeSubfolders',true);
We see
ans =
1×5 cell array
{'photos\x'} {'photos\y'} {'photos\z'} {'photos\a'} {'photos\b'}
so as you can see, those are not full folder names with drive and everything, so it's not able to find the files.
4 commentaires
Image Analyst
le 24 Juil 2021
You're welcome. Glad it worked. Could you please click the "Accept this answer" link?
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Entering Commands dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!