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

本站现有博文332篇,共被浏览895111

本站已经建立2596天!

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