【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)
相关推荐
Akttt3 分钟前
【T2I】R&B: REGION AND BOUNDARY AWARE ZERO-SHOT GROUNDED TEXT-TO-IMAGE GENERATION
人工智能·深度学习·计算机视觉·text2img
jndingxin1 小时前
OpenCV CUDA模块设备层-----反向二值化阈值处理函数thresh_binary_inv_func()
人工智能·opencv·计算机视觉
精灵vector1 小时前
构建专家级SQL Agent交互
python·aigc·ai编程
Zonda要好好学习1 小时前
Python入门Day2
开发语言·python
Vertira1 小时前
pdf 合并 python实现(已解决)
前端·python·pdf
太凉1 小时前
Python之 sorted() 函数的基本语法
python
项目題供诗2 小时前
黑马python(二十四)
开发语言·python
jndingxin2 小时前
OpenCV CUDA模块设备层-----在 GPU 上执行类似于 std::copy 的操作函数warpCopy()
人工智能·opencv·计算机视觉
晓13132 小时前
OpenCV篇——项目(二)OCR文档扫描
人工智能·python·opencv·pycharm·ocr
是小王同学啊~2 小时前
(LangChain)RAG系统链路向量检索器之Retrievers(五)
python·算法·langchain