info
parent
e4eda48b02
commit
943b9dfbc7
13
app.py
13
app.py
|
@ -43,6 +43,10 @@ def stop(id):
|
||||||
def show():
|
def show():
|
||||||
# print(request.json)
|
# print(request.json)
|
||||||
data = request.json["content"]
|
data = request.json["content"]
|
||||||
|
info(data)
|
||||||
|
return 'ok'
|
||||||
|
|
||||||
|
def info(data):
|
||||||
balls = data["balls"]
|
balls = data["balls"]
|
||||||
table = data["table"]
|
table = data["table"]
|
||||||
text = f"table:{table:>3} "
|
text = f"table:{table:>3} "
|
||||||
|
@ -50,7 +54,6 @@ def show():
|
||||||
ball = "#" if "ball"+str(i) in balls else " "
|
ball = "#" if "ball"+str(i) in balls else " "
|
||||||
text += f"| {i} : {ball} "
|
text += f"| {i} : {ball} "
|
||||||
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'),text)
|
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'),text)
|
||||||
return 'ok'
|
|
||||||
|
|
||||||
def worker(id,source,region=None,stream=False):
|
def worker(id,source,region=None,stream=False):
|
||||||
if region == None:
|
if region == None:
|
||||||
|
@ -111,7 +114,9 @@ def worker(id,source,region=None,stream=False):
|
||||||
names = {}
|
names = {}
|
||||||
if count < region:
|
if count < region:
|
||||||
continue
|
continue
|
||||||
json_data = json.dumps({"table":id,"balls":balls,"time":int(time.time()*1000)})
|
data = {"table":id,"balls":balls,"time":int(time.time()*1000)}
|
||||||
|
info(data)
|
||||||
|
json_data = json.dumps(data)
|
||||||
balls = {}
|
balls = {}
|
||||||
count = 0
|
count = 0
|
||||||
if not stream:
|
if not stream:
|
||||||
|
@ -135,10 +140,10 @@ def workerloop(stop_event,id,source,target=None,region=None):
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
}
|
}
|
||||||
text = json.dumps({"content":json_data})
|
text = json.dumps({"content":json_data})
|
||||||
print(text)
|
# print(text)
|
||||||
response = requests.post(target, data=text, headers=headers)
|
response = requests.post(target, data=text, headers=headers)
|
||||||
|
|
||||||
print(response.text)
|
# print(response.text)
|
||||||
finally:
|
finally:
|
||||||
gen.close()
|
gen.close()
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
billiard:
|
billiard:
|
||||||
# command: ["python", "./app.py"]
|
command: ["python", "./app.py"]
|
||||||
command: ["gunicorn", "app:app", "--bind", "0.0.0.0:5000", "--timeout", "0", "--workers", "1"]
|
# command: ["gunicorn", "app:app", "--bind", "0.0.0.0:5000", "--timeout", "0", "--workers", "1"]
|
||||||
restart: always
|
restart: always
|
||||||
build: .
|
build: .
|
||||||
volumes:
|
volumes:
|
||||||
|
|
4
show.py
4
show.py
|
@ -1,6 +1,7 @@
|
||||||
import cv2
|
import cv2
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
import requests
|
import requests
|
||||||
import supervision as sv
|
import supervision as sv
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ def show():
|
||||||
text += f"| {i} : {ball} "
|
text += f"| {i} : {ball} "
|
||||||
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'),text)
|
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'),text)
|
||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
app.logger.setLevel(logging.ERROR)
|
||||||
app.run("0.0.0.0",threaded=True)
|
app.run("0.0.0.0",threaded=True)
|
||||||
|
|
Loading…
Reference in New Issue