简体   繁体   中英

running a python file showing image in google colab

i want to run a python file in google colab. The file will also show image in a loop but whatever i do i am not able to show the image.

cam = cv2.VideoCapture('etcs/waste_2.mp4')
ret_val, image = cam.read()
while i<50:
    ret_val, image = cam.read()
    i+=1
    image,new_centers = TfPoseEstimator.draw_humans(image, humans, imgcopy=False)

    logger.debug('show+')
    cv2.putText(image,
                "FPS: %f" % (1.0 / (time.time() - fps_time)),
                (10, 10),  cv2.FONT_HERSHEY_SIMPLEX, 0.5,
                (0, 255, 0), 2)
    cv2_imshow(image)
    imshow(np.asarray(image))
    plt.show()
    sleep(1)
    
    fps_time = time.time()
    if cv2.waitKey(1) == 27:
        break
    logger.debug('finished+')

output:

没有图像

Use command 'run' instead of 'python' to execute.py file. enter image description here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM