【问题标题】:Running a python file showing image in google colab在 google colab 中运行显示图像的 python 文件
【发布时间】:2021-06-19 09:22:39
【问题描述】:

我想在 google colab 中运行一个 python 文件。该文件还将循环显示图像。但是无论我做什么,我都无法显示图像。

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+')

输出:

【问题讨论】:

    标签: python-3.x opencv matplotlib google-colaboratory


    【解决方案1】:

    使用命令 'run' 而不是 '!python' 来执行 .py 文件。

    【讨论】:

      猜你喜欢
      • 2020-03-06
      • 2022-01-14
      • 2019-08-12
      • 2020-03-20
      • 2019-03-22
      • 1970-01-01
      • 2019-10-18
      • 2020-10-15
      • 2016-02-09
      相关资源
      最近更新 更多