|
| 1 | +--- |
| 2 | +title: Bill of Lading OCR Java |
| 3 | +category: 622b805aaec68102ea7fcbc2 |
| 4 | +slug: java-bill-of-lading-ocr |
| 5 | +parentDoc: 631a062c3718850f3519b793 |
| 6 | +--- |
| 7 | +The Java OCR SDK supports the [Bill of Lading API](https://platform.mindee.com/mindee/bill_of_lading). |
| 8 | + |
| 9 | +The [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/bill_of_lading/default_sample.jpg) can be used for testing purposes. |
| 10 | + |
| 11 | + |
| 12 | +# Quick-Start |
| 13 | +```java |
| 14 | +import com.mindee.MindeeClient; |
| 15 | +import com.mindee.input.LocalInputSource; |
| 16 | +import com.mindee.parsing.common.AsyncPredictResponse; |
| 17 | +import com.mindee.product.billoflading.BillOfLadingV1; |
| 18 | +import java.io.File; |
| 19 | +import java.io.IOException; |
| 20 | + |
| 21 | +public class SimpleMindeeClient { |
| 22 | + |
| 23 | + public static void main(String[] args) throws IOException, InterruptedException { |
| 24 | + String apiKey = "my-api-key"; |
| 25 | + String filePath = "/path/to/the/file.ext"; |
| 26 | + |
| 27 | + // Init a new client |
| 28 | + MindeeClient mindeeClient = new MindeeClient(apiKey); |
| 29 | + |
| 30 | + // Load a file from disk |
| 31 | + LocalInputSource inputSource = new LocalInputSource(new File(filePath)); |
| 32 | + |
| 33 | + // Parse the file asynchronously |
| 34 | + AsyncPredictResponse<BillOfLadingV1> response = mindeeClient.enqueueAndParse( |
| 35 | + BillOfLadingV1.class, |
| 36 | + inputSource |
| 37 | + ); |
| 38 | + |
| 39 | + // Print a summary of the response |
| 40 | + System.out.println(response.toString()); |
| 41 | + |
| 42 | + // Print a summary of the predictions |
| 43 | +// System.out.println(response.getDocumentObj().toString()); |
| 44 | + |
| 45 | + // Print the document-level predictions |
| 46 | +// System.out.println(response.getDocumentObj().getInference().getPrediction().toString()); |
| 47 | + |
| 48 | + // Print the page-level predictions |
| 49 | +// response.getDocumentObj().getInference().getPages().forEach( |
| 50 | +// page -> System.out.println(page.toString()) |
| 51 | +// ); |
| 52 | + } |
| 53 | + |
| 54 | +} |
| 55 | + |
| 56 | +``` |
| 57 | +# Field Types |
| 58 | +## Standard Fields |
| 59 | +These fields are generic and used in several products. |
| 60 | + |
| 61 | +### BaseField |
| 62 | +Each prediction object contains a set of fields that inherit from the generic `BaseField` class. |
| 63 | +A typical `BaseField` object will have the following attributes: |
| 64 | + |
| 65 | +* **confidence** (`Double`): the confidence score of the field prediction. |
| 66 | +* **boundingBox** (`Polygon`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document. |
| 67 | +* **polygon** (`Polygon`): contains the relative vertices coordinates (`polygon` extends `List<Point>`) of a polygon containing the field in the image. |
| 68 | +* **pageId** (`Integer`): the ID of the page, always `null` when at document-level. |
| 69 | + |
| 70 | +> **Note:** A `Point` simply refers to a List of `Double`. |
| 71 | +
|
| 72 | + |
| 73 | +Aside from the previous attributes, all basic fields have access to a custom `toString` method that can be used to print their value as a string. |
| 74 | + |
| 75 | +### StringField |
| 76 | +The text field `StringField` extends `BaseField`, but also implements: |
| 77 | +* **value** (`String`): corresponds to the field value. |
| 78 | +* **rawValue** (`String`): corresponds to the raw value as it appears on the document. |
| 79 | + |
| 80 | +### DateField |
| 81 | +The date field `DateField` extends `BaseField`, but also implements: |
| 82 | + |
| 83 | +* **value** (`LocalDate`): an accessible representation of the value as a Java object. Can be `null`. |
| 84 | + |
| 85 | +## Specific Fields |
| 86 | +Fields which are specific to this product; they are not used in any other product. |
| 87 | + |
| 88 | +### Carrier Field |
| 89 | +The shipping company responsible for transporting the goods. |
| 90 | + |
| 91 | +A `BillOfLadingV1Carrier` implements the following attributes: |
| 92 | + |
| 93 | +* **name** (`String`): The name of the carrier. |
| 94 | +* **professionalNumber** (`String`): The professional number of the carrier. |
| 95 | +* **scac** (`String`): The Standard Carrier Alpha Code (SCAC) of the carrier. |
| 96 | +Fields which are specific to this product; they are not used in any other product. |
| 97 | + |
| 98 | +### Consignee Field |
| 99 | +The party to whom the goods are being shipped. |
| 100 | + |
| 101 | +A `BillOfLadingV1Consignee` implements the following attributes: |
| 102 | + |
| 103 | +* **address** (`String`): The address of the consignee. |
| 104 | +* **email** (`String`): The email of the shipper. |
| 105 | +* **name** (`String`): The name of the consignee. |
| 106 | +* **phone** (`String`): The phone number of the consignee. |
| 107 | +Fields which are specific to this product; they are not used in any other product. |
| 108 | + |
| 109 | +### Items Field |
| 110 | +The goods being shipped. |
| 111 | + |
| 112 | +A `BillOfLadingV1CarrierItem` implements the following attributes: |
| 113 | + |
| 114 | +* **description** (`String`): A description of the item. |
| 115 | +* **grossWeight** (`Double`): The gross weight of the item. |
| 116 | +* **measurement** (`Double`): The measurement of the item. |
| 117 | +* **measurementUnit** (`String`): The unit of measurement for the measurement. |
| 118 | +* **quantity** (`Double`): The quantity of the item being shipped. |
| 119 | +* **weightUnit** (`String`): The unit of measurement for weights. |
| 120 | +Fields which are specific to this product; they are not used in any other product. |
| 121 | + |
| 122 | +### Notify Party Field |
| 123 | +The party to be notified of the arrival of the goods. |
| 124 | + |
| 125 | +A `BillOfLadingV1NotifyParty` implements the following attributes: |
| 126 | + |
| 127 | +* **address** (`String`): The address of the notify party. |
| 128 | +* **email** (`String`): The email of the shipper. |
| 129 | +* **name** (`String`): The name of the notify party. |
| 130 | +* **phone** (`String`): The phone number of the notify party. |
| 131 | +Fields which are specific to this product; they are not used in any other product. |
| 132 | + |
| 133 | +### Shipper Field |
| 134 | +The party responsible for shipping the goods. |
| 135 | + |
| 136 | +A `BillOfLadingV1Shipper` implements the following attributes: |
| 137 | + |
| 138 | +* **address** (`String`): The address of the shipper. |
| 139 | +* **email** (`String`): The email of the shipper. |
| 140 | +* **name** (`String`): The name of the shipper. |
| 141 | +* **phone** (`String`): The phone number of the shipper. |
| 142 | + |
| 143 | +# Attributes |
| 144 | +The following fields are extracted for Bill of Lading V1: |
| 145 | + |
| 146 | +## Bill of Lading Number |
| 147 | +**billOfLadingNumber**: A unique identifier assigned to a Bill of Lading document. |
| 148 | + |
| 149 | +```java |
| 150 | +System.out.println(result.getDocument().getInference().getPrediction().getBillOfLadingNumber().value); |
| 151 | +``` |
| 152 | + |
| 153 | +## Carrier |
| 154 | +**carrier**([BillOfLadingV1Carrier](#carrier-field)): The shipping company responsible for transporting the goods. |
| 155 | + |
| 156 | +```java |
| 157 | +System.out.println(result.getDocument().getInference().getPrediction().getCarrier().value); |
| 158 | +``` |
| 159 | + |
| 160 | +## Items |
| 161 | +**carrierItems**(List<[BillOfLadingV1CarrierItem](#items-field)>): The goods being shipped. |
| 162 | + |
| 163 | +```java |
| 164 | +for (carrierItemsElem : result.getDocument().getInference().getPrediction().getCarrierItems()) |
| 165 | +{ |
| 166 | + System.out.println(carrierItemsElem.value); |
| 167 | +} |
| 168 | +``` |
| 169 | + |
| 170 | +## Consignee |
| 171 | +**consignee**([BillOfLadingV1Consignee](#consignee-field)): The party to whom the goods are being shipped. |
| 172 | + |
| 173 | +```java |
| 174 | +System.out.println(result.getDocument().getInference().getPrediction().getConsignee().value); |
| 175 | +``` |
| 176 | + |
| 177 | +## Date of issue |
| 178 | +**dateOfIssue**: The date when the bill of lading is issued. |
| 179 | + |
| 180 | +```java |
| 181 | +System.out.println(result.getDocument().getInference().getPrediction().getDateOfIssue().value); |
| 182 | +``` |
| 183 | + |
| 184 | +## Departure Date |
| 185 | +**departureDate**: The date when the vessel departs from the port of loading. |
| 186 | + |
| 187 | +```java |
| 188 | +System.out.println(result.getDocument().getInference().getPrediction().getDepartureDate().value); |
| 189 | +``` |
| 190 | + |
| 191 | +## Notify Party |
| 192 | +**notifyParty**([BillOfLadingV1NotifyParty](#notify-party-field)): The party to be notified of the arrival of the goods. |
| 193 | + |
| 194 | +```java |
| 195 | +System.out.println(result.getDocument().getInference().getPrediction().getNotifyParty().value); |
| 196 | +``` |
| 197 | + |
| 198 | +## Place of Delivery |
| 199 | +**placeOfDelivery**: The place where the goods are to be delivered. |
| 200 | + |
| 201 | +```java |
| 202 | +System.out.println(result.getDocument().getInference().getPrediction().getPlaceOfDelivery().value); |
| 203 | +``` |
| 204 | + |
| 205 | +## Port of Discharge |
| 206 | +**portOfDischarge**: The port where the goods are unloaded from the vessel. |
| 207 | + |
| 208 | +```java |
| 209 | +System.out.println(result.getDocument().getInference().getPrediction().getPortOfDischarge().value); |
| 210 | +``` |
| 211 | + |
| 212 | +## Port of Loading |
| 213 | +**portOfLoading**: The port where the goods are loaded onto the vessel. |
| 214 | + |
| 215 | +```java |
| 216 | +System.out.println(result.getDocument().getInference().getPrediction().getPortOfLoading().value); |
| 217 | +``` |
| 218 | + |
| 219 | +## Shipper |
| 220 | +**shipper**([BillOfLadingV1Shipper](#shipper-field)): The party responsible for shipping the goods. |
| 221 | + |
| 222 | +```java |
| 223 | +System.out.println(result.getDocument().getInference().getPrediction().getShipper().value); |
| 224 | +``` |
| 225 | + |
| 226 | +# Questions? |
| 227 | +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) |
0 commit comments