I have 2 folders containing multiple images files following the same filename convention. I'd like to go through each images from each folder together and perform a pixel difference for the corresponding filename. I have the code for pixel difference of one image, I need the algorithm to return the processed difference-image for each operation while looping over both folders at the same time according to the filename, then write this image in a third folder.
I have this Folder structure:
**first camera** **second camera**
20-06-01-0000.jpg 20-06-01-0000.png
20-06-02-0000.jpg 20-06-02-0000.png
20-06-03-0000.jpg 20-06-03-0000.png
... ...
20-06-30-0000.jpg 20-06-30-0000.png
Pixel difference:
import cv2
img1 = cv2.imread('/firstcamera/20-06-26-00000.jpg')
img2 = cv2.imread('/secondcamera/20-06-26-00000.png')
difference = cv2.subtract(img1,img2)
cv2.imwrite('d-20-06-26-00000.png', difference)
I want this Folder structure:
**first camera** **second camera** **difference**
20-06-01-0000.jpg 20-06-01-0000.png d-20-06-01-0000.png
20-06-02-0000.jpg 20-06-02-0000.png d-20-06-02-0000.png
20-06-03-0000.jpg 20-06-03-0000.png d-20-06-03-0000.png
... ... ...
20-06-30-0000.jpg 20-06-30-0000.png d-20-06-30-0000.png
I know I can use os.listdir() and enumerate() but I can get it to work properly. Please help, thanks!