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

add webcam_height and webcam_width to specify the resolution of the Webcam #10032

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yinsumirage
Copy link
Contributor

Description

try to add webcam_height and webcam_width to specify the resolution of the Webcam.
The following code can be executed correctly.

import gradio as gr

with gr.Blocks() as demo:
    image = gr.Image(label="Input", sources="webcam", webcam_height=720, webcam_width=1280)

demo.launch()

However, I don't have a very thorough understanding of resolution, so I didn't see if the image actually changed to a different resolution after modifying the code, which may need help.

Closes: #10027

@@ -102,6 +102,8 @@ def __init__(
show_share_button: bool | None = None,
placeholder: str | None = None,
show_fullscreen_button: bool = True,
webcam_height: int = 1440,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yinsumirage for the nice contribution!

I prefer we instead just let developers specify the media constraints as a python dictionary and we pass that into the get_stream function. It will be more flexible that way and we can add docstring examples for controlling the height and width specifically. I think we can call this parameter webcam_constraints.

BTW, you also need to specify the new props in image/Index.svelte and image/ImageUploader.svelte and pass them into the Webcam component.

BTW can you do this for video as well now that you're at it? 😊

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

Successfully merging this pull request may close these issues.

I want to specify the resolution of the Webcam
2 participants