08_OpenCV文字图片绘制

复制代码
import cv2 
import numpy as np

img = cv2.imread('image0.jpg',1)
font = cv2.FONT_HERSHEY_SIMPLEX

cv2.rectangle(img,(500,400),(200,100),(0,255,0),20)
# 1 dst 2 文字内容 3 坐标 4 5 字体大小 6 color 7 粗细 8 line type
cv2.putText(img,'flower',(200,50),font,1,(0,0,250),2,cv2.LINE_AA)
# cv2.imshow('src',img)
# cv2.waitKey(0)

array([[[ 34, 36, 30],

33, 35, 29\], \[ 31, 33, 27\], ..., \[ 83, 110, 60\], \[ 85, 110, 60\], \[ 85, 110, 60\]\], \[\[ 32, 34, 28\], \[ 31, 33, 27\], \[ 30, 32, 26\], ..., \[ 80, 107, 57\], \[ 81, 106, 56\], \[ 81, 106, 56\]\], \[\[ 31, 33, 27\], \[ 31, 33, 27\], \[ 30, 32, 26\], ..., \[ 78, 107, 57\], \[ 77, 104, 54\], \[ 77, 104, 54\]\], ..., \[\[ 14, 16, 17\], \[ 11, 16, 15\], \[ 15, 18, 16\], ..., \[ 16, 16, 16\], \[ 9, 11, 11\], \[ 10, 12, 12\]\], \[\[ 12, 16, 17\], \[ 11, 16, 15\], \[ 15, 19, 14\], ..., \[ 16, 16, 16\], \[ 14, 16, 16\], \[ 15, 17, 17\]\], \[\[ 12, 16, 17\], \[ 11, 16, 15\], \[ 15, 19, 14\], ..., \[ 16, 16, 16\], \[ 17, 19, 19\], \[ 17, 19, 19\]\]\], dtype=uint8) ``` import matplotlib.pyplot as plt %matplotlib inline dst = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) plt.imshow(dst) plt.show() ``` ![](https://i-blog.csdnimg.cn/direct/3fa3f39564a04fb3afaca82ea47a9f1e.png) ## 图片绘制 ``` import cv2 img = cv2.imread('image0.jpg',1) height = int(img.shape[0]*0.2) width = int(img.shape[1]*0.2) imgResize = cv2.resize(img,(width,height)) for i in range(0,height): for j in range(0,width): img[i+200,j+350] = imgResize[i,j] # cv2.imshow('src',img) # cv2.waitKey(0) ``` ``` img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) plt.imshow(img) plt.show() ``` ![](https://i-blog.csdnimg.cn/direct/830315abce304d59bb68d4d201ecaa26.png)

相关推荐
千寻girling1 小时前
Python 是用来做 AI 人工智能 的 , 不适合开发 Web 网站 | 《Web框架》
人工智能·后端·算法
AI攻城狮1 小时前
OpenClaw 里 TAVILY_API_KEY 明明写在 ~/.bashrc,为什么还是失效?一次完整排查与修复
人工智能·云原生·aigc
stark张宇2 小时前
构建第一个AI聊天机器人:Flask+DeepSeek+Postgres实战
人工智能·postgresql·flask
yiyu07163 小时前
3分钟搞懂深度学习AI:自我进化的最简五步法
人工智能·深度学习
浪浪山_大橙子5 小时前
OpenClaw 十分钟快速,安装与接入完全指南 - 推荐使用trae 官方 skills 安装
前端·人工智能
火山引擎开发者社区5 小时前
OpenClaw 快速上手:把云手机变成你的 7×24 小时 AI 手机助手
人工智能
Qlly5 小时前
DDD 架构为什么适合 MCP Server 开发?
人工智能·后端·架构
Lee川5 小时前
从零构建智能对话系统:AI Agent 实战指南
人工智能
冬奇Lab6 小时前
一天一个开源项目(第43篇):Star-Office-UI - 像素风格的 AI 办公室看板,让 AI 助手的工作状态可视化
人工智能·开源·资讯
风象南6 小时前
纯文本模型竟然也能直接“画图”,而且还很好用
前端·人工智能·后端