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

本站现有博文320篇,共被浏览757191

本站已经建立2422天!

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