Hello. At this point, I have a program that reads images using the 'imread' function, and then processes them.
My Mission: I want the process of reading images from the folder to be automatic. In the folder (from which the program reads images) there is a picture called 'image1'. I want my program to read it from the folder, process it, and then wait for the next image ('image2'), to be uploaded to the folder. When the program detects that the image has been uploaded to a folder, the program reads it, processes it, and waits for the next image ('image3'), and so on.
I tried to solve the problem on my own, using the following program, and it didn't work. Can anyone help me?
for k = 1:5
jpgFilename = sprintf('image%d.jpg', k);
fullFileName = fullfile('C:\fproject\final_project\', jpgFilename);
if exist(fullFileName, 'file') %if the image exist in the folder
rgbImage = imread(fullFileName);
else
k=k-1;
for count=1:15
%wait 20 seconds to the image
pause(1)
if exist(fullFileName, 'file')
break %Exit this loop (return to the main loop)
end
if count==20 % if after 20 seconds the image not exist in folder
k=k+1;
break %try to read the next image
end
end
figure, imshow(rgbImage)
end
Best Answer