> ## Documentation Index
> Fetch the complete documentation index at: https://docs-claimagent.textin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 图像质量检测

> 图像质量检测。检测项: 模糊(blurry)、不完整(un_integrity)、复印件(photocopy)、翻拍(screen_remark)、光斑(light_spot)、扫描件(scan)。


支持两种输入方式(互斥)：

- **方式一**：传 material_id 或 batch_id 指定已上传的材料

- **方式二**：直接上传文件(multipart/form-data 或 file_urls)


同时传文件和 material_id/batch_id 会返回 400 错误。


质检模型参数通过 query string 传递，如 `?blurry_threshold=0.3&un_integrity_threshold=0.7`，参数与上次质检不一致时会重新调用质检模型。



## OpenAPI

````yaml POST /doc-agent/api/v1/capability/image-quality
openapi: 3.0.3
info:
  description: |-
    CapabilityService 独立子能力服务
     提供文件上传、图像质检、材料分类、材料抽取等独立能力，不依赖案件流程。
     通过 batch_id 和 material_id 串联各能力调用。

     ## 典型调用流程
     1. 上传文件 → UploadFiles，获得 batch_id 和 material_id 列表
     2. (可选)图像质检 → CheckImageQuality，可独立调用，也可用上传返回的 material_id
     3. (可选)材料分类 → ClassifyMaterial，可独立调用，也可用上传返回的 material_id
     4. 材料抽取 → ExtractMaterial，传入 material_id 列表，返回每个材料的状态和结果
     5. 轮询 → 重复调用 ExtractMaterial 直到所有材料完成，或等待 callback_url 回调
     注: 质检和分类可独立调用，不依赖抽取流程；抽取接口的 material_ids 必须来自上传接口。
     注: ExtractMaterial 幂等，已完成的材料不会重新抽取，失败的材料会自动重试。

     ## 错误响应
     所有接口错误均返回 HTTP 非 200 状态码，body 格式: {"code": 400, "msg": "错误描述"}
     常见错误码:
       400 — 参数校验失败(缺少必填字段、文件数超限等)
       403 — 认证失败(x-ti-app-id 或 x-ti-secret-code 缺失/无效)
       404 — 资源不存在(material_id / batch_id 无效)
       500 — 内部处理异常

     错误响应示例:
       {"code": 404, "msg": "material not found"}
       {"code": 404, "msg": "batch not found"}
       {"code": 400, "msg": "material_ids or batch_id is required"}
       {"code": 400, "msg": "material does not belong to the specified batch"}
       {"code": 400, "msg": "files or file_urls is required"}
       {"code": 400, "msg": "所有材料必须属于同一批次"}
       {"code": 403, "msg": "x-api-key 或 x-ti-app-id/x-ti-secret-code 不能为空"}
  title: CapabilityService API
  version: 0.0.1
servers:
  - url: https://agents.textin.com/
security: []
tags:
  - name: CapabilityService
paths:
  /doc-agent/api/v1/capability/image-quality:
    post:
      tags:
        - CapabilityService
      description: >-
        图像质量检测。检测项:
        模糊(blurry)、不完整(un_integrity)、复印件(photocopy)、翻拍(screen_remark)、光斑(light_spot)、扫描件(scan)。



        支持两种输入方式(互斥)：


        - **方式一**：传 material_id 或 batch_id 指定已上传的材料


        - **方式二**：直接上传文件(multipart/form-data 或 file_urls)



        同时传文件和 material_id/batch_id 会返回 400 错误。



        质检模型参数通过 query string 传递，如
        `?blurry_threshold=0.3&un_integrity_threshold=0.7`，参数与上次质检不一致时会重新调用质检模型。
      operationId: CapabilityService_CheckImageQuality
      parameters:
        - in: header
          name: x-ti-app-id
          required: true
          schema:
            type: string
        - in: header
          name: x-ti-secret-code
          required: true
          schema:
            type: string
      requestBody:
        content:
          multipart/form-data:
            example:
              files: '@门诊收费票据01.png'
              material_id: 8ffe03ce-4714-4b50-8daf-afee06002cc3
            schema:
              properties:
                batch_id:
                  description: 批次 ID(处理批次下所有材料)
                  example: 661be601-65c7-4025-af0f-20d357dfb090
                  type: string
                blurry_threshold:
                  description: >-
                    模糊风险判定阈值。开启模糊检测后，若模型输出的模糊风险分数大于该阈值，则判定图像存在模糊风险(0~1，保留2位小数，默认
                    0.5)
                  example: 0.5
                  format: float
                  type: number
                detection_scope:
                  description: >-
                    检测范围控制参数。0 表示检测图片中的所有主体，只要任一主体存在质量风险，则整体判定为存在风险；1
                    表示仅检测第一个主体的质量风险情况。建议采用 0(默认 0)
                  example: 0
                  format: int32
                  type: integer
                file_urls:
                  description: URL 上传(与 material_id/batch_id 互斥)，JSON 数组格式
                  example: '["https://example.com/file1.pdf"]'
                  type: string
                files:
                  description: 文件二进制上传(支持多文件)
                  format: binary
                  type: string
                light_spot_level:
                  description: >-
                    光斑检测的检测级别控制参数。0 表示优先检测主体边缘与背景区域是否存在光斑；1
                    表示优先检测主体内容区域是否存在光斑，例如文字、印章、人像等区域是否受光斑影响(默认 0)
                  example: 0
                  format: int32
                  type: integer
                light_spot_threshold:
                  description: >-
                    光斑风险判定阈值。开启光斑检测后，若模型输出的光斑风险分数大于该阈值，则判定图像存在光斑风险(0~1，保留2位小数，默认
                    0.5)
                  example: 0.5
                  format: float
                  type: number
                material_id:
                  description: 已上传材料的 ID(处理单个材料，与 files/file_urls 互斥)
                  example: 8ffe03ce-4714-4b50-8daf-afee06002cc3
                  type: string
                photocopy_threshold:
                  description: >-
                    复印件风险判定阈值。开启复印件检测后，若模型输出的复印件风险分数大于该阈值，则判定图像为复印件风险(0~1，保留2位小数，默认
                    0.5)
                  example: 0.5
                  format: float
                  type: number
                scan_threshold:
                  description: >-
                    扫描件风险判定阈值。开启扫描件检测后，若模型输出的扫描件风险分数大于该阈值，则判定图像存在扫描件风险(0~1，保留2位小数，默认
                    0.5)
                  example: 0.5
                  format: float
                  type: number
                screen_remark_threshold:
                  description: >-
                    翻拍风险判定阈值。开启翻拍检测后，若模型输出的翻拍风险分数大于该阈值，则判定图像存在翻拍风险(0~1，保留2位小数，默认
                    0.5)
                  example: 0.5
                  format: float
                  type: number
                un_integrity_level:
                  description: >-
                    完整性检测的检测级别控制参数。0 表示优先检测主体边缘与背景是否完整；1
                    表示优先检测主体内容是否完整，例如文字、印章、人像等区域是否缺失(默认 0)
                  example: 0
                  format: int32
                  type: integer
                un_integrity_threshold:
                  description: >-
                    完整性风险判定阈值。开启完整性检测后，若模型输出的完整性风险分数大于该阈值，则判定图像存在不完整风险。完整性风险检测包括：1.拍摄(因未拍全导致的完整性风险)
                    2.物理遮挡 3.数字遮挡(如马赛克) 4.物理水印(含水印文件的打印件) 5.数字水印(常规水印，如水印相机)
                    6.弯折 7.破损(0~1，保留2位小数，默认 0.5)
                  example: 0.5
                  format: float
                  type: number
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              example:
                code: 200
                data:
                  materials:
                    - material_id: 8ffe03ce-4714-4b50-8daf-afee06002cc3
                      pages:
                        - page: 1
                          risk_details:
                            blurry:
                              reason: []
                              score: 0.4
                              valid: false
                            light_spot:
                              reason: []
                              score: 0
                              valid: false
                            photocopy:
                              reason: []
                              score: 0
                              valid: false
                            scan:
                              reason: []
                              score: 0
                              valid: false
                            screen_remark:
                              reason: []
                              score: 0
                              valid: false
                            un_integrity:
                              reason:
                                - 数字遮挡
                              score: 1
                              valid: true
                          risk_type:
                            - un_integrity
                    - material_id: 27734e23-3482-42a3-98d7-1bdb369118bc
                      pages:
                        - page: 1
                          risk_details:
                            blurry:
                              reason: []
                              score: 0.4
                              valid: false
                            light_spot:
                              reason: []
                              score: 0
                              valid: false
                            photocopy:
                              reason: []
                              score: 0
                              valid: false
                            scan:
                              reason: []
                              score: 0
                              valid: false
                            screen_remark:
                              reason: []
                              score: 0
                              valid: false
                            un_integrity:
                              reason:
                                - 拍摄
                              score: 1
                              valid: true
                          risk_type:
                            - un_integrity
                message: OK
              schema:
                properties:
                  code:
                    description: 业务状态码
                    example: 200
                    type: integer
                  data:
                    $ref: >-
                      #/components/schemas/capability.v1.CapabilityImageQualityResponse
                  message:
                    description: 状态说明
                    example: OK
                    type: string
                type: object
          description: OK
components:
  schemas:
    capability.v1.CapabilityImageQualityResponse:
      properties:
        materials:
          description: 各材料的质检结果
          items:
            $ref: '#/components/schemas/capability.v1.MaterialQualityResult'
          type: array
      type: object
    capability.v1.MaterialQualityResult:
      properties:
        material_id:
          description: 材料 ID
          type: string
        pages:
          description: 各页的质检结果
          items:
            $ref: '#/components/schemas/capability.v1.PageQualityResult'
          type: array
      type: object
    capability.v1.PageQualityResult:
      properties:
        page:
          description: 页码(从 1 开始)
          format: int32
          type: integer
        risk_details:
          allOf:
            - $ref: '#/components/schemas/common.RiskDetails'
          description: 该页的风险详情
        risk_type:
          description: 该页命中的风险类型列表
          enum:
            - blurry
            - un_integrity
            - photocopy
            - screen_remark
            - light_spot
            - scan
          items:
            type: string
          type: array
      type: object
    common.RiskDetails:
      properties:
        blurry:
          allOf:
            - $ref: '#/components/schemas/common.RiskInfo'
          description: 模糊风险
        light_spot:
          allOf:
            - $ref: '#/components/schemas/common.RiskInfo'
          description: 光斑风险
        photocopy:
          allOf:
            - $ref: '#/components/schemas/common.RiskInfo'
          description: 复印件风险
        scan:
          allOf:
            - $ref: '#/components/schemas/common.RiskInfo'
          description: 扫描件风险
        screen_remark:
          allOf:
            - $ref: '#/components/schemas/common.RiskInfo'
          description: 屏幕水印风险
        un_integrity:
          allOf:
            - $ref: '#/components/schemas/common.RiskInfo'
          description: 不完整风险
      type: object
    common.RiskInfo:
      properties:
        reason:
          description: 风险原因（如 "拍摄"、"物理遮挡" 等）
          items:
            type: string
          type: array
        score:
          description: 风险评分（0~1）
          format: float
          type: number
        valid:
          description: 是否存在该风险
          type: boolean
      type: object

````