我有来自视频的图像和带有索引的查找表。目标是通过使用查找表中的索引从每一帧生成一个新图像。我的代码使用我的笔记本电脑工作,但有点慢。我的目标是让它在 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()
我该怎么做才能让它更快?我应该研究并行处理吗?欢迎任何帮助。谢谢