【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)
相关推荐
2401_89719055几秒前
JavaScript对象浅拷贝:Object-assign的合并规则
jvm·数据库·python
Shorasul5 分钟前
如何用 fill 配合 map 初始化一个填充了不同对象的数组
jvm·数据库·python
weixin_586061468 分钟前
golang如何使用go-redis客户端_golang go-redis客户端使用教程
jvm·数据库·python
m0_3776182321 分钟前
C# 异步范围Asynchronous Disposal方法 C# await using如何使用
jvm·数据库·python
qq_2837200531 分钟前
Python 模块精讲:platform 获取系统信息,从入门到实战全攻略
python·platform
vb攻城狮41 分钟前
前端害怕被蒸馏 快速入门Python 【demo_03】
python
qq_189807031 小时前
SQL多表嵌套查询数据重复怎么办_使用DISTINCT去重优化策略
jvm·数据库·python
m0_747854521 小时前
mysql如何设置数据库连接字符编码_修改default-character
jvm·数据库·python
Wyz201210241 小时前
如何在 React 中正确将父组件函数传递给子组件并触发调用
jvm·数据库·python
2401_865439631 小时前
Go语言如何用logrus_Go语言logrus日志框架教程【技巧】
jvm·数据库·python