1 Star 0 Fork 0

bitterteaer/人流量检测-web

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
socket_server_yolo.py 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
bitterteaer 提交于 2022-12-02 13:24 . first commit
from socketserver import BaseRequestHandler, ThreadingTCPServer
from app import app
from flask_sqlalchemy import SQLAlchemy
from models import GroupOfPeople, Camera
from exts import get_time
# app.app_context().push()
db = SQLAlchemy(app)
class Handler(BaseRequestHandler):
def handle(self) -> None:
address, pid = self.client_address
print(f'{address} connected!')
while True:
data = self.request.recv(1024)
if len(data) <= 0:
print("close!")
break
print(f'receive data: {data.decode()}')
data_dict = eval(data.decode())
# 存入数据库
camera = db.session.query(Camera).filter(Camera.ipv4 == data_dict.get("ip")).first()
if camera is None:
camera = Camera(ipv4=data_dict.get("ip"),
place="未知",
state="未加入系统中的摄像头")
gop = GroupOfPeople(time=get_time(),
mask=data_dict.get("mask"),
no_mask=data_dict.get("no_mask"),
camera=camera)
db.session.add(gop)
db.session.commit()
if __name__ == '__main__':
server = ThreadingTCPServer(('0.0.0.0', 5001), Handler)
print("Listening")
server.serve_forever()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/bitterteaer/people-flow-detection-web.git
git@gitee.com:bitterteaer/people-flow-detection-web.git
bitterteaer
people-flow-detection-web
人流量检测-web
master

搜索帮助