我尝试使用 MPI scatter 将 cv2 Video Capture 源发送到不同的进程。这样,每个进程都会有一个句柄来检索帧。
if rank == 0:
video_source = cv2.VideoCapture('my_video.avi')
source_list = [video_source] * world_communicator.Get_size()
else:
source_list = None
data = world_communicator.scatter(source_list, root=0)
# Do stuff with access to the video source...
但是,我收到此代码的以下错误。
[dfaux@ubiquitous mpi_practice]$ mpirun -n 2 python cv2_video_practice.py
Traceback (most recent call last):
File "cv2_video_practice.py", line 93, in <module>
process_video(source, destination, kernel)
File "cv2_video_practice.py", line 58, in process_video
data = comm.scatter(frame_counts, root=0)
File "Comm.pyx", line 874, in mpi4py.MPI.Comm.scatter (src/mpi4py.MPI.c:68023)
File "pickled.pxi", line 656, in mpi4py.MPI.PyMPI_scatter (src/mpi4py.MPI.c:32402)
File "pickled.pxi", line 131, in mpi4py.MPI._p_Pickle.dumpv (src/mpi4py.MPI.c:26847)
File "pickled.pxi", line 81, in mpi4py.MPI._p_Pickle.dump (src/mpi4py.MPI.c:26188)
cPickle.PicklingError: Can't pickle <type 'cv2.VideoCapture'>: it's not the same object as cv2.VideoCapture
为什么我不能腌制视频源?为什么<type 'cv2.VideoCapture'>
不是同一个对象cv2.VideoCapture
?