package com.zhgd.xmgl.modules.basicdata.api.image_ai;

import com.alibaba.fastjson.JSONArray;
import com.zhgd.xmgl.modules.basicdata.api.image_ai.common.FireSmokeDetectExample;
import com.zhgd.xmgl.modules.basicdata.api.image_ai.common.LargeSafetyHelmetDetectExample;
import com.zhgd.xmgl.modules.basicdata.api.image_ai.common.ReflectiveVestDetectExample;
import com.zhgd.xmgl.modules.basicdata.api.image_ai.utils.AiBroker;
import lombok.experimental.UtilityClass;

@UtilityClass
public class ImageApi {

    /**
     * 根据rtsp流进行安全帽检测
     * @return
     */
    public JSONArray safetyHelmet(String rtsp) {
        String result = AiBroker.runAs(rtsp, imagePath -> {
            return LargeSafetyHelmetDetectExample.imageAi(imagePath);
        });
        return JSONArray.parseArray(result);
    }

    /**
     * 根据rtsp流进行反光衣检测
     * @return
     */
    public JSONArray reflectiveVest(String rtsp) {
        String result = AiBroker.runAs(rtsp, imagePath -> {
            return ReflectiveVestDetectExample.imageAi(imagePath);
        });
        return JSONArray.parseArray(result);
    }

    /**
     * 根据rtsp流进行烟火检测
     * @return
     */
    public JSONArray fireSmoke(String rtsp) {
        String result = AiBroker.runAs(rtsp, imagePath -> {
            return FireSmokeDetectExample.imageAi(imagePath);
        });
        return JSONArray.parseArray(result);
    }

    public static void main(String[] argstia) {
        try {
            System.out.println(safetyHelmet("rtsp://admin:jxj12345@10.0.77.104:554/Streaming/Channels/101"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
