I wrote the following code using OpenCV and Python:
import cv2
cap = cv2.VideoCapture(1)
cv2.namedWindow('Original')
cv2.namedWindow('Captured')
cv2.namedWindow('Deffects')
while True:
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame', frame)
if cv2.waitKey(1) == ord('c'):
cv2.imshow('Captured', gray)
cv2.imwrite('tswira.jpg', frame)
if cv2.waitKey(1) == ord('s'):
img1 = cv2.imread('carte1.jpg', 0)
img2 = cv2.imread('tswira.JPG', 0)
img1 = cv2.resize(img1, (250, 250))
img2 = cv2.resize(img2, (250, 250))
sub = img1 - img2
cv2.imshow('Original', img1)
cv2.imshow('Captured', img2)
cv2.imshow('Deffects', sub)
if cv2.waitKey(1) == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
This is the image I'm getting as output:
However, my question is this: how can I crop just the white area?