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

本站现有博文339篇,共被浏览996090次

本站已经建立2706天!

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