L i'nUddlmZddlmZddlmZddlmZmZm Z ddl m Z ddl m Z ddlmZmZddlmZmZdd lmZmZmZmZmZdd lmZdd lmZdd lm Z!dd lm"Z#ddl$m%Z%ddl&m'Z'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-ddl.m/Z/m0Z0er ddl1m2Z2ddlm3Z3e0e/zdzZ4de5d<eGddZ6GddZ7y)) annotations) dataclass)dedent) TYPE_CHECKING TypeAliascast)enforce_filename_restriction)current_form_id) LayoutConfigvalidate_width)check_widget_policiesmaybe_raise_label_warnings)KeyLabelVisibilitycompute_and_register_element_id get_label_visibility_proto_valueto_key)_get_upload_files) CameraInput)FileUploaderState)UploadedFileInfo)gather_metrics)ScriptRunContextget_script_run_ctx) WidgetArgsWidgetCallback WidgetKwargsregister_widget) DeletedFile UploadedFile)DeltaGenerator)WidthWithoutContentNrSomeUploadedSnapshotFilec,eZdZ ddZ ddZy)CameraInputSerdec&t}|t|tr|S|jj }|j |_|j |_|j|_|jj|j|S)N) FileUploaderStateProto isinstanceruploaded_file_infoaddfile_idnamesize file_urlsCopyFrom _file_urls)selfsnapshot state_proto file_infos m/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/elements/widgets/camera_input.py serializezCameraInputSerde.serialize:sy-.  z(K@ +6+I+I+M+M+O $,, ! ! $$X%8%89ct|}t|dk(rdn|d}|'t|tst |j dg|S)Nrz.jpg)rlenr(rr r,)r1ui_value upload_files return_values r5 deserializezCameraInputSerde.deserializeKsL)2 "<0A5t<?  #J|[,Q ():):VH Er7N)r2r#returnr')r:zFileUploaderStateProto | Noner>r#)__name__ __module__ __qualname__r6r=r7r5r%r%8s.* "5 !r7r%ceZdZed d dddd d dZ d ddddd d d Zedd Zy)CameraInputMixin camera_inputNFvisiblestretch)disabledlabel_visibilitywidthc Lt} |j||||||||| |  S)a2Display a widget that returns pictures from the user's webcam. Parameters ---------- label : str A short label explaining to the user what this widget is used for. The label can optionally contain GitHub-flavored Markdown of the following types: Bold, Italics, Strikethroughs, Inline Code, Links, and Images. Images display like icons, with a max height equal to the font height. Unsupported Markdown elements are unwrapped so only their children (text contents) render. Display unsupported elements as literal characters by backslash-escaping them. E.g., ``"1\. Not an ordered list"``. See the ``body`` parameter of |st.markdown|_ for additional, supported Markdown directives. For accessibility reasons, you should never set an empty label, but you can hide it with ``label_visibility`` if needed. In the future, we may disallow empty labels by raising an exception. .. |st.markdown| replace:: ``st.markdown`` .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown key : str or int An optional string or integer to use as the unique key for the widget. If this is omitted, a key will be generated for the widget based on its content. No two widgets may have the same key. help : str or None A tooltip that gets displayed next to the widget label. Streamlit only displays the tooltip when ``label_visibility="visible"``. If this is ``None`` (default), no tooltip is displayed. The tooltip can optionally contain GitHub-flavored Markdown, including the Markdown directives described in the ``body`` parameter of ``st.markdown``. on_change : callable An optional callback invoked when this camera_input's value changes. args : list or tuple An optional list or tuple of args to pass to the callback. kwargs : dict An optional dict of kwargs to pass to the callback. disabled : bool An optional boolean that disables the camera input if set to ``True``. Default is ``False``. label_visibility : "visible", "hidden", or "collapsed" The visibility of the label. The default is ``"visible"``. If this is ``"hidden"``, Streamlit displays an empty spacer instead of the label, which can help keep the widget aligned with other widgets. If this is ``"collapsed"``, Streamlit displays no label or spacer. width : "stretch" or int The width of the camera input widget. This can be one of the following: - ``"stretch"`` (default): The width of the widget matches the width of the parent container. - An integer specifying the width in pixels: The widget has a fixed width. If the specified width is greater than the width of the parent container, the width of the widget matches the width of the parent container. Returns ------- None or UploadedFile The UploadedFile class is a subclass of BytesIO, and therefore is "file-like". This means you can pass an instance of it anywhere a file is expected. Examples -------- >>> import streamlit as st >>> >>> enable = st.checkbox("Enable camera") >>> picture = st.camera_input("Take a picture", disabled=not enable) >>> >>> if picture: ... st.image(picture) .. output:: https://doc-camera-input.streamlit.app/ height: 600px ) labelkeyhelp on_changeargskwargsrHrIrJctx)r _camera_input) r1rLrMrNrOrPrQrHrIrJrRs r5rEzCameraInputMixin.camera_inputVsCV!"!!-"  r7)rHrIrJrRc t|}t|j||ddt||t d|d|j||| } t } | | _|| _t|j| _ || _ t|| j_ |t|| _t!| t#| } t%}t'| j ||||j(|j*| d}|jj-d| | t/|jt0ry|jS) NF) default_valuewrites_allowedrE)user_keykey_as_main_identitydgrLrNrJ)rJfile_uploader_state_value)on_change_handlerrPrQ deserializer serializerrR value_type) layout_config)rr rYrrCameraInputProtoidrLr form_idrHrrIvaluerrNr r r%rr=r6_enqueuer(r)r1rLrMrNrOrPrQrHrIrJrR element_idcamera_input_protor_serdecamera_input_states r5rSzCameraInputMixin._camera_inputsLSk GG     #5*:;4 !&ww ./ *#( %4TWW%="&.#4T 5 ++1  &,Tl  #u$51  ",  ! !'**2    .m   (.. <!'''r7ctd|S)zGet our DeltaGenerator.r!)r)r1s r5rYzCameraInputMixin.dgs$d++r7)NNNNN)rLstrrM Key | NonerN str | NonerOWidgetCallback | NonerPWidgetArgs | NonerQWidgetKwargs | NonerHboolrIrrJr"r>UploadedFile | None)rLrjrMrkrNrlrOrmrPrnrQrorHrprIrrJr"rRzScriptRunContext | Noner>rq)r>r!)r?r@rArrErSpropertyrYrBr7r5rDrDUsaN#+/"&&*v ,5%.v v v  v ) v  v $v v *v #v  v $v v+/"&&*E(,5%.'+E(E(E( E( ) E(  E($E(E(*E(#E(%E( E(N,,r7rD)8 __future__r dataclassesrtextwraprtypingrrr*streamlit.elements.lib.file_uploader_utilsr !streamlit.elements.lib.form_utilsr #streamlit.elements.lib.layout_utilsr r streamlit.elements.lib.policiesr rstreamlit.elements.lib.utilsrrrrr(streamlit.elements.widgets.file_uploaderrstreamlit.proto.CameraInput_pb2rr`streamlit.proto.Common_pb2rr'rUploadedFileInfoProtostreamlit.runtime.metrics_utilrstreamlit.runtime.scriptrunnerrrstreamlit.runtime.staterrrr'streamlit.runtime.uploaded_file_managerrr streamlit.delta_generatorr!r"r#__annotations__r%rDrBr7r5rs#!11S=LGKRP9O N8G&2[&@4&G)G  8D,D,r7