【Python】Qwen-VL-7B box

VLLM-Qwen2-VL-7B-Instruct

bash 复制代码
import cv2

# 读取图像
image_path = 'haibaoA.png'  # 替换为图像的路径
image = cv2.imread(image_path)

# 定义框的坐标 (x1, y1) 是左上角,(x2, y2) 是右下角
x1, y1 = 200, 550  # 左上角坐标
x2, y2 = 799, 750 # 右下角坐标
h, w = image.shape[0], image.shape[1]
x1, y1, x2, y2 = (int(x1 / 1000 * w), int(y1 / 1000 * h), int(x2 / 1000 * w), int(y2 / 1000 * h))
# 定义框的颜色 (B, G, R) 和线条宽度
color = (0, 255, 0)  # 绿色
thickness = 2  # 线条宽度

# 在图像上绘制矩形框
cv2.rectangle(image, (x1, y1), (x2, y2), color, thickness)

# 显示图像
cv2.imshow('Image with Rectangle', image)
cv2.waitKey(0)
cv2.destroyAllWindows()

# 保存绘制框后的图像
output_path = 'image_with_rectangle.jpg'
cv2.imwrite(output_path, image)
相关推荐
普通网友18 分钟前
Python函数定义与调用:编写可重用代码的基石
jvm·数据库·python
普通网友33 分钟前
使用Python进行PDF文件的处理与操作
jvm·数据库·python
MZ_ZXD00142 分钟前
springboot流浪动物救助平台-计算机毕业设计源码08780
java·spring boot·后端·python·spring·flask·课程设计
十步杀一人_千里不留行1 小时前
解释器模式:为 LLM 构建迷你 DSL 解释器,实现 Prompt 编排语言
python·prompt·解释器模式
这儿有一堆花2 小时前
python视觉开发
开发语言·python
普通网友2 小时前
编写一个Python脚本自动下载壁纸
jvm·数据库·python
w***4813 小时前
Python中的简单爬虫
爬虫·python·信息可视化
z***56564 小时前
【玩转全栈】----Django模板语法、请求与响应
数据库·python·django
voidmort4 小时前
web3.py 简介:面向 Python 开发者的以太坊
开发语言·python·web3.py
后台开发者Ethan4 小时前
LangGraph 的持久化
python·langgraph