File name
Commit message
Commit date
import numpy as np
from flask import Flask, request
from flask_restx import Api, Resource, fields
import os
from datetime import datetime
from yoloseg.inference_ import Inference, overlay_mask
import cv2
import time
import base64
app = Flask(__name__)
api = Api(app, version='1.0', title='Detection postprocessing component',
description='A postprocessing that dynamically decides how frequently send image and detection result')
# Namespace definition
ns = api.namespace('cctv', description='CCTV operations')
@ns.route('/postprocess', )
class get_inference_result(Resource):
def __init__(self):
super().__init__(api)
self.time_sent = None
self.cctv_latitude = None
self.cctv_longitude = None
self.cctv_info = None
self.mask = None
self.image = None
self.image_type = None
self.area_percent = 0
@ns.response(200, 'Success')
@ns.response(400, 'Validation Error')
def post(self):
self.image = request.files['image']
self.mask = request.files['mask']
self.cctv_info = base64.b64decode(request.headers.get('x-cctv-name', '')).decode('UTF-8')
self.cctv_latitude = request.headers.get('x-cctv-latitude')
self.cctv_longitude = request.headers.get('x-cctv-longitude')
self.image_type = request.headers.get('Content-Type')
self.area_percent = request.headers.get('x-area-percentage')
async def data_ping_pong(self):
pass