use of com.amazonaws.services.textract.AmazonTextract in project aws-doc-sdk-examples by awsdocs.
the class DocumentText method main.
public static void main(String[] arg) throws Exception {
// The S3 bucket and document
String document = "";
String bucket = "";
AmazonS3 s3client = AmazonS3ClientBuilder.standard().withEndpointConfiguration(new EndpointConfiguration("https://s3.amazonaws.com", "us-east-1")).build();
// Get the document from S3
com.amazonaws.services.s3.model.S3Object s3object = s3client.getObject(bucket, document);
S3ObjectInputStream inputStream = s3object.getObjectContent();
BufferedImage image = ImageIO.read(inputStream);
// Call DetectDocumentText
EndpointConfiguration endpoint = new EndpointConfiguration("https://textract.us-east-1.amazonaws.com", "us-east-1");
AmazonTextract client = AmazonTextractClientBuilder.standard().withEndpointConfiguration(endpoint).build();
DetectDocumentTextRequest request = new DetectDocumentTextRequest().withDocument(new Document().withS3Object(new S3Object().withName(document).withBucket(bucket)));
DetectDocumentTextResult result = client.detectDocumentText(request);
// Create frame and panel.
JFrame frame = new JFrame("RotateImage");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
DocumentText panel = new DocumentText(result, image);
panel.setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
}
use of com.amazonaws.services.textract.AmazonTextract in project aws-doc-sdk-examples by awsdocs.
the class AnalyzeDocument method main.
public static void main(String[] arg) throws Exception {
// The S3 bucket and document
String document = "";
String bucket = "";
AmazonS3 s3client = AmazonS3ClientBuilder.standard().withEndpointConfiguration(new EndpointConfiguration("https://s3.amazonaws.com", "us-east-1")).build();
// Get the document from S3
com.amazonaws.services.s3.model.S3Object s3object = s3client.getObject(bucket, document);
S3ObjectInputStream inputStream = s3object.getObjectContent();
BufferedImage image = ImageIO.read(inputStream);
// Call AnalyzeDocument
EndpointConfiguration endpoint = new EndpointConfiguration("https://textract.us-east-1.amazonaws.com", "us-east-1");
AmazonTextract client = AmazonTextractClientBuilder.standard().withEndpointConfiguration(endpoint).build();
AnalyzeDocumentRequest request = new AnalyzeDocumentRequest().withFeatureTypes("TABLES", "FORMS").withDocument(new Document().withS3Object(new S3Object().withName(document).withBucket(bucket)));
AnalyzeDocumentResult result = client.analyzeDocument(request);
// Create frame and panel.
JFrame frame = new JFrame("RotateImage");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
AnalyzeDocument panel = new AnalyzeDocument(result, image);
panel.setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
}
Aggregations