印章检查
使用 ComPDFKit Document AI 的印章检查工具,您可以检查图像中的所有印章。以下示例展示了如何上传 JPG 文件并使用 Java、PHP、C#、Python 和 Swift 编程语言运行印章检查功能。然后,输出 JSON 文件。
Java
// Create a client
CPDFClient client = new CPDFClient(publicKey,secretKey);
// Create a task
// Create an example of a DocumentAI Stamp Inspection task
CPDFCreateTaskResult result = client.createTask(CPDFDocumentAIEnum.DETECTIONSTAMP);
// Get a task id
String taskId = result.getTaskId();
// File handling parameter settings
CPDFStampInspectionParameter fileParameter = new CPDFStampInspectionParameter();
// Upload files
client.uploadFile(new File("test.jpg"), taskId, fileParameter);
// Execute task
client.executeTask(taskId);
// Query TaskInfo
CPDFTaskInfoResult taskInfo = client.getTaskInfo(taskId);
PHP
// Create a client
$client = new CPDFClient('public_key', 'secret_key');
// Create a task
// Create an example of a DocumentAI Stamp Inspection task
$taskInfo = $client->createTask(CPDFDocumentAI::DETECTIONSTAMP);
//Upload files
$fileInfo = $client->addFile('test.jpg')->uploadFile($taskInfo['taskId']);
//Execute task
$client->executeTask($taskInfo['taskId']);
//Query TaskInfo
$taskInfo = $client->getTaskInfo($taskInfo['taskId']);
C#
// Create a client
CPDFClient client = new CPDFClient(publicKey,secretKey);
// Create a task
// Create an example of a DocumentAI Stamp Inspection task
CPDFCreateTaskResult result = client.CreateTask(CPDFDocumentAIEnum.DETECTIONSTAMP);
// Get a task id
string taskId = result.TaskId;
// File handling parameter settings
CPDFStampInspectionParameter fileParameter = new CPDFStampInspectionParameter();
// Upload files
client.UploadFile(new FileInfo("test.jpg"), taskId, fileParameter);
// Execute task
client.ExecuteTask(taskId);
// Query TaskInfo
CPDFTaskInfoResult taskInfo = client.GetTaskInfo(taskId);
Python
# Create a client
client = CPDFClient(public_key, secret_key)
# Create a task
# Create an example of a DocumentAI Stamp Inspection task
create_task_result = client.create_task(CPDFDocumentAIEnum.DETECTIONSTAMP)
# Get a task id
task_id = create_task_result.task_id
# File handling parameter settings
file_parameter = CPDFStampInspectionParameter()
# Upload files
client.upload_file('test.jpg', task_id, file_parameter)
# Execute task
client.execute_task(task_id)
# Query TaskInfo
task_info = client.get_task_info(task_id)
Swift
// Create a client
let client: CPDFClient = CPDFClient(publicKey: public_key, secretKey: secret_key)
Task { @MainActor in
// Create a task
// Create an example of a DocumentAI Stamp Inspection task
let taskModel = await client.createTask(url: CPDFDocumentAI.DETECTIONSTAMP)
// Get a task id
let taskId = taskModel?.taskId ?? ""
// Upload files
let path = Bundle.main.path(forResource: "test2", ofType: "jpg")
let uploadFileModel = await client.uploadFile(filepath: path ?? "", params: [:], taskId: taskId)
// Execute task
let _ = await client.processFiles(taskId: taskId)
// Query TaskInfo
let taskInfoModel = await client.getTaskInfo(taskId: taskId)
}
结果:
文件类型 | 说明 |
---|---|
.json | 邮票检测结果。 |
内容:
参数 | 说明 |
---|---|
cost | 表单识别所花费的时间。 |
boxes | 输入图像中所有检测到的对象框的位置。 |
labels | 检测到的对象的标签。 |
scores | 分数越高,结果越可靠。 |