Rendered walking animation
This commit is contained in:
parent
1945cce0e6
commit
112cbd83da
3 changed files with 29 additions and 13 deletions
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.blend filter=lfs diff=lfs merge=lfs -text
|
37
moonwalk.py
37
moonwalk.py
|
@ -36,11 +36,21 @@ colorset = [(255, 0, 0),
|
|||
]
|
||||
|
||||
|
||||
VELOCITY_FACTOR = 1000*.05 # a pixels/second velocity of 400 gives a frame-duration of .05
|
||||
walk_image = pyglet.image.load('walk_bw.jpg') # TODO investigaet pyglet.resource: https://pyglet.readthedocs.io/en/latest/programming_guide/image.html#displaying-images
|
||||
image_grid = pyglet.image.ImageGrid(walk_image, rows=1, columns=4)
|
||||
# texture_grid = image_grid.get_texture_sequence()
|
||||
walk_animation = image_grid.get_animation(period=.05)
|
||||
VELOCITY_FACTOR = 20*.05 # a pixels/second velocity of 400 gives a frame-duration of .05
|
||||
|
||||
images_nrs = range(125, 162)
|
||||
walk_images = []
|
||||
for nr in images_nrs:
|
||||
fn = f'walk-animation/OUT/{nr:03d}_frame{nr}.png'
|
||||
pic: pyglet.image.ImageData = pyglet.image.load(fn)
|
||||
walk_images.append(pic)
|
||||
walk_animation = pyglet.image.animation.Animation.from_image_sequence(walk_images, 2, True)
|
||||
|
||||
|
||||
# walk_image = pyglet.image.load('walk_bw.jpg') # TODO investigaet pyglet.resource: https://pyglet.readthedocs.io/en/latest/programming_guide/image.html#displaying-images
|
||||
# image_grid = pyglet.image.ImageGrid(walk_image, rows=1, columns=4)
|
||||
# # texture_grid = image_grid.get_texture_sequence()
|
||||
# walk_animation = image_grid.get_animation(period=.05)
|
||||
walk_animation_dim = {
|
||||
'y': walk_animation.get_max_height(),
|
||||
'x': walk_animation.get_max_width()
|
||||
|
@ -53,8 +63,8 @@ class Params:
|
|||
# video_fps: float = 60
|
||||
tracker_fps: float = 5.6
|
||||
# iou = None
|
||||
emitter_speed: float = 4 # objects per second
|
||||
object_velocity: float = 400 # pixels/second
|
||||
emitter_speed: float = 2 # objects per second
|
||||
object_velocity: float = 200 # pixels/second
|
||||
velocity_decay: float = 1 # make system a bit springy
|
||||
iou_threshold: float = 0 # SORT Intersection over union
|
||||
|
||||
|
@ -99,8 +109,8 @@ class DetectedObject:
|
|||
self.canvas = canvas
|
||||
# TODO handle variability
|
||||
self.v = self.canvas.params.object_velocity
|
||||
self.w = 80 # width
|
||||
self.h = 160 # height
|
||||
self.w = 160 # width
|
||||
self.h = 320 # height
|
||||
self.l = -self.w # left
|
||||
self.t = (self.canvas.height - self.h)/2 # top
|
||||
|
||||
|
@ -159,8 +169,8 @@ class Canvas:
|
|||
A canvas with moving objects
|
||||
"""
|
||||
def __init__(self, params: Params):
|
||||
self.width = 1280
|
||||
self.height = 720
|
||||
self.width = 1920
|
||||
self.height = 1080
|
||||
self.objects: list[DetectedObject] = []
|
||||
self.lastSnapshot: Optional[float] = None
|
||||
self.params = params
|
||||
|
@ -182,7 +192,7 @@ class Canvas:
|
|||
# self.window.set_handler('on_close', self.on_close)
|
||||
|
||||
# Purple background color:
|
||||
# pyglet.gl.glClearColor(*AnimConfig.clear_color)
|
||||
pyglet.gl.glClearColor(230/255,230/255,230/255,230/255)
|
||||
self.draw_stats = True
|
||||
self.fps_display = pyglet.window.FPSDisplay(window=self.window, color=(255,255,255,255))
|
||||
self.fps_display.label.x = self.window.width - 150
|
||||
|
@ -349,7 +359,8 @@ class Canvas:
|
|||
for i, object in enumerate(self.objects.copy()):
|
||||
if object.l > self.width:
|
||||
logging.info(f'Delete {i}')
|
||||
self.objects.pop(i)
|
||||
el = self.objects.pop(i)
|
||||
el.shape.delete() # clear the attached shape
|
||||
|
||||
|
||||
def snapshot(self) -> list[DetectedObject]:
|
||||
|
|
BIN
walk-animation/walking-body.blend
(Stored with Git LFS)
Normal file
BIN
walk-animation/walking-body.blend
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in a new issue