EADST

Put Rectangle and Text in Video with OpenCV

Put Rectangle and Text in Video with OpenCV

# coding=UTF-8
import cv2
def generate_video(video_name):    
    video = "{}.mp4".format(video_name)
    result_video = "./video_label/{}.mp4".format(video_name)

    cap = cv2.VideoCapture(video)
    fps_video = cap.get(cv2.CAP_PROP_FPS)
    fourcc = cv2.VideoWriter_fourcc(*"mp4v")
    frame_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
    frame_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
    videoWriter = cv2.VideoWriter(result_video, fourcc, fps_video, (frame_width, frame_height))
    while (cap.isOpened()):
        ret, frame = cap.read()
        if ret == True:
            # You need to change the following two lines.
            cv2.rectangle(frame, (left_x_up, left_y_up), (right_x_down, right_y_down), (55,255,155), 5)
            cv2.putText(frame, "Hello World!", (word_x, word_y), cv2.FONT_HERSHEY_SIMPLEX, 1, (55,255,155), 2)
            videoWriter.write(frame)
        else:
            videoWriter.release()
            break
相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
YOLO XGBoost Proxy Freesound FP64 Numpy SAM Markdown GGML icon uwsgi GPT4 Linux Quantization mmap UI Plate 多进程 TSV 图标 LeetCode XML Color Conda Hungarian Ptyhon Bin RAR Plotly Github Data Python Animate Pytorch Distillation 阿里云 RL torchinfo 多线程 Windows 图形思考法 版权 Sklearn Anaconda Docker LLAMA RGB FlashAttention Diagram Pillow Ubuntu scipy UNIX 第一性原理 Crawler v0.dev Llama Safetensors 飞书 WebCrawler BTC Nginx Qwen2.5 报税 BeautifulSoup ms-swift 财报 Magnet Interview Tiktoken Web Input llama.cpp v2ray Translation Pandas Baidu Bitcoin Qwen Git 音频 FP16 QWEN Template Bert Base64 EXCEL Image2Text 腾讯云 Hotel AI Logo CAM Domain Cloudreve Knowledge FP8 Permission TensorRT Shortcut CC SQL COCO HuggingFace printf Jupyter tar 顶会 算法题 Paddle LLM Tensor Gemma ModelScope Vim 签证 Algorithm CV Card PyCharm WAN InvalidArgumentError Website Statistics git-lfs Qwen2 PDF Vmess VGG-16 继承 论文 证件照 Disk Clash transformers Jetson SPIE TTS 域名 CEIR logger SVR CTC diffusers Streamlit Firewall FastAPI Michelin NameSilo OpenCV Transformers 净利润 Search GIT HaggingFace C++ Paper SQLite Rebuttal VPN Attention CSV Breakpoint Bipartite BF16 News git Password Dataset Review tqdm ONNX Random CLAP Heatmap CUDA OCR 论文速读 GPTQ PyTorch DeepSeek DeepStream uWSGI Math LaTeX Datetime NLP Video Excel MD5 公式 Quantize 递归学习法 Augmentation Google Tracking OpenAI GoogLeNet Mixtral Agent LoRA 搞笑 TensorFlow 强化学习 ChatGPT Zip Django Land Food Pickle VSCode 云服务器 NLTK Miniforge Hilton Claude IndexTTS2 ResNet-50 PDB 关于博主 JSON Use PIP API hf FP32
站点统计

本站现有博文333篇,共被浏览921508

本站已经建立2627天!

热门文章
文章归档
回到顶部