云天 发表于 2024-10-3 17:32:17

行空板之AI绘画显示大屏

【项目背景】

#-*- coding: UTF-8 -*-

# MindPlus
# Python
import cv2
import siot
import base64
import numpy as np
from Spark import Spark


spark_amount=0

spark_Personality=[]

# 事件回调函数
def on_message_callback(client, userdata, msg):
    global img
    global BiaoShi
    img=base64.b64decode(msg.payload.decode())
    BiaoShi = 1


siot.init(client_id="989152365291244",server="iot.dfrobot.com.cn",port=1883,user="AVNLqL6SR",password="04HYqY6IRz")
siot.connect()
siot.loop()
siot.set_callback(on_message_callback)
siot.getsubscribe(topic="z4ksqL6Ig")
spark_appid="5c7a6af2"
spark_api_key="94932090baf7bb1eae2200ace714f424"
spark_api_secret="YTYwZjMwMDYwNDVjYTU0OTFhY2RmNjEx"
spark_history=[]
spark = Spark(spark_appid,spark_api_secret,spark_api_key,spark_Personality)
spark.tti("绘制一幅关于人们在北京欢度十一假期,清晰的水彩风格的画。")
img = 0
siot.publish(topic="z4ksqL6Ig", data=spark.imageBase)
BiaoShi = 0
cv2.namedWindow("Mind+'s Windows", cv2.WINDOW_NORMAL)
cv2.setWindowProperty("Mind+'s Windows", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
image = cv2.imread("logo.jpg", cv2.IMREAD_UNCHANGED)
cv2.waitKey(20)

while True:
    if (BiaoShi == 1):
      BiaoShi = 2
      print(img)
      image = np.frombuffer(img, np.uint8)
      image = cv2.imdecode(image, cv2.IMREAD_COLOR)
    else:
      cv2.imshow("Mind+'s Windows", image)
      cv2.waitKey(20)



页: [1]
查看完整版本: 行空板之AI绘画显示大屏