ake178178's picture
Update camera.py
bb7ec90 verified
raw
history blame contribute delete
471 Bytes
import cv2
import streamlit as st
def take_picture():
"""
使用 OpenCV 拍摄一张照片并返回图像数据。
"""
cap = cv2.VideoCapture(0) # 打开默认摄像头
ret, frame = cap.read()
cap.release()
return frame
def show_picture(img):
"""
在 Streamlit 中显示图像。
"""
st.image(img, channels="BGR")
if __name__ == "__main__":
if st.button("拍照"):
img = take_picture()
show_picture(img)