我正在使用python执行图像减法.我有numpy数组形式的图像.携带所有图像的列表的大小是1000.列表中的每个numpy数组是360*640类型.当帧数约为300时,帧减法正确发生.
def find_der(frames):
der = []
for a in range(len(frames)-1):
der.append(frames[a + 1] - frames[a])
return der
framesprocessing = 1000
for j in range(framesprocessing):
img = cv.QueryFrame(video)
if img is None:
print("Images are Not Captured")
else:
tmp = cv.CreateImage(cv.GetSize(img), 8, 3)
saveImagesColor = 'Abhiram_images/RGB/frame' + str(i) + '.png' #Saving the iplimages to the local PC
cv.SaveImage(saveImagesColor, img)
saveImagesGray = 'Abhiram_images/GRAY/frame' + str(i) + '.png' #Saving the grayscale images to the local PC
img1 = cv2.imread(saveImagesColor)
grayimg = cv2.cvtColor(img1,cv2.COLOR_BGR2GRAY)
cv2.imwrite(saveImagesGray, grayimg) …Run Code Online (Sandbox Code Playgroud)