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

本站现有博文324篇,共被浏览819941

本站已经建立2524天!

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