【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)
相关推荐
ZC跨境爬虫几秒前
批量爬取小说章节并优化排版(附完整可运行脚本)
前端·爬虫·python·自动化
ths5122 分钟前
Python 正则表达式实战指南:从入门到精通(12 个高频案例)(三)
python·正则表达式
ZC跨境爬虫3 分钟前
海南大学交友平台登录页开发实战day4(解决python传输并读取登录信息的问题)
开发语言·前端·python·flask·html
Wyawsl4 分钟前
Python操作MySQL数据库
数据库·python·mysql
SuperEugene12 分钟前
Python 异步 async/await:为什么 AI 框架大量使用?| 基础篇
开发语言·人工智能·python
SMF191918 分钟前
【uv】Python包管理器uv安装和应用
开发语言·python·uv
gergul18 分钟前
在llama-cpp-python中使用自己编译的llama.cpp,解决pip install llama-cpp-python报错
python·llama·llama.cpp·llamacpppython
深蓝轨迹18 分钟前
#Python零基础机器学习入门教程
人工智能·python·机器学习
蓝色的杯子20 分钟前
Python面试30分钟突击掌握-LeetCode1-Array
开发语言·python·面试
怪祝浙22 分钟前
超简洁YOLO8n快速上手人员检测
python