How to add images continuously to a imageDatastore

조회 수: 26 (최근 30일)
Chinthaka Amarasinghe
Chinthaka Amarasinghe 2019년 8월 6일
댓글: OJ27 2020년 4월 21일
Hi,
I'm new to the Matlab and using a imageDatastore object to store images comming from a camera, I want to update an existing image data store continuously. Is there a way to do that...?
Thanks..
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 8월 10일
What would this be like if it were available? Normally you create a datastore and loop, hasdata(), read(), process.
Now there are three possibilities:
  1. new images are added to the datastore more quickly than you can process images, and there are an indefinite number of images. In this case you can never get to the end of the data
  2. new images are added faster than you can process, but only for a definite time, after which you can catch up. In this case you could delay starting until all of the images are available
  3. new images are added more slowly than you can process them. In this case you will keep running into the end of the current datastore and will have to know to wait for more
For some of these possibilities I wonder whether you should just occasionally poll the directory for new files and process them. If you are using ms Windows then there is even a way using .NET to set up a callback when new files arrive.

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

채택된 답변

Divya Gaddipati
Divya Gaddipati 2019년 8월 9일
Since the Files and Labels properties of the imageDatastore function return cell array of character vectors, you can directly use these to append/concatenate using the cat function.
For example:
imds = imageDatastore({'street1.jpg','street2.jpg','peppers.png','corn.tif'}); % Existing datastore
imds_new = imageDatastore({'cameraman.tif'}); %to append to the existing datastore
imds_cat = imageDatastore(cat(1, imds.Files, imds_new.Files));
imds_cat.Labels = cat(1, imds.Labels, imds_new.Labels)
imds = imds_cat;
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 8월 9일
What the above does is have an existing datastore, and build a new one with new files and labels, and then extract the information from the two datastore and use it to build a third datastore, after which you would probably delete the other two.
Effectively the only reason to use the first two datastore here is to take advantage of the logic to discover files and labels.
In a situation where you have new files continually being dropped into a directory, then to use the above you would be needing to continually figuring out which files were new compared to the other ones in the directory, which is a process that is likely to involve reading the entire directory again, in which case you might as well just delete the old datastore.
OJ27
OJ27 2020년 4월 21일
what about combining two TransformedDataStores that have image and label information (for segmentation)?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Datastore에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by