Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

just getting started, using streaming_video.py example #7

Closed
bsenftner opened this issue Dec 4, 2021 · 2 comments
Closed

just getting started, using streaming_video.py example #7

bsenftner opened this issue Dec 4, 2021 · 2 comments

Comments

@bsenftner
Copy link

Realizing what I'm looking for may not be in zengl; when I run the streaming_video.py example I see my webcam0 fine, but it is vertically flipped.

To vertically flip the video frame, would that be done at the imageio, the zengl, or some other image module level I need to bring into that minimal example? I am thinking the return value from zengl.rgba(next(it), 'rgb') would saved to an intermediate variable, potentially as input to some image object that allows basic graphical operations, such as the vertical flip I want?

@szabolcsdombi
Copy link
Owner

You can flip it with zengl.rgba(next(it)[::-1].tobytes(), 'rgb')

next(it) is actually a numpy array

zengl.rgba(...) is a very limited helper to provide a readable way to express rbg to rgba conversion or similar.

you can do the conversion and padding completely with numpy as a single step:

import numpy as np
rgba = np.zeros((height, width, 4), 'u1')

while window.update():
    rgba[:, :, :3] = next(it)[::-1]
    image.write(rgba)
    ...

@bsenftner
Copy link
Author

Makes perfect sense, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants