Hi,
I want to alter detectnet.py so that a picture (including the frame) of a detected object is saved to disk.
At the moment, this part of the code captures the image from the camera and checks if a keyboard (for testing) is detected.
It then sends me a message via telegram:
while True:
# capture the next image
img = input.Capture()
# detect objects in the image (with overlay)
detections = net.Detect(img, overlay=opt.overlay)
# print the detections
print("detected {:d} objects in image".format(len(detections)))
for detection in detections:
print(detection)
# render the image
output.Render(img)
# update the title bar
output.SetStatus("{:s} | Network {:.0f} FPS".format(opt.network, net.GetNetworkFPS()))
for detection in detections:
if detection.ClassID == 76:
i = i + 1
if i > 30:
bot.send_video(chat_id="", photo=open('/tmp/output.mp4', 'rb'), caption="mycaption")
os.remove('/tmp/output.mp4')
i = 0
# exit on input/output EOS
if not input.IsStreaming() or not output.IsStreaming():
break
The ultimate goal is to send me an image of the detected object via telegram, but I can’t get my head around how to render just the last frame and send it as a jpeg.
If it is easier, a video would also be okay.
Can anybody point me in the right direction?
Thanks :)