Cannot find files or folders matching: 'recycle10​1\project\​aluminiumc​an'.

5 次查看(过去 30 天)
clc
clear all; close all;
outputFolder=fullfile('recycle101');
rootFolder=fullfile(outputFolder,'project');
categories={'aluminiumcan','petbottles','drinkcartonbox'};
imds=imageDatastore(fullfile(rootFolder,categories),'LabelSource','foldernames');
tbl=countEachLabel(imds)
Error:
>> imds=imageDatastore(fullfile(rootFolder,categories),'LabelSource','foldernames');
tbl=countEachLabel(imds)
Error using imageDatastore
Cannot find files or folders matching: 'recycle101\project\aluminiumcan'.
  4 个评论
Tan
Tan 2023-5-13
but my MATLAB install at hard-disk and the dataset is saved at local disk.
Does it will affect and get the error as below?
Error using imageDatastore
Cannot find files or folders matching: 'recycle101\project\aluminiumcan'.
Walter Roberson
Walter Roberson 2023-5-13
what does this report?
parts = {'recycle101', 'project', 'aluminiumcan'};
if exist(parts{1}, 'dir')
fprintf('folder "%s" exists!\n', parts{1});
if exists(fullfile(parts{1:2}), 'dir')
fprintf('folder "%s" exists!\n', fullfile(parts{1:2}));
if exists(fulfile(parts{1:3}), 'dir')
fprintf('folder "%s" exists!\n', fullfile(parts{1:3}));
else
fprintf('but could not find subfolder "%s"\n', parts{3});
end
else
fprintf('but could not find subfolder "%s"\n', parts{2});
end
else
fprintf('folder "%s" does not exist in current directory!\n', parts{1});
end

请先登录,再进行评论。

回答(1 个)

Neeraj
Neeraj 2023-5-22
Hello,
The error clearly states that 'imageDatastore' is unable to find the files/folders located at location 'recycle101\project\aluminiumcan'
Please ensure that the relative path: 'recycle101\project\aluminiumcan' exists.
If it does exist, then try to pass the absolute path to the 'imageDatastore' which might look similar to: 'C:\Users\OneDrive\Desktop\recycle101\project\aluminiumcan'
If the absolute path works without any error, then you only need to modify the 'outputFolder' variable as shown below:
clc
clear all; close all;
outputFolder=fullfile('C:\Users\OneDrive\Desktop\recycle101');
rootFolder=fullfile(outputFolder,'project');
categories={'aluminiumcan','petbottles','drinkcartonbox'};
imds=imageDatastore(fullfile(rootFolder,categories),'LabelSource','foldernames');
tbl=countEachLabel(imds)

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by