【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)
相关推荐
Channing Lewis几秒前
Python读取excel转成html,并且复制excel中单元格的颜色(字体或填充)
python·html·excel
小钟不想敲代码3 分钟前
Python(一)
开发语言·python
大佬,救命!!!6 分钟前
对算子shape相关的属性值自动化处理
python·算法·自动化·学习笔记·算子·用例脚本·算子形状
WoY202011 分钟前
本地PyCharm配置远程服务器上的python环境
服务器·python·pycharm
tzjly19 分钟前
JSON数据一键导入SQL Server
python
一分半心动38 分钟前
清理C盘的python脚本
开发语言·python
AI手记叨叨1 小时前
Python数学:几何运算
python·数学·解析几何·射影几何·微分几何·欧几里得几何
toolhow2 小时前
SelfAttenion自注意力机制
pytorch·python·深度学习
智航GIS2 小时前
6.2 while循环
java·前端·python
qq_336313932 小时前
java基础-IO流(转换流)
java·开发语言·python