EADST

Python: Subtract the Background Image from A video

Python: Subtract the Background Image from A video.

import cv2
import numpy as np

def get_video_median(video_path, save_path):
    # Open Video
    cap = cv2.VideoCapture(video_path)

    # Randomly select 100 frames
    frame_num = 100
    frameIds = cap.get(cv2.CAP_PROP_FRAME_COUNT) * np.random.uniform(size=frame_num)

    # Store selected frames in an array
    frames = []
    for fid in frameIds:
        cap.set(cv2.CAP_PROP_POS_FRAMES, fid)
        ret, frame = cap.read()
        frames.append(frame)

    # Calculate the pixel median along the time axis
    medianFrame = np.median(frames, axis=0).astype(dtype=np.uint8) 
    img_save = '{}/median.jpg'.format(save_path)
    cv2.imwrite(img_save, medianFrame)


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

本站现有博文328篇,共被浏览843791

本站已经建立2549天!

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