Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1.  
  2. def start_moments_calculator(self, target_algorithm, display=False):
  3. while True:
  4. processed_image = self.get_processed_image(target_algorithm)
  5. if processed_image is None:
  6. break
  7. moments = cv2.moments(processed_image)
  8. hu_moments = cv2.HuMoments(moments)
  9. for i in range(0, 7):
  10. hu_moments[i] = -1 * copysign(1.0, hu_moments[i]) * log10(abs(hu_moments[i]))
  11.  
  12. if display:
  13. cv2.imshow("Show by CV2", processed_image)
  14. k = cv2.waitKey(1)
  15. if k % 256 == 27: # ESC
  16. print("Escape hit, closing...")
  17. break
  18.  
  19. self.cam.release()
  20. cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement