Imagedatastore can not find files
조회 수: 42 (최근 30일)
이전 댓글 표시
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
채택된 답변
Image Analyst
2021년 7월 24일
편집: Image Analyst
2021년 7월 24일
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
Image Analyst
2021년 7월 24일
You're welcome. Glad it worked. Could you please click the "Accept this answer" link?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!