How to open multiple images sequentially for text extraction and save it in a file
    3 views (last 30 days)
  
       Show older comments
    
    PRACHI Sood
 on 30 Apr 2020
  
    
    
    
    
    Answered: Srivardhan Gadila
    
 on 4 May 2020
            I have some 50 photos which I want to extarct the text out of from, I am saving the extracted text into a text file. Problem is the current code that I am using seems to be opening the image files from the folder randomly. How do I make sure that image file opens sequentially ?
location= 'file_path\*.jpg';
ds = imageDatastore(location);
fid = fopen('noPlate.txt', 'wt');
while hasdata(ds) 
    img = read(ds) ;             % read image from datastore
    ocrResults     = ocr(img)
    recognizedText = ocrResults.Text;
    % This portion of code writes the recognise text
    fprintf(fid,'%s\n', recognizedText);     
    fprintf(fid,'%s\n', '\n');
end
fclose(fid); 
winopen('noPlate.txt')
0 Comments
Accepted Answer
  Srivardhan Gadila
    
 on 4 May 2020
        I think the read(ds) reads the files in the datastore in the order ds.Files{1}, ds.Files{2}, ds.Files{3}...........so on.
Once try checking the following:
subplot(1,2,1);imshow(read(ds));subplot(1,2,2);imshow(ds.Files{1});sgtitle(ds.Files{1})
subplot(1,2,1);imshow(read(ds));subplot(1,2,2);imshow(ds.Files{2});sgtitle(ds.Files{2})
subplot(1,2,1);imshow(read(ds));subplot(1,2,2);imshow(ds.Files{3});sgtitle(ds.Files{3})
Or
[data,info] = read(ds);
info
0 Comments
More Answers (0)
See Also
Categories
				Find more on Feature Detection and Extraction in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
