From 1e01141f41ba780f0b502afac2874f99e224bcaf Mon Sep 17 00:00:00 2001 From: Cole Deck Date: Sun, 12 May 2024 16:59:59 -0500 Subject: [PATCH] Make cable_search match cable_map --- led_control.py | 4 ++-- map.png | Bin 348063 -> 348063 bytes run.py | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/led_control.py b/led_control.py index fab6ccd..9aba2e7 100755 --- a/led_control.py +++ b/led_control.py @@ -721,12 +721,12 @@ if __name__ == "__main__": import matplotlib.pyplot as plt ledsys = LEDSystem() ledsys.init() - cap = cv2.VideoCapture('badapple.mp4') + cap = cv2.VideoCapture('output.mp4') while cap.isOpened(): ret, frame = cap.read() if not ret: break - ledsys.mapimage(frame, fps=60) + ledsys.mapimage(frame, fps=200) show = False ring = 1 diff --git a/map.png b/map.png index ab99b3785c4e3c7170b75506ba9f246412fce3a5..21f1e0c128c87fd751113784a88384d72611531b 100644 GIT binary patch delta 58 zcmbO~Uv&O_(Fq=MCOQfkB_##LR{Hw6i6sR&`6W4-NqYH3>H6}j%B78It!a#{X-utY N%&loGThmxA{Q+bC6XpN_ delta 58 zcmbO~Uv&O_(Fq=M#yScaB_##LR{Hw6i6sR&`6W4-NqYH3>H5c?MFcmdwWcw)rZKgq OF}J3%Y)xae^alWiEEQn@ diff --git a/run.py b/run.py index 746fcf8..617ac07 100755 --- a/run.py +++ b/run.py @@ -249,10 +249,51 @@ def check_server(): elif call == "request": results = jbs.search(data["string"])["hits"] dataout = dict() - dataout["cables"] = list() - for result in results: - dataout["cables"].append(result["fullspecs"]) + dataout["map"] = list() + for cabledata in results: + + fs = cabledata["fullspecs"] + tmp1 = {"part_number": cable_list[idx], "position": idx, "name": cable_list[idx], "brand": cabledata["brand"] } + if "Product Overview" in fs and "Product Category" in fs["Product Overview"]: + tmp1["category"] = fs["Product Overview"]["Product Category"] + if "Product Overview" in fs and "Suitable Applications" in fs["Product Overview"]: + if len(fs["Product Overview"]["Suitable Applications"]) == 0 or not isinstance(fs["Product Overview"]["Suitable Applications"], str): + print(cable_list[idx], fs["Product Overview"]["Suitable Applications"]) + for key, value in fs["Product Overview"].items(): + #print(key,value) + if len(value) > 5 and isinstance(value, str): + tmp1["application"] = value + elif len(key) > 15 and not isinstance(value, str): + tmp1["application"] = key + else: + tmp1["application"] = fs["Product Overview"]["Suitable Applications"] + elif "Product Overview" in fs and "Suitable Applications:" in fs["Product Overview"]: + if len(fs["Product Overview"]["Suitable Applications:"]) == 0 or not isinstance(fs["Product Overview"]["Suitable Applications:"], str): + print(cable_list[idx], fs["Product Overview"]["Suitable Applications:"]) + for key, value in fs["Product Overview"].items(): + #print(key,value) + if len(value) > 5 and isinstance(value, str): + tmp1["application"] = value + elif len(key) > 15 and not isinstance(value, str): + tmp1["application"] = key + else: + tmp1["application"] = fs["Product Overview"]["Suitable Applications:"] + if "image" in cabledata: + tmp1["image"] = cabledata["image"] + if "description" in cabledata: + tmp1["description"] = cabledata["description"] + if "short_description" in cabledata: + tmp1["short_description"] = cabledata["short_description"] + if "application" in cabledata: + tmp1["application"] = cabledata["application"] + if "category" in cabledata: + tmp1["category"] = cabledata["category"] + + dataout["map"].append(tmp1) + + # after loop send_data(decoded["type"], "send", dataout, client_id) + case "keyboard": fprint("keyboard message") if call == "send":