Class: Mindee::Extraction::MultiReceiptsExtractor
- Inherits:
-
Object
- Object
- Mindee::Extraction::MultiReceiptsExtractor
- Defined in:
- lib/mindee/extraction/multi_receipts_extractor/multi_receipts_extractor.rb
Overview
Multi-receipts extraction class wrapper.
Class Method Summary collapse
Class Method Details
.extract_receipts(input_source, inference) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mindee/extraction/multi_receipts_extractor/multi_receipts_extractor.rb', line 10 def self.extract_receipts(input_source, inference) # Extracts individual receipts from multi-receipts documents. # # @param input_source [LocalInputSource] Local Input Source to extract sub-receipts from. # @param inference [Inference] Results of the inference. # @return [Array<ExtractedImage>] Individual extracted receipts as an array of ExtractedMultiReceiptsImage. images = [] raise 'No possible receipts candidates found for MultiReceipts extraction.' unless inference.prediction.receipts (0...input_source.count_pdf_pages).each do |page_id| receipt_positions = inference.pages[page_id].prediction.receipts.map(&:bounding_box) images.concat( Mindee::Extraction::ImageExtractor.extract_multiple_images_from_source(input_source, page_id + 1, receipt_positions) ) end images end |