Innerhlab dieses Repositorys ist ein showcase ausgearbeitet, welcher live die Funktion des EVM Algorithmus darstellt.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

video.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import numpy as np
  2. import cv2
  3. import platform
  4. def calculate_pyramid_levels(vidWidth, vidHeight):
  5. '''
  6. Calculates the maximal pyramid levels for the Laplacian pyramid
  7. :param vidWidth: video frames' width
  8. :param vidHeight: video frames' height
  9. '''
  10. if vidWidth < vidHeight:
  11. levels = int(np.log2(vidWidth))
  12. else:
  13. levels = int(np.log2(vidHeight))
  14. return levels
  15. def rgb2yiq(video):
  16. '''
  17. Converts the video color from RGB to YIQ (NTSC)
  18. :param video: RGB video sequence
  19. :return: YIQ-color video sequence
  20. '''
  21. yiq_from_rgb = np.array([[0.299, 0.587, 0.114],
  22. [0.596, -0.274, -0.322],
  23. [0.211, -0.523, 0.312]])
  24. t = np.dot(video, yiq_from_rgb.T)
  25. return t
  26. def yiq2rgb(video):
  27. '''
  28. Converts the video color from YIQ (NTSC) to RGB
  29. :param video: YIQ-color video sequence
  30. :return: RGB video sequence
  31. '''
  32. rgb_from_yiq = np.array([[1, 0.956, 0.621],
  33. [1, -0.272, -0.647],
  34. [1, -1.106, 1.703]])
  35. t = np.dot(video, rgb_from_yiq.T)
  36. return t