1

我有来自视频的图像和带有索引的查找表。目标是通过使用查找表中的索引从每一帧生成一个新图像。我的代码使用我的笔记本电脑工作,但有点慢。我的目标是让它在 TX2 中工作。下面是我的代码,不知道为什么它很慢。

    cap1 = cv2.VideoCapture(2)
    with open('lookup_table.pkl', 'rb') as f:
        lut_idx = pickle.load(f)
    channels = 3 # Colored images
    dim = 480 # Square image 480 x480
    while (cap1.isOpened()):
        ret1, left = cap1.read()
        if ret1 == True:
            newImg = np.reshape(np.reshape(together, (dim * dim , channels))[lut_idx],
                                     (dim, dim, channels))  
            cv2.imshow('newImage', newImg)  # Show image

        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    cap1.release()
    cv2.destroyAllWindows()

我该怎么做才能让它更快?我应该研究并行处理吗?欢迎任何帮助。谢谢

4

1 回答 1

0

所以,我正在使用预定义的查找表进行一些图像处理。该表具有从图像中抓取像素的位置的索引值。在 TX2 中执行此操作很困难,因为 TX2 的 CPU 较弱。更快地做到这一点的方法是使用 GPU,因为 TX2 有一个巨大的 GPU。CUPY 或 Numba 可用于解决速度问题。

于 2020-03-03T17:18:23.353 回答