This API classifies the input image as per batch class identifier provided. This API will depend on the three plugin for completion “CREATE_THUMBNAILS_PLUGIN”, “CLASSIFY_IMAGES_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN”.  If any batch class doesn’t have those plugin then the API will not work.

Request Method POST

Input Parameters

Input Parameter Values Descriptions
batchClassId This value should not be empty and it should be a valid batch class identifier as BC1. This parameter is used for providing batch class identifier on which image classification will be performed.

 

Web Service URL: http://{serverName}:{port}/dcma/rest/classifyImage

Checklist:

  1. Input file should be single page tif/tiff file only.
  2. batchClassId should be valid batch class identifier and must have the plugins “CREATE_THUMBNAILS_PLUGIN”, “CLASSIFY_IMAGES_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN”.

Sample client code using apache commons http client:-

private static void classifyImage() {
		HttpClient client = new HttpClient();
		String url = "http://localhost:8080/dcma/rest/classifyImage";
		PostMethod mPost = new PostMethod(url);
		// Adding tif file for processing
		File file1 = new File("C:\\sample\\US-Invoice.tif");
		Part[] parts = new Part[2];
		try {
			parts[0] = new FilePart(file1.getName(), file1);
			// Adding parameter for batchClassId
			String batch = "BC8";
			parts[1] = new StringPart("batchClassId", batch);
			MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
			mPost.setRequestEntity(entity);
			int statusCode = client.executeMethod(mPost);
			if (statusCode == 200) {
				System.out.println("Web service executed successfully..");
				String responseBody = mPost.getResponseBodyAsString();
				System.out.println(statusCode + " *** " + responseBody);
			} else if (statusCode == 403) {
				System.out.println("Invalid username/password..");
			} else {
				System.out.println(mPost.getResponseBodyAsString());
			}
		} catch (FileNotFoundException e) {
			System.err.println("File not found for processing..");
		} catch (HttpException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (mPost != null) {
				mPost.releaseConnection();
			}
		}
	}

Was this article helpful to you?

Engineering

Comments are closed.