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
标签云
RAR PDB GGML scipy C++ FP32 报税 DeepSeek NLP FP64 CV OCR Password 阿里云 VPN Quantization Python Ptyhon uwsgi RGB Vim Zip Quantize Qwen Conda Agent Ubuntu 算法题 OpenAI Pillow 腾讯云 TTS printf 证件照 Github Card WebCrawler Attention Algorithm CLAP Bipartite CUDA CC 音频 LaTeX Color NLTK Distillation Plate mmap SVR 关于博主 Translation 版权 Diagram Safetensors Mixtral SPIE XML Qwen2 Windows torchinfo WAN VSCode Disk HuggingFace git GPT4 SQLite Qwen2.5 Use 签证 Land Shortcut UI CEIR GoogLeNet llama.cpp Jetson Docker Plotly Template PyCharm Excel EXCEL 财报 搞笑 uWSGI Random UNIX Proxy InvalidArgumentError Linux tar LLAMA FP8 Domain ResNet-50 Markdown Food tqdm Paper DeepStream Bert Git ONNX JSON Paddle 多进程 Math Tracking Permission Jupyter Website TensorRT 公式 v2ray logger LoRA CAM AI CTC GPTQ Animate git-lfs BTC 继承 COCO Firewall Cloudreve Pytorch Clash Interview Nginx Datetime Sklearn hf API Breakpoint Hotel TSV TensorFlow Heatmap Tensor Anaconda Hilton Tiktoken FP16 Streamlit XGBoost Freesound SAM Hungarian IndexTTS2 Transformers 域名 LLM Review Video FlashAttention Crawler Vmess BF16 Web Numpy GIT ChatGPT NameSilo 飞书 PyTorch LeetCode Llama 多线程 Base64 YOLO PIP diffusers Input MD5 Claude Magnet VGG-16 HaggingFace Logo transformers Michelin FastAPI 净利润 v0.dev Knowledge Pickle Augmentation Statistics PDF Gemma Miniforge Google Bitcoin Dataset Bin OpenCV BeautifulSoup Pandas Django Image2Text ModelScope CSV QWEN Baidu SQL Data
站点统计

本站现有博文312篇,共被浏览744432

本站已经建立2387天!

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