def volume_analysis(self, threshold_image):
gamma = 0.05
flag = False
no_of_pixels = cv2.compare(threshold_image, 0, cv2.CMP_GT).sum() / 255
if self.prevNoOfPixels is not None:
if abs(self.prevNoOfPixels - no_of_pixels) / self.prevNoOfPixels > gamma:
flag = True
self.prevNoOfPixels = no_of_pixels
return flag
I am guessing that cv2.compare(threshold_image, 0, cv2.CMP_GT).sum() is substracting an empty or 0 matrix from threshold image and storing it in a matrix that has something to do with cv2.CMP_GT .sum() is probably finding the number of pixels from that matrix. Am I right?
However, I couldn't find any official python documentation on the function cv2.compare() or on cv2.CMP_GT or on .sum() {used in such a way}. I did see that there are some articles on these keywords being used in C++. I will be grateful if someone can explain what these mean or share some documentation.