# fisheye_api **Repository Path**: study-cooperation/fisheye_api ## Basic Information - **Project Name**: fisheye_api - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-02-05 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 演示 ## 下载项目 我们定义一个根目录 `APP_ROOT`。 使用在命令行输入如下代码获取程序源码。 ```bash git clone https://gitee.com/study-cooperation/fisheye_api.git APP_ROOT ``` 检测程序返回的 `json_string` 的格式满足《天诺&湖大鱼眼图片相关API文档》的说明。 数据和模型获取请看 `data/README.md`。 ## 低密度(展厅) 低密度使用函数 `predict_low_density_image` 进行预测,我们封装了一个编码函数 `image_encode_base64` 和一个解码函数 `image_decode_base64`, 建议使用。 ```python import json import cv2 from APP_ROOT import predict_low_density_image from APP_ROOT import image_decode_base64 json_string = predict_low_density_image('http://ovuhjq3qc.bkt.clouddn.com/2017-11-16%2017:20:22-920-.png', # 图像路径或者url "{'1': [{'x': 0.1010, 'y': 0.2010}, {'x': 0.3010, 'y': 0.4010}, {'x':0.5010, 'y': 0.6010}, {'x': 0.7010,'y':0.8010}]}", # roi need_return_image=True, # 是否返回画出标注的图像 visual_whole_person=False # 是否标记整个人,False表示只标注靠近人的脚部 ) # 将string对象加载为字典 json_string = json.loads(json_string) # 解码图像并显示 img = image_decode_base64(json_string['pic_base64']) cv2.imshow('result', img) cv2.waitKey(0) ``` ## 低密度(展厅) 实现计算Recall和Precision, **其预测值和真实值的计算算法由我们实现**,代码在 `utils/eval.py` 的 `eval_detect_result` 函数。 原图和标注必须全部放在同一个文件夹下,原图的名字必须和对应的标注同名, 标注文件在这里使用的是PASCAL VOC数据的格式。 ```python from APP_ROOT import predict_with_recall_precision predict_with_recall_precision(root='/path/to/test/data', output='/where/to/save/result/image' # 如果不添加这个参数则不保存图像 ) ``` ## 高密度(车展) 高密度使用函数 `predict_high_density_image` 进行预测。 ```python from APP_ROOT import predict_high_density_image json_string = predict_high_density_image('/path/to/your/test/image/dir/XXX.jpg', high=HIGH, # 摄像头高度,单位米,在我们的研究中,535、545、550、375、335高度定为5m, # 334、376、419、420、551、552高度定为7m rois="{'1': [{'x': 0.1010, 'y': 0.2010}, {'x': 0.3010, 'y': 0.4010}, {'x':0.5010, 'y': 0.6010}, {'x': 0.7010,'y':0.8010}]}" # roi ) # 返回的json字符串 print(json_string) ``` 样例输出: ```bash {"code": 200, "data": {"store_id": 0, "type": null, "url": "D:\\552\\552_75942017-11-17.jpg", "image_roi": {"1": {"people_num": 25.79307746887207, "is_high_density": 1}, "2": {"people_num": 9.091708183288574, "is_high_density": 1}}}} ```