def subalg_fun(self):
cap = cv2.VideoCapture(1)
time.sleep(2)
_, first_frame = cap.read()
first_gray = cv2.cvtColor(first_frame, cv2.COLOR_BGR2GRAY)
first_gray = cv2.GaussianBlur(first_gray, (5, 5), 0)
while True:
_, frame = cap.read()
gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
gray_frame = cv2.GaussianBlur(gray_frame, (5, 5), 0)
sub_image = cv2.subtract(first_gray, gray_frame)
thresh = cv2.threshold(sub_image , 20, 255, cv2.THRESH_BINARY)[1]
thresh = cv2.dilate(thresh, None, iterations=3)
result = not np.any(thresh)
cv2.imshow("Frame", frame)
cv2.imshow("sub", sub_image)
if result is True:
print("nothing:",nth)
else:
print("difff:",diff)
# cv2.imshow("difference", difference)
key = cv2.waitKey(30)
if key == 27:
break
i converted the above code from python to c++ successfully but my problem is "result = not np.any(thresh)" here we use numpy to find the difference what is alternate solution for c++