我正在尝试在来自网络摄像头的实时提要上运行我的图像处理算法。我希望它在多处理模块的并行进程中运行,我该如何实现?这是我当前没有并行编码的代码:from cv2 import VideoCapture , imshow , waitKey ,imwriteimport numpy as npfrom time import timedef greenify (x): return some_valueskip = 4video = VideoCapture(0)video.set(3,640/skip)video.set(4,480/skip)total = 0top_N = 100while True: image = video.read()[1] if waitKey(1) == 27: break arr = array([list(map(greenify,j)) for j in image]) result = unravel_index(argpartition(arr,arr.size-top_N,axis=None)[-top_N:], arr.shape) centre = skip*np.median(result[0]) , skip*np.median(result[1]) imshow('Feed', image)print('Time taken:',total)video.release()
添加回答
举报
0/150
提交
取消