0

I am writing a code using the Google AIY vision kit and its APIs. I have a loop which calls the face_detection model continuously every 30 secs. The loop works perfectly fine for the first 2 iterations but when it reaches to the 3rd iteration my display monitor switches off and shows me that no HDMI is detected even though the program is still running in the background. Along with the display monitor, I have connected my laptop to my raspberry pi using a VNC viewer. So, when the display monitor goes off the VNC viewer keeps operating and the command line keeps displaying the output. How can I fix this issue and keep the monitor open for all the period of running the code?

This is the main function:

def main():
  with PiCamera(sensor_mode=4, resolution=(1640, 1232), framerate=30) as camera:
     while durationOver():
        camera.start_preview()
        face_detection_inference(camera,argsf)
        camera.stop_preview()
if __name__ == '__main__':
    main()

This the face_detection_inference function:

def face_detection_inference(camera,args):

 """Face detection camera inference example.""" 

# Annotator renders in software so use a smaller size and scale results
# for increased performance.
annotator = Annotator(camera, dimensions=(320, 240))
scale_x = 320 / 1640
scale_y = 240 / 1232

# Incoming boxes are of the form (x, y, width, height). Scale and
# transform to the form (x1, y1, x2, y2).
def transform(bounding_box):
    x, y, width, height = bounding_box
    return (scale_x * x, scale_y * y, scale_x * (x + width), scale_y * (y + height))
try:
    with CameraInference(face_detection.model()) as inference:
        cam_tick = time.time()
        for result in inference.run(args.num_frames):
            time_passed = time.time() - cam_tick
            if time_passed>5:
                break
            faces = face_detection.get_faces(result)
            annotator.clear()
            for face in faces:
                annotator.bounding_box(transform(face.bounding_box), fill=0)
            annotator.update()
            print('#%05d (%5.2f fps): num_faces=%d' %(inference.count, inference.rate, len(faces)))
finally:
    annotator.stop()
    inference.close()
  • 1
    you described your observation ... now, please ask a question – jsotola Nov 2 '20 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.