## ObjectVA * Default port: 6090 * Default ssl port: 4473 ### Login * 說明:登入 * Path:/user/web/login * Method:post #### Request Interface: ``` interface ILogin_User { username: string; password: string; } type request = ILogin_User; ``` #### Response Interface: ``` interface IObject { objectId: string; name: string; } interface IWebLoginUser { objectId: string; roles: IObject[]; username: string; name: string; email: string; } interface IWebLogin { sessionId: string; user: IWebLoginUser; } type response = IWebLogin; ``` #### Example ``` /// request {{baseUrl}}/user/web/login { "username": "signage_api_user", "password": "Aa123456*" } /// response { "sessionId": "r:uvol4zlp3spsxv7x53qyavxdo7liwgoi", "user": { "objectId": "6285b1f0dab93262c0e2bf11", "roles": [ { "objectId": "6285a9ba6627fa53fc3d8c40", "name": "Administrator" } ], "username": "signage_api_user", "name": "signage_api_user", "email": "signage_api_user@service.com" } } ``` #### Status * 200 - 成功 * 400 - 請求部分欄位缺失或型別錯誤 * 401 - 登入失敗,帳號密碼錯誤 *** ### Maintain Session * 說明:檢查Session 、取得帳號資料或是延長Session 使用期限 (1 小時) * Path:/user/web/login * Method:post #### Request Interface: ``` interface ILogin_SessionId { sessionId: string; } ``` #### Response Interface: ``` 同Login API ``` #### Example ``` /// request {{baseUrl}}/user/web/login { "sessionId": "r:uvol4zlp3spsxv7x53qyavxdo7liwgoi" } /// response { "sessionId": "r:uvol4zlp3spsxv7x53qyavxdo7liwgoi", "user": { "objectId": "6285b1f0dab93262c0e2bf11", "roles": [ { "objectId": "6285a9ba6627fa53fc3d8c40", "name": "Administrator" } ], "username": "signage_api_user", "name": "signage_api_user", "email": "signage_api_user@service.com" } } ``` #### Status * 200 - 成功 * 400 - 請求部分欄位缺失或型別錯誤 * 401 - Session 過期或錯誤 *** ### Get Source List * 說明:取得所有影像來源清單 (使用時會延長一次Session 使用時間) * Path:/source/all * Method:get #### Request Interface: ``` interface ISessionId { sessionId: string; } type request = ISessionId; ``` #### Response Interface: ``` enum ESourceType { /// 相機影像來源 camera = "camera", } interface IMessage<T = string> { result: boolean; message: string; content: T; } interface IAll { objectId: string; name: string; type: string; } type response = IMessage<IAll[]>; ``` #### Example ``` /// request {{baseUrl}}/source/all?sessionId={{sessionId}} /// response { "result": true, "message": "2021-09-17T02:17:36.611Z", "content": [ { "objectId": "6143fabe40dcec5857331673", "name": "Camera 1", "type": "camera" } ] } ``` ### Status * 200 - 成功 * 400 - 請求部分欄位缺失或型別錯誤 * 401 - 需要登入 * 403 - 登入帳號權限錯誤 *** ### Live Report * 說明:取得即時辨識報告 (連線期間自動延長Session 使用時間) * Path:/report/live * Method:websocket #### Request Interface: ``` interface ISessionId { sessionId: string; } interface ILive { /// 欲取得影像來源辨識紀錄Id sourceId: string; } type request = ISessionId & ILive; ``` #### Response Interface: ``` enum ESourceType { /// 相機影像來源 camera = "camera", } enum ESourceDetectAreaType { /// 排隊區域 quening = "quening", } interface IWsResponse<T = string> { statusCode: number; message: T; } interface IModelResponse { /// 辨識模型Id id: string; /// 辨識模型 名稱 name: string; description: string; format: string; inputWidth: number; inputHeight: number; /// 辨識模型可辨識物件 labels: { id: string; /// 物件名稱 (請以此做比對) name: string; }[]; } interface ILive_UserSource { /// 影像來源objectId objectId: string; /// 影像來源名稱 name: string; /// 使用辨識模型 model: IModelResponse; } interface ISourceDetectAreaCoordinate { /// 坐標軸X (依圖片寬度百分比,左上角為0) /// @range 0 - 1 x: number; /// 坐標軸Y (依圖片高度百分比,左上角為0) /// @range 0 - 1 y: number; } interface IDetectArea { /// 偵測區域objectId objectId: string; /// 偵測區域名稱 name: string; /// 偵測區域類型 type: string; /// 偵測區域座標 coordinates: ISourceDetectAreaCoordinate[]; } interface ILive_User { sessionId: string; source: ILive_UserSource; detectAreas: IDetectArea[]; } interface ILive_Data { /// 辨識時間 (ISO String) date: Date; /// 影像來源 camera: { /// 影像來源objectId objectId: string; /// 影像來源名稱 name: string; }; /// 辨識結果 inference: { count: { in: number; out: number; pass: number; traffic: number; }; triggerlines: { objectId: string; name: string; in: number; out: number; }[]; /// 辨識物件 objects: { id: number; /// 辨識物件Id trafficId: number; /// 辨識物件分數 conf: number; /// 辨識物件門檻值 threshold: number; /// 辨識物件物件總停留時間 (毫秒) aliveTime: number; /// 辨識物件物件名稱 label: string; /// 辨識物件座標 location: { /// 坐標軸X (依圖片寬度百分比,左上角為0) /// @range 0 - 1 x: number; /// 坐標軸Y (依圖片高度百分比,左上角為0) /// @range 0 - 1 y: number; /// 坐標軸寬度 (依圖片寬度百分比,左上角為0) /// @range 0 - 1 width: number; /// 坐標軸高度 (依圖片高度百分比,左上角為0) /// @range 0 - 1 height: number; }; /// 辨識物件存在偵測區域 areas: { /// 偵測區域objectId objectId: string; /// 偵測區域名稱 name: string; /// 偵測區域停留時間 (毫秒) stayTime: number; }[]; }[]; }; } type ILive = ILive_User | ILive_Data; type response = IWsResponse | ILive; ``` #### Example ``` /// request {{baseWsUrl}}/report/live?sessionId={{sessionId}}&sourceId=661e21418bfc68a540709c49 /// response (設定值,連線成功後會立即傳送一次並於有更新時會再傳送) { "sessionId": "r:514fsgzt4tb00n4j1eqgxfx2wmhzqko2", "source": { "objectId": "661e21418bfc68a540709c49", "name": "Cleanroom Pass", "model": { "id": "rgNob6lK", "name": "cleanroom001", "description": "Azure Custom Vision Object Detection", "format": "azure_object_detect", "inputWidth": 320, "inputHeight": 320, "labels": [ { "id": "0", "name": "Glove_L" }, { "id": "1", "name": "Glove_NG" }, { "id": "2", "name": "Glove_R" }, { "id": "3", "name": "Hat" }, { "id": "4", "name": "Hat_NG" }, { "id": "5", "name": "Mask" }, { "id": "6", "name": "Shoe_L" }, { "id": "7", "name": "Shoe_NG" }, { "id": "8", "name": "Shoe_R" } ] } }, "detectAreas": [ { "objectId": "661e21418bfc68a540709c4a", "name": "Cleanroom Pass Q1", "type": "quening", "coordinates": [ { "x": 0.317955112219451, "y": 0.077132743362832 }, { "x": 0.317955112219451, "y": 0.898230088495575 }, { "x": 0.670922693266833, "y": 0.898230088495575 }, { "x": 0.670922693266833, "y": 0.077132743362832 } ] } ] } /// response (辨識紀錄) { "date": "2024-06-11T10:03:29.324Z", "camera": { "objectId": "661e21418bfc68a540709c49", "name": "Cleanroom Pass" }, "inference": { "count": { "in": 0, "out": 0, "pass": 0, "traffic": 9170 }, "triggerlines": [], "objects": [ { "id": 1, "trafficId": 9165, "conf": 0.9792952, "threshold": 0.3, "aliveTime": 1335, "label": "Hat", "location": { "x": 0.46197916666666666, "y": 0.10925925925925926, "width": 0.0703125, "height": 0.10833333333333334 }, "areas": [] }, { "id": 2, "trafficId": 9166, "conf": 0.61675644, "threshold": 0.3, "aliveTime": 1335, "label": "Glove_L", "location": { "x": 0.5802083333333333, "y": 0.5324074074074074, "width": 0.03854166666666667, "height": 0.0824074074074074 }, "areas": [ { "objectId": "661e21418bfc68a540709c4a", "name": "Cleanroom Pass Q1", "stayTime": 1132 } ] }, { "id": 3, "trafficId": 9169, "conf": 0.41235736, "threshold": 0.3, "aliveTime": 1335, "label": "Glove_R", "location": { "x": 0.396875, "y": 0.5407407407407407, "width": 0.036458333333333336, "height": 0.09444444444444444 }, "areas": [] }, { "id": 4, "trafficId": 9167, "conf": 0.3063643, "threshold": 0.3, "aliveTime": 1335, "label": "Shoe_R", "location": { "x": 0.43385416666666665, "y": 0.712037037037037, "width": 0.0578125, "height": 0.10833333333333334 }, "areas": [ { "objectId": "661e21418bfc68a540709c4a", "name": "Cleanroom Pass Q1", "stayTime": 910 } ] }, { "id": 5, "trafficId": 9168, "conf": 0.30329338, "threshold": 0.3, "aliveTime": 1335, "label": "Shoe_L", "location": { "x": 0.5197916666666667, "y": 0.6944444444444444, "width": 0.05520833333333333, "height": 0.09814814814814816 }, "areas": [ { "objectId": "661e21418bfc68a540709c4a", "name": "Cleanroom Pass Q1", "stayTime": 602 } ] }, { "id": 6, "trafficId": 9170, "conf": 0.30088824, "threshold": 0.3, "aliveTime": 1335, "label": "Mask", "location": { "x": 0.46458333333333335, "y": 0.21296296296296297, "width": 0.06302083333333333, "height": 0.07592592592592592 }, "areas": [ { "objectId": "661e21418bfc68a540709c4a", "name": "Cleanroom Pass Q1", "stayTime": 602 } ] } ] } } ``` ### Status * 200 - 成功 (連線成功一定會傳一次) * 401 - 需要登入 * 403 - 登入帳號權限錯誤