当前位置:网站首页>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
边栏推荐
- Nacos installation and use
- Is industrial securities a state-owned enterprise? Is it safe to open an account in industrial securities?
- 云原生数据湖以存储、计算、数据管理等能力通过信通院评测认证
- Keywords serializable serialization and deserialization
- 时创能源冲刺科创板:拟募资11亿 年营收7亿净利反降36%
- The temporary table from XML to VFP is simple and easy to use and worth collecting
- 分享7个神仙壁纸网站,让新的壁纸,给自己小小的雀跃,不陷入年年日日的重复。
- Shichuang Energy sprint Technology Innovation Board: le chiffre d'affaires annuel prévu de 1,1 milliard de RMB est de 0,7 milliard de RMB, en baisse de 36%
- Spark runs wordcount (case 2)
- Cesium building loading (with height)
猜你喜欢
Niuke: rotation array
Startups must survive
Source code analysis of AQS & reentrantlock
Database Series: MySQL index optimization summary (comprehensive version)
How TCP handles exceptions during three handshakes and four waves
How far is it from the DBF of VFP to the web salary query system?
Two ways of redis persistence -- detailed explanation of RDB and AOF
VFP uses Kodak controls to control the scanner to solve the problem that the volume of exported files is too large
ROS 笔记(06)— 话题消息的定义和使用
分享7个神仙壁纸网站,让新的壁纸,给自己小小的雀跃,不陷入年年日日的重复。
随机推荐
ThingsPanel 發布物聯網手機客戶端(多圖)
How terrible is it not to use error handling in VFP?
2020最新最全IT学习线路
黑马畅购商城---3.商品管理
Thingpanel publie le client mobile IOT (Multi - images)
Flink partition policy
VFP develops a official account to receive coupons, and users will jump to various target pages after registration, and a set of standard processes will be sent to you
Why distributed IDS? What are the distributed ID generation schemes?
VFP serial port communication is difficult for 9527. Maomao just showed his skill and was defeated by kiss
属性分解 GAN 复现 实现可控人物图像合成
.Net Core 中使用工厂模式
Convergence by probability
Customize to prevent repeated submission of annotations (using redis)
cnds
The idea of mass distribution of GIS projects
Spark history server and event log details
Database Series: MySQL index optimization summary (comprehensive version)
How to open an account for trading futures Shanghai nickel products online
Shichuang Energy sprint Technology Innovation Board: le chiffre d'affaires annuel prévu de 1,1 milliard de RMB est de 0,7 milliard de RMB, en baisse de 36%
Oracle Spatial creating spatial tables