{
    "openapi": "3.0.0",
    "info": {
        "title": "图像垃圾分类 - API文档",
        "version": "1.0.0",
        "description": "<p>该接口支持垃圾分类图像识别，支持图像base64和图像url（二选一）两种传递资源的方式。如使用图像base64的方式，则使用img参数，其值为图片的base64编码（建议URLEncoder下），大小不超过6M。如使用图片url的方式，则使用imgurl参数，其值应为一个服务稳定的图像url地址。成功识别后返回一个列表，其中包含trust和lajitype参数。trust是图像可信度，单位是百分比，越接近100表示识别结果越可信。lajitype表示垃圾类别，其中0表示为可回收垃圾、1为有毒有害垃圾、2为厨余或湿垃圾、3为其他或干垃圾，4为结果中的未知类型（例如识别到了天空、建筑、明星人物等情况，你可以在前端显示时排除，或者提示非垃圾物品）。<\/p>\n<p>base64编码测试工具：<a href=\"\/demo\/base64\" target=\"_blank\">图片\/base64互转<\/a>、示例源码：<a target=\"_blank\" href=\"https:\/\/www.tianapi.com\/article\/99\">垃圾识别演示代码<\/a>，关键词识别请点击<a target=\"_blank\" href=\"https:\/\/www.tianapi.com\/apiview\/97\">垃圾分类<\/a>接口、<a target=\"_blank\" href=\"https:\/\/www.tianapi.com\/apiview\/107\">垃圾分类搜索热点<\/a>接口。<\/p>"
    },
    "servers": [
        {
            "url": "https:\/\/apis.tianapi.com"
        }
    ],
    "paths": {
        "\/imglajifenlei\/index": {
            "post": {
                "summary": "图像垃圾分类",
                "tags": [
                    "图像垃圾分类"
                ],
                "description": "根据图像查询物品对应的垃圾分类信息",
                "requestBody": {
                    "content": {
                        "application\/x-www-form-urlencoded": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "img": {
                                        "type": "string",
                                        "example": "base64",
                                        "description": "图片base64编码，与imgurl参数二选一"
                                    },
                                    "key": {
                                        "type": "string",
                                        "description": "API密钥"
                                    },
                                    "mode": {
                                        "type": "int",
                                        "example": "0",
                                        "description": "0或空为严格模式，1为模糊模式"
                                    },
                                    "imgurl": {
                                        "type": "string",
                                        "example": "https:\/\/www.tianapi.com\/static\/img\/ocr\/kc.jpg",
                                        "description": "图片URL地址（支持jpg\/png\/bmp格式）"
                                    }
                                },
                                "required": [
                                    "img",
                                    "key"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "成功响应",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "name": {
                                            "type": "string",
                                            "example": "打火机",
                                            "description": "识别物体名称"
                                        },
                                        "trust": {
                                            "type": "int",
                                            "example": 100,
                                            "description": "可信度，单位百分比"
                                        },
                                        "lajitip": {
                                            "type": "string",
                                            "example": "打火机是其它干垃圾，常见包括砖瓦陶瓷、卫生间废纸、猫砂、毛发、一次性制品等......",
                                            "description": "垃圾分类提示"
                                        },
                                        "lajitype": {
                                            "type": "int",
                                            "example": 3,
                                            "description": "垃圾分类，0为可回收、1为有害、2为厨余(湿)、3为其他(干)、4为未知结果"
                                        }
                                    }
                                },
                                "example": {
                                    "msg": "success",
                                    "code": 200,
                                    "result": {
                                        "list": [
                                            {
                                                "name": "打火机",
                                                "trust": 100,
                                                "lajitip": "打火机是其它干垃圾，常见包括砖瓦陶瓷、卫生间废纸、猫砂、毛发、一次性制品等。投放时应尽量沥干水分、平整轻放。",
                                                "lajitype": 3
                                            },
                                            {
                                                "name": "圆珠笔",
                                                "trust": 61,
                                                "lajitip": "圆珠笔是其它干垃圾，常见包括砖瓦陶瓷、卫生间废纸、猫砂、毛发、一次性制品等。投放时应尽量沥干水分、平整轻放。",
                                                "lajitype": 3
                                            },
                                            {
                                                "name": "文具盒",
                                                "trust": 40,
                                                "lajitip": "文具盒是可回收垃圾，常见包括各类废金属、玻璃瓶、饮料瓶、电子产品等。投放时应注意轻投轻放、清洁干燥、避免污染。",
                                                "lajitype": 0
                                            },
                                            {
                                                "name": "化妆品",
                                                "trust": 20,
                                                "lajitip": "化妆品是有毒有害垃圾，常见包括废电池、废油漆桶、各类过期药品等。投放时应注意尽量排空内容物或包裹妥善后投放。",
                                                "lajitype": 1
                                            },
                                            {
                                                "name": "护肤品",
                                                "trust": 0,
                                                "lajitip": "护肤品是其它干垃圾，常见包括砖瓦陶瓷、卫生间废纸、猫砂、毛发、一次性制品等。投放时应尽量沥干水分、平整轻放。",
                                                "lajitype": 3
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}