필터 지우기
필터 지우기

Can't load dataset from .mat correctly?

조회 수: 5 (최근 30일)
Maria Rasmussen
Maria Rasmussen 2017년 12월 29일
댓글: Maria Rasmussen 2017년 12월 29일
I have tried to follow this guide in the documentation: https://se.mathworks.com/help/vision/examples/object-detection-using-faster-r-cnn-deep-learning.html#d119e1400 I first load a folder with data locally and save it as .mat.
%%Load image folder and save as .mat
clear;
clc;
addpath(genpath(pwd));
dataFolder = '.../pathtofolder';
if ~isdir(dataFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s',
dataFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(dataFolder, '*.tif');
pngFiles = dir(filePattern);
result = cell(1,100);
for k = 1:length(pngFiles)
baseFileName = pngFiles(k).name;
fullFileName = fullfile(dataFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray= imread(fullFileName);
result{k} = imageArray;
end
save fasterRCNNtestImages.mat result;
And in another script after running the code above, I load it like so:
data = load('fasterRCNNtestImages.mat');
varoaDataset = data.fasterRCNNtestImages;
I have made the code as in the guide, but I seem to be misunderstanding something?
What I want to do is give a bunch of images as input and then "teach" it to search for some specific objects in the images. I could also do this by making a script that sorts objects in the images based on size, but I could not find a could source explaining how this can be done, and since my images are .png it appears to be a bit more tricky. I got the arror 2d image expected when I tried the other option any way and got stuck when I did not seem able to convert png. to another format (.jpg in my trial and error). So CNN seemed the better solution, but now I am stuck again.
  댓글 수: 2
KALYAN ACHARJYA
KALYAN ACHARJYA 2017년 12월 29일
Please clarify where you faced problem Load image from folder or save as .mat
Maria Rasmussen
Maria Rasmussen 2017년 12월 29일
Loading the .mat

댓글을 달려면 로그인하십시오.

채택된 답변

Rik
Rik 2017년 12월 29일
In your code you save the mat file with this line
save fasterRCNNtestImages.mat result;
This creates a mat file with the result variable inside it. However, when you load it, you try to get the variable fasterRCNNtestImages from the file. That isn't what you saved, so it is not there. Using the code below should fix your error.
data = load('fasterRCNNtestImages.mat');
varoaDataset = data.result;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by