您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

46 行
1.3KB

  1. from io import BytesIO
  2. import cv2
  3. import matplotlib.pyplot as plt
  4. import matplotlib.patches as pat
  5. import numpy as np
  6. import requests
  7. from PIL import ImageDraw, Image
  8. from util.ImageUtils import url2Array
  9. url = "https://www.2008php.com/2015_Website_appreciate/2015-12-06/20151206234254.jpg"
  10. color= (255, 255, 0)
  11. #( 蓝, 绿, 红)
  12. # 红色 (0, 0, 255)
  13. # 洋红色 (255, 0, 255)
  14. # 青色 (255, 255, 0)
  15. # 黑色 (0, 0, 0)
  16. # 蓝色 (255, 0, 0)
  17. # 绿色 (0, 255, 0)
  18. # 黄色 (0, 255, 255) # 不考虑
  19. img = url2Array(url)
  20. cv2.putText(img,"Hello World", (100,100), cv2.FONT_HERSHEY_SIMPLEX, 1.0,color, 1, cv2.LINE_AA)
  21. # rectangle 坐标的参数格式为左上角(x1, y1),右下角(x2, y2), 颜色 , 粗细
  22. cv2.rectangle(img, (100, 110), (400, 310), color, 2)
  23. cv2.imshow('img', img)
  24. cv2.waitKey()
  25. # fig, ax = plt.subplots(1)
  26. # ax.imshow(img)
  27. # # Rectangle 坐标的参数格式为左上角(x, y),width, height。
  28. # rec = pat.Rectangle((386, 144), 1049, 760, linewidth=2, edgecolor='r', facecolor='None')
  29. # ax.add_patch(rec)
  30. # plt.imshow(img)
  31. # plt.show()
  32. # response = requests.get(url)
  33. # image = Image.open(BytesIO(response.content))
  34. # a = ImageDraw.ImageDraw(image)
  35. # # rectangle 坐标的参数格式为左上角(x1, y1),右下角(x2, y2)。
  36. # a.rectangle(((386, 144), (1435, 904)), fill=None, outline='red', width=2)
  37. # image.show()