【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)
相关推荐
北斗落凡尘8 小时前
LangGraph 入门实战(2)
python·langchain
ttod_qzstudio9 小时前
Java 常用语法极简通关(五):类与对象——字段、方法、构造器、this 与 static
java·开发语言·python
jufeng130710 小时前
【系列:手搓自主 AI Agent:Hermes 架构原理剖析 · 第 1 篇】
人工智能·python·架构·agent
牧羊人.33310 小时前
计算机视觉基础|第2章 OpenCV图像基础操作(读写、窗口、像素操作)
人工智能·opencv·计算机视觉
月光船幽幽11 小时前
影子模式下保护 logits 不被修改
人工智能·python·算法
_oP_i13 小时前
python 后缀 mjs文件
开发语言·python
北斗落凡尘13 小时前
如何使用LangGraph(1)
python·langchain
Livia要学习14 小时前
Python装饰器
开发语言·python
大模型丫丫15 小时前
LangChain4j:Java 生态的 AI 应用开发利器
java·人工智能·python
circuitsosk15 小时前
向量数据库选型与性能压测:Milvus、Pinecone、Chroma在真实业务下的对比
数据库·python·pinecone·milvus·向量数据库·chroma