In my attempt to follow the FireDetection example, I'm currently facing some uncertainty regarding the process of transitioning from the "lpb.NNData" object, which represents the results obtained from the fire_detection neural network, to a tensor result. Specifically, I'm looking to access the correct layer, "final_result" onto script node, which will be flashed on the device.
script.setScript("""
import socket
import time
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(("0.0.0.0", 5000))
server.listen()
node.warn("Server up")
labelMap_SSD = ["background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow",
"diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"]
label_fire = ["fire", "normal", "smoke"]
while True:
conn, client = server.accept()
node.warn(f"Connected to client IP: {client}")
try:
while True:
pck = node.io["frame"].get()
data = pck.getData()
ts = pck.getTimestamp()
# --------MobilenetSSD
detections_ssd = node.io["detSSD"].tryGet()
if detections_ssd:
dets = detections_ssd.detections
data_ssd = []
for det in dets:
label = labelMap_SSD[det.label]
if label == "person":
det_bb = [det.label, det.xmin, det.ymin, det.xmax, det.ymax]
data_ssd.append(det_bb)
# --------FireDetection
data_fire = node.io["detFire"].tryGet()
# node.warn(f"data_fire: {data_fire}")
# TODO: extract tensor data ???
# now to send data we need to encode it (whole header is 256 characters long)
header = f"ABCDE " + str(ts.total_seconds()).ljust(18) + str(len(data)).ljust(8) + str(data_ssd).ljust(224)
conn.send(bytes(header, encoding='ascii'))
conn.send(data)
except Exception as e:
node.warn(f"Error oak: {e}")
node.warn("Client disconnected")
""")
Any help will be appreciated.
Irena