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

本站现有博文337篇,共被浏览962159次

本站已经建立2674天!

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