28浏览
查看: 28|回复: 0

[M10项目] 行空板之AI绘画显示大屏

[复制链接]
【项目背景】
  1. #  -*- coding: UTF-8 -*-
  2. # MindPlus
  3. # Python
  4. import cv2
  5. import siot
  6. import base64
  7. import numpy as np
  8. from Spark import Spark
  9. spark_amount=0
  10. spark_Personality=[]
  11. # 事件回调函数
  12. def on_message_callback(client, userdata, msg):
  13.     global img
  14.     global BiaoShi
  15.     img=base64.b64decode(msg.payload.decode())
  16.     BiaoShi = 1
  17. siot.init(client_id="989152365291244",server="iot.dfrobot.com.cn",port=1883,user="AVNLqL6SR",password="04HYqY6IRz")
  18. siot.connect()
  19. siot.loop()
  20. siot.set_callback(on_message_callback)
  21. siot.getsubscribe(topic="z4ksqL6Ig")
  22. spark_appid="5c7a6af2"
  23. spark_api_key="94932090baf7bb1eae2200ace714f424"
  24. spark_api_secret="YTYwZjMwMDYwNDVjYTU0OTFhY2RmNjEx"
  25. spark_history=[]
  26. spark = Spark(spark_appid,spark_api_secret,spark_api_key,spark_Personality)
  27. spark.tti("绘制一幅关于人们在北京欢度十一假期,清晰的水彩风格的画。")
  28. img = 0
  29. siot.publish(topic="z4ksqL6Ig", data=spark.imageBase)
  30. BiaoShi = 0
  31. cv2.namedWindow("Mind+'s Windows", cv2.WINDOW_NORMAL)
  32. cv2.setWindowProperty("Mind+'s Windows", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
  33. image = cv2.imread("logo.jpg", cv2.IMREAD_UNCHANGED)
  34. cv2.waitKey(20)
  35. while True:
  36.     if (BiaoShi == 1):
  37.         BiaoShi = 2
  38.         print(img)
  39.         image = np.frombuffer(img, np.uint8)
  40.         image = cv2.imdecode(image, cv2.IMREAD_COLOR)
  41.     else:
  42.         cv2.imshow("Mind+'s Windows", image)
  43.         cv2.waitKey(20)
复制代码


ThuOctober-202410035074..png
ThuOctober-202410033419..png
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail