Skip to content

Commit

Permalink
Merge pull request #18 from 5sControl/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
eugenos-programos authored Jul 12, 2023
2 parents c5afeec + c6188d5 commit 04f099c
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 245 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.10
RUN apt-get update
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN pip --default-timeout=100 install -r requirements.txt
RUN apt-get install ffmpeg libsm6 libxext6 -y

WORKDIR /var/www/5scontrol
Expand Down
214 changes: 10 additions & 204 deletions confs/settings.env
Original file line number Diff line number Diff line change
@@ -1,222 +1,28 @@
username = 'admin'
password = 'just4Taqtile'
task = 'bottles'
camera_url = 'http://192.168.1.163/onvif-http/snapshot?Profile_1'
camera_url = 'http://192.168.1.162/onvif-http/snapshot?Profile_1'
server_url = 'http://127.0.0.1'
extra = '
[
{
"areas": [
{
"itemId": 51,
"itemName": "Savisriegis 4.8*90/50",
"multiRow": True,
"coords": [
{
"x1": 670.5552672548002,
"x2": 702.439024390244,
"y1": 777.6878534798535,
"y2": 916.178695970696
}
]
},
{
"itemId": 52,
"itemName": "M645 107Р (RAL7035)",
"multiRow": True,
"coords": [
{
"x1": 896.2807100591715,
"x2": 941.72449704142,
"y1": 420.2308155844156,
"y2": 592.6152311688312
}
]
},
{
"itemId": 36,
"itemName": "Savisriegis 4.8*100",
"multiRow": True,
"coords": [
{
"x1": 705.503355704698,
"x2": 734.1387024608501,
"y1": 778.1279162303664,
"y2": 914.8399581151832
}
]
},
{
"itemId": 39,
"itemName": "643370",
"multiRow": False,
"coords": [
{
"x1": 834.3624161073826,
"x2": 886.1918210290828,
"y1": 412.13838743455494,
"y2": 604.7741989528795
}
]
},
{
"itemId": 43,
"itemName": "М175.1 107Р",
"multiRow": True,
"coords": [
{
"x1": 622.4608501118569,
"x2": 669.7091722595079,
"y1": 400.7457172774869,
"y2": 584.4525235602094
}
]
},
{
"itemId": 21,
"itemName": "Savisriegis 4.8*120/72",
"multiRow": True,
"coords": [
{
"x1": 733.9296644295302,
"x2": 764.5746398210291,
"y1": 775.4805445026178,
"y2": 919.7046282722513
}
]
},
{
"itemId": 26,
"itemName": "M620 107P",
"multiRow": True,
"coords": [
{
"x1": 944.6886800894856,
"x2": 992.5864519015662,
"y1": 419.7686282722513,
"y2": 608.0453193717277
}
]
},
{
"itemId": 46,
"itemName": "М104 anthrazitgrau (176Р)",
"multiRow": False,
"coords": [
{
"x1": 477.8523489932886,
"x2": 523.668903803132,
"y1": 397.8975497382199,
"y2": 563.0912670157068
}
]
},
{
"itemId": 41,
"itemName": "М162",
"multiRow": False,
"coords": [
{
"x1": 725.5480984340045,
"x2": 771.6581655480984,
"y1": 402.1698010471204,
"y2": 587.7236439790576
}
]
},
{
"itemId": 42,
"itemName": "М261.2",
"multiRow": False,
"coords": [
{
"x1": 674.0044742729307,
"x2": 721.4536733780761,
"y1": 399.3216335078534,
"y2": 582.0429738219896
}
]
},
{
"itemId": 40,
"itemName": "М177",
"multiRow": False,
"coords": [
{
"x1": 775.6599552572708,
"x2": 830.3838210290828,
"y1": 409.290219895288,
"y2": 597.6765654450262
}
]
},
{
"itemId": 25,
"itemName": "M687 107 P RAL 7035",
"multiRow": True,
"coords": [
{
"x1": 1278.527562642369,
"x2": 1327.8070523917995,
"y1": 639.3769769769771,
"y2": 770.5239959959961
}
]
},
{
"itemId": 44,
"itemName": "М104 cremeweib (607)",
"multiRow": False,
"coords": [
{
"x1": 575.2125279642058,
"x2": 621.0290827740492,
"y1": 399.3216335078534,
"y2": 573.0598534031413
}
]
},
{
"itemId": 45,
"itemName": "М104 schwarzbraun (925)",
"multiRow": False,
"itemName": "tea",
"multiRow": false,
"task": "bottles",
"lowStockLevel": 20,
"coords": [
{
"x1": 527.9642058165548,
"x2": 572.3489932885906,
"y1": 396.47346596858637,
"y2": 571.6357696335078
}
]
},
{
"itemId": 20,
"itemName": "Savisriegis 4.2*55",
"multiRow": True,
"coords": [
{
"x1": 764.8933333333332,
"x2": 803.9107999999999,
"y1": 784.2821463414635,
"y2": 930.5133268292684
"x1": 495.8731636363636,
"x2": 1417.4731636363636,
"y1": 186.89133014354067,
"y2": 464.53088357256775
}
]
}
],
"zones": [
{
"zoneId": 5,
"zoneName": "STELAG 1.1",
"coords": [
{
"x1": 355,
"x2": 1416,
"y1": 234.82086001829828,
"y2": 972.4311070448308
}
]
}
]
"zones": []
}
]
'
Expand Down
52 changes: 35 additions & 17 deletions get_predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
PORT = 5000

def predict_human(img: np.array, server_url: str, logger: Logger):
response = requests.post(
f"{server_url}:{PORT}/predict_human",
json={
"image": img.tolist()
}
try:
response = requests.post(
f"{server_url}:{PORT}/predict_human",
json={
"image": img.tolist()
}
)
except Exception as exc:
logger.critical(
"Cannot send request. Error - {}".format(exc)
)
return [None, None]
status_code = response.status_code
if status_code == 200:
n_boxes = response.json().get('n_boxes')
Expand All @@ -24,31 +30,43 @@ def predict_human(img: np.array, server_url: str, logger: Logger):
return [n_boxes, coordinates]

def predict_bottles(img: np.array, server_url: str, logger: Logger):
response = requests.post(
f"{server_url}:{PORT}/predict_bottles",
json={
"image": img.tolist()
}
try:
response = requests.post(
f"{server_url}:{PORT}/predict_bottles",
json={
"image": img.tolist()
}
)
except Exception as exc:
logger.critical(
"Cannot send request. Error - {}".format(exc)
)
return [None, None]
status_code = response.status_code
if status_code == 200:
n_bottles = response.json().get('n_items')
coordinates = np.array(response.json().get("coordinates"))
else:
logger.warning(
"Response code = {}.\n JSON = {}".format(status_code, response.json())
"Response code = {}.\n response = {}".format(status_code, response)
)
n_bottles = None
coordinates = None
return [n_bottles, coordinates]

def predict_boxes(img: np.array, server_url: str, logger: Logger):
response = requests.post(
f"{server_url}:{PORT}/predict_boxes",
json={
"image": img.tolist()
}
)
try:
response = requests.post(
f"{server_url}:{PORT}/predict_boxes",
json={
"image": img.tolist()
}
)
except Exception as exc:
logger.critical(
"Cannot send request. Error - {}".format(exc)
)
return [None, None]
status_code = response.status_code
if status_code == 200:
n_boxes = response.json().get('n_items')
Expand Down
7 changes: 3 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

if os.environ.get("extra") is None:
load_dotenv("confs/settings.env")
extra = os.environ.get("extra")
extra = ast.literal_eval(extra)[0]
extra: str = os.environ.get("extra")
extra = json.loads(extra)[0]
areas = extra.get("areas")
zones = extra.get("zones")

Expand All @@ -26,6 +26,5 @@
logger = create_logger()

dataset = HTTPLIB2Capture(source, username=username, password=password, logger=logger)
target = os.environ.get("task") if os.environ.get("task") is not None else "boxes"

run_min_max(dataset, logger, areas, folder, DEBUG_FOLDER, server_url, zones, target)
run_min_max(dataset, logger, areas, folder, DEBUG_FOLDER, server_url, zones)
Loading

0 comments on commit 04f099c

Please sign in to comment.