当前位置:网站首页>plt. GCA () picture frame and label
plt. GCA () picture frame and label
2022-06-25 12:01:00 【On the art of moving bricks】
Frame and label
Draw a box and label
Mainly from json In file , Get the coordinate position of the target .
Frame the picture json file information .
Code
import json
from matplotlib import pyplot as plt
from PIL import Image
import numpy as np
jsonpath = ' ROM. .json' # load json Data and information
with open(jsonpath,encoding = 'utf-8') as f:
data=json.load(f)
image = ' ROM. .jpg'
img = Image.open(image)
np_img = np.array(img)
print(np_img.shape)
plt.figure(figsize=(15,9))
plt.imshow(img)
current_axis = plt.gca() # Frame object
xmin = data['outputs']['object'][0]['bndbox']['xmin']
ymin = data['outputs']['object'][0]['bndbox']['ymin']
xmax = data['outputs']['object'][0]['bndbox']['xmax']
ymax = data['outputs']['object'][0]['bndbox']['ymax']
current_axis.add_patch(plt.Rectangle((xmin, ymin), xmax-xmin, ymax-ymin, color='green', fill=False, linewidth=2))
current_axis.text(xmin, ymin, 'c luo', size='x-large', color='white', bbox={
'facecolor':'green', 'alpha':1.0})# among label Is the tag name you want to type

Draw multiple boxes and labels
Tagged picture json file information 
Code :
import json
from matplotlib import pyplot as plt
from PIL import Image
import numpy as np
jsonpath = ' mei .json' # load json Data and information
with open(jsonpath,encoding = 'utf-8') as f:
data=json.load(f)
image = ' mei .jpg'
img = Image.open(image)
np_img = np.array(img)
print(np_img.shape)
plt.figure(figsize=(15,9))
plt.imshow(img)
current_axis = plt.gca() # Frame object
data = data['outputs']['object']
for i in data:
print(i)
name = i['name']
xmin = i['bndbox']['xmin']
ymin = i['bndbox']['ymin']
xmax = i['bndbox']['xmax']
ymax = i['bndbox']['ymax']
current_axis.add_patch(plt.Rectangle((xmin, ymin), xmax-xmin, ymax-ymin, color='green', fill=False, linewidth=2))
current_axis.text(xmin, ymin, name, size='x-large', color='white', bbox={
'facecolor':'green', 'alpha':1.0})# among label Is the tag name you want to type

边栏推荐
- Spark tuning tool -- detailed explanation of sparklens
- PyCaret 成功解决无法从‘sklearn.model_selection._search‘导入名称“_check_param_grid”
- Application of analytic hierarchy process in college teaching evaluation system (principle + example + tool)
- Spark runs wordcount (case 1)
- 黑马畅购商城---8.微服务网关Gateway和Jwt令牌
- Spark history server and event log details
- WebRTC Native M96 基础Base模块介绍之实用方法的封装(MD5、Base64、时间、随机数)
- 数据库系列:MySQL索引优化总结(综合版)
- 兴业证券是国企吗?在兴业证券开户资金安全吗?
- Niuke.com: Candy distribution
猜你喜欢

Shichuang energy rushes to the scientific innovation board: it plans to raise 1.1 billion yuan, with an annual revenue of 700million yuan and a 36% decrease in net profit

Golden sun education listed in the U.S.: a small cap medium cap stock with a market value of USD 360million

Thingspanel releases Internet of things mobile client (multiple pictures)

Architects reveal the difference between working in Alibaba, Tencent and meituan

Eureka accesses the console and reports an error: whitelabel error page

Spark history server performance improvement (I) -- Application List

ROS 笔记(06)— 话题消息的定义和使用

Two ways of redis persistence -- detailed explanation of RDB and AOF

Dark horse shopping mall ---8 Microservice gateway and JWT token

ThingsPanel 发布物联网手机客户端(多图)
随机推荐
Spark runs wordcount (case 2)
JSON format processing
Customize to prevent repeated submission of annotations (using redis)
Sword finger offer II 091 Painting house: application of state machine DP
Redis雪崩、穿透和击穿是什么?
JS judge whether a number is in the set
Golden sun education listed in the U.S.: a small cap medium cap stock with a market value of USD 360million
客从何处来
Openfeign uses
A detour taken by a hardware engineer
数据库系列:MySQL索引优化总结(综合版)
交易期货沪镍产品网上怎么开户
The cloud native data lake has passed the evaluation and certification of the ICT Institute with its storage, computing, data management and other capabilities
Simple use of stream
Why distributed IDS? What are the distributed ID generation schemes?
Builder pattern
.Net Core 中使用工厂模式
The service layer reports an error. The XXX method invalid bound statement (not found) cannot be found
Idea uses the fast request interface for debugging
ThingsPanel 發布物聯網手機客戶端(多圖)