Fx.AI: Handle AI-related APIs
1. Image recognition
Fx.AI.detectPic(<String modelId>, <String path>)
Parameter Description
| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| modelId | String | The unique ID of the object recognition model |
| path | String | image path |
return type
APIResult
Return value description
Map(returns the product data identified by the image) Return value example: {"path":"N_202006_09_87e2be5f5c364bda9cb5ed61a21ddd25","objectList":[{"apiName":"ProductObj","dataId":"5d3bbf1e7cfed965a54daf70","position":{ "x":532.0,"y":756.0,"w":78.0,"h":146.0},"score":"0.9921149611473083","color":"C91F25"},{"apiName":"ProductObj" ,"dataId":"5d3bbf1e7cfed965a54daf72","position":{"x":220.0,"y":761.0,"w":86.0,"h":72.0},"score":"0.9953563809394836","color" :"3DD4C4"},{"apiName":"ProductObj","dataId":"5d3bbf1e7cfed965a54daf72","position":{"x":327.0,"y":840.0,"w":82.0,"h": 62.0},"score":"0.9940695762634277","color":"3DD4C4"},{"apiName":"ProductObj","dataId":"5d3bbe347cfed965a54dacb7","position":{"x":475.0,"y ":942.0,"w":81.0,"h":77.0},"score":"0.9963515996932983","color":"3F3F98"}]}
Java example
APIResult ret = Fx.AI.detectPic("5dabce96e75d9594e1dc05f6", "N_202006_09_87e2be5f5c364bda9cb5ed61a21ddd25");
Groovy example
def ret = Fx.AI.detectPic("5dabce96e75d9594e1dc05f6", "N_202006_09_87e2be5f5c364bda9cb5ed61a21ddd25")
Precautions
- The enterprise can only use it if it has a model
2. Invoice verification
Fx.AI.invoiceValidation(<InvoiceData invoice>)
Parameter Description
| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| invoice | InvoiceData | See below for details |
return type
APIResult
Return value description
Invoice information that needs to be verified, including: invoice type; invoice code; invoice number; invoice date; invoice amount; the last 6 digits of the invoice verification code; supported invoice typesInvoice: elec_special_vat_invoice Normal VAT invoice: normal_invoice Normal VAT invoice (electronic): elec_normal_invoice Normal VAT invoice (roll): roll_normal_invoice Electronic general VAT invoice for tolls: toll_elec_normal_invoice Special VAT invoice for freight transport: special_freight_transport_invoice Motor vehicle sales Invoice: motor_vehicle_invoice Used car sales invoice: used_vehicle_invoice
Java example
InvoiceData invoice = InvoiceData. builder()
.type("elec_normal_invoice")
.code("011002100511")
.number("24830566")
.date("20210620")
.amount("339.62")
.checkCode("957725")
.build();
APIResult ret = Fx.AI.invoiceValidation(invoice);
if (ret. isError()) {
log.info(ret.message());
} else {
log.info("success!");
}
Groovy example
InvoiceData invoice = InvoiceData. builder()
.type("elec_normal_invoice")
.code("011002100511")
.number("24830566")
.date("20210620")
.amount("339.62")
.checkCode("957725")
.build()
def(Boolean error, Object data, String errorMessage) = Fx.AI.invoiceValidation(invoice)
if (error) {
log. info(errorMessage)
} else {
log. info("success!")
}
(1). Refer to InvoiceData
3. Obtain the recognition type supported by ocr
Fx.AI.queryOcrTypes()
return type
APIResult
Return value description
List
Java example
APIResult ret = Fx.AI.queryOcrTypes();
if (ret. isError()) {
log.info(ret.message());
} else {
log.info(ret.getData());
}
4. ocr recognition
Fx.AI.ocrImages(<String ocrType>, <List paths>)
Parameter Description
| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| ocrType | String | ocr type, BankCard: "Bank Card Identification", IdCard: "ID Card Identification", Invoice: "Universal Machine Printed Invoice Identification", Accurate: "Universal Identification Type (High Precision)", Passport: "Passport Identification", VatInvoice: "VAT Invoice Identification", TrainTicket: "Train Ticket", TaxiReceipt: "Taxi Ticket Identification", HouseHoldRegister: "Household Registration" |
| paths | List | Image nPath list |
return type
APIResult
Return value description
Map, identifying knotsfruit
Java example
APIResult ret = Fx.AI.ocrImages("Accurate", Lists.newArrayList("N_202107_29_96131698ed29473bb1d7baac7909eac1.jpg"));
if (ret. isError()) {
log.info(ret.message());
} else {
log.info(ret.getData());
}
Reference class com.fxiaoke.functions.model.InvoiceData
field description
| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| code | String | invoice code |
| number | String | invoice number |
| type | String | invoice type |
| checkCode | String | Invoice check code (last 6 digits), optional |
| date | String | Invoice date: |
| amount | String | Invoice amount (excluding tax) |