46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
from io import BytesIO
|
||
|
||
import cv2
|
||
import matplotlib.pyplot as plt
|
||
import matplotlib.patches as pat
|
||
import numpy as np
|
||
import requests
|
||
from PIL import ImageDraw, Image
|
||
|
||
from util.ImageUtils import url2Array
|
||
|
||
url = "https://www.2008php.com/2015_Website_appreciate/2015-12-06/20151206234254.jpg"
|
||
|
||
color= (255, 255, 0)
|
||
#( 蓝, 绿, 红)
|
||
# 红色 (0, 0, 255)
|
||
# 洋红色 (255, 0, 255)
|
||
# 青色 (255, 255, 0)
|
||
# 黑色 (0, 0, 0)
|
||
# 蓝色 (255, 0, 0)
|
||
# 绿色 (0, 255, 0)
|
||
# 黄色 (0, 255, 255) # 不考虑
|
||
img = url2Array(url)
|
||
cv2.putText(img,"Hello World", (100,100), cv2.FONT_HERSHEY_SIMPLEX, 1.0,color, 1, cv2.LINE_AA)
|
||
# rectangle 坐标的参数格式为左上角(x1, y1),右下角(x2, y2), 颜色 , 粗细
|
||
cv2.rectangle(img, (100, 110), (400, 310), color, 2)
|
||
cv2.imshow('img', img)
|
||
cv2.waitKey()
|
||
|
||
# fig, ax = plt.subplots(1)
|
||
# ax.imshow(img)
|
||
# # Rectangle 坐标的参数格式为左上角(x, y),width, height。
|
||
# rec = pat.Rectangle((386, 144), 1049, 760, linewidth=2, edgecolor='r', facecolor='None')
|
||
# ax.add_patch(rec)
|
||
# plt.imshow(img)
|
||
# plt.show()
|
||
# response = requests.get(url)
|
||
# image = Image.open(BytesIO(response.content))
|
||
# a = ImageDraw.ImageDraw(image)
|
||
# # rectangle 坐标的参数格式为左上角(x1, y1),右下角(x2, y2)。
|
||
# a.rectangle(((386, 144), (1435, 904)), fill=None, outline='red', width=2)
|
||
# image.show()
|
||
|
||
|
||
|