import datetime
import halcon as ha
import os
cd = os.getcwd()+"\\"
import streamlit as st
import time
def main():# 主函数
st.set_page_config(page_title="实时图像展示") # 设置应用的标题
st.markdown("### 实时图像展示")
t=st.text("每秒更新一次图像。")
ph=st.empty()
tm=st.text(datetime.datetime.now().strftime("%Y%m%d%H%M%S"))
cnt=0
while True:
t.text("每秒更新一次图像。" + str(cnt))
im = ha.read_image(cd +str(cnt)+ ".bmp")
arr = ha.himage_as_numpy_array(im)
ph.image(arr)
cnt = cnt + 1
if cnt > 7:
cnt = 0
tstr=datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
tm.text(tstr) # time.sleep(0.1)
if __name__ == "__main__":# 运行主函数
main()
streamlit更新halcon图像
于 2024-07-07 16:30:39 首次发布