zoukankan      html  css  js  c++  java
  • 使用python进行视频图片提取

    操作系统 : Windows 10 [版本 10.0.19043.1165]

    Python 版本 : 3.9.2_x64

    可以借助python代码使用opencv实现,命令行示例代码如下:

    # python3
    # pip install opencv-python numpy
    
    import os,cv2
    import numpy as np
    
    def save_img(img,addr,num):
            naddr = "%s/%d.jpg" % (addr,num)
            ret = cv2.imwrite(naddr,img)
            #print("ret :",ret)
            return ret
    
    srcFile = "./1.mp4"
    dstDir = "./output"
    
    if not os.path.isdir(dstDir):
            os.mkdir(dstDir)
    
    videoCapture = cv2.VideoCapture(srcFile)
    isOK,frame = videoCapture.read()
    i=0
    while isOK :
            i = i + 1
            if not save_img(frame,dstDir,i) :
                    print("error occur!")
                    break
            if (i+1)%100 == 1 :  print('save img:',i)
            isOK,frame = videoCapture.read()
    

      

    也可以借助python的界面实现,具体代码见共享的资源文件。

    附图:

    文件列表:

     命令行模式效果:

     图形模式效果:

     提取效果:

    本文涉及资源下载地址:https://pan.baidu.com/s/1xhBxGnc8akC3UH70CyIDdw

    可关注微信公众号(聊聊博文)后回复 2021101601 获得提取码。  

    微信公众号:

  • E-Mail : Mike_Zhang@live.com
  • 转载请注明出处,谢谢!
查看全文
  • 相关阅读:
    利用jquery修改href的部分字符
    javascript基础 思维导图2
    Javascript 思维导图 绘制基础内容(值得一看)
    JavaScript判断是否全为中文,是否含有中文
    将Jquery序列化后的表单值转换成Json
    连接Oracle时报错ORA-12541: TNS: 无监听程序
    A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: /usr/local/eclipse/
    (转)Debian 安装与卸载包命令
    Flume 1.7.0单机版安装
    Struts2.5学习笔记----org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter报错
  • 原文地址:https://www.cnblogs.com/MikeZhang/p/pythonConvertVedioToImages.html
  • Copyright © 2011-2022 走看看