This shows you the differences between two versions of the page.
Next revisionBoth sides next revision | |||
resources:eval:user-guides:eval-adsd3175d-first-frame-pygame [10 May 2023 18:27] – created Andre Straker-Payne | resources:eval:user-guides:eval-adsd3175d-first-frame-pygame [10 May 2023 18:39] – Updated code and instructions Andre Straker-Payne | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Animated Depth Images using PyGame ====== | ====== Animated Depth Images using PyGame ====== | ||
+ | |||
+ | The following examples works with the eval kit release TOF_Evaluation_ADTF3175D-Rel4.1.1 with Python 3.9. | ||
+ | |||
+ | It is assumed depth-image-animation-pygame.py is in TOF_Evaluation_ADTF3175D-Rel4.1.1/ | ||
+ | |||
+ | Python dependencies are: | ||
+ | * Matplotlib - used for the viridis color map | ||
+ | * PyGame - used for the animate | ||
+ | * NumPy | ||
== Usage == | == Usage == | ||
Line 49: | Line 58: | ||
import matplotlib.pyplot as plt | import matplotlib.pyplot as plt | ||
from matplotlib.colors import ListedColormap | from matplotlib.colors import ListedColormap | ||
+ | |||
+ | modemapping = { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | |||
+ | mode = " | ||
if len(sys.argv) < 2 or sys.argv[1] == " | if len(sys.argv) < 2 or sys.argv[1] == " | ||
Line 91: | Line 107: | ||
print(" | print(" | ||
- | status = camera1.setFrameType(" | + | status = camera1.setFrameType(mode) |
print(" | print(" | ||
Line 117: | Line 133: | ||
def main(): | def main(): | ||
pygame.init() | pygame.init() | ||
- | window_size = (1024, 1024) | + | window_size = (modemapping[mode][" |
screen = pygame.display.set_mode(window_size) | screen = pygame.display.set_mode(window_size) | ||