参考文章:python—OpenCV2中 cv2.VideoCapture(),read(),waitKey()的使用

VideoCapture.py

# encoding: utf-8
# module cv2.cv2
# from D:\Yolov3_Tensorflow\python\lib\site-packages\cv2\cv2.cp36-win_amd64.pyd
# by generator 1.147
""" Python wrapper for OpenCV. """# imports
import cv2.cv2 as  # C:\Users\HuaWei\AppData\Local\Programs\Python\Python36\lib\site-packages\cv2\cv2.cp36-win_amd64.pyd
import cv2.Error as Error # <module 'cv2.Error'>
import cv2.cuda as cuda # <module 'cv2.cuda'>
import cv2.detail as detail # <module 'cv2.detail'>
import cv2.dnn as dnn # <module 'cv2.dnn'>
import cv2.fisheye as fisheye # <module 'cv2.fisheye'>
import cv2.flann as flann # <module 'cv2.flann'>
import cv2.instr as instr # <module 'cv2.instr'>
import cv2.ipp as ipp # <module 'cv2.ipp'>
import cv2.ml as ml # <module 'cv2.ml'>
import cv2.ocl as ocl # <module 'cv2.ocl'>
import cv2.ogl as ogl # <module 'cv2.ogl'>
import cv2.samples as samples # <module 'cv2.samples'>
import cv2.utils as utils # <module 'cv2.utils'>
import cv2.videoio_registry as videoio_registry # <module 'cv2.videoio_registry'>
import cv2 as __cv2from .object import objectclass VideoCapture(object):# no docdef get(self, propId): # real signature unknown; restored from __doc__"""get(propId) -> retval(返回值).   @brief Returns the specified VideoCapture property(返回指定的VideoCapture属性).   .   @param propId Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...).   or one from @ref videoio_flags_others(来自cv :: VideoCaptureProperties的属性标识符(例如cv :: CAP_PROP_POS_MSEC,cv :: CAP_PROP_POS_FRAMES等)。或@ref videoio_flags_others中的一个).   @return Value for the specified property. Value 0 is returned when querying a property that is.   not supported by the backend used by the VideoCapture instance.(指定属性的值。 查询VideoCapture实例使用的后端不支持的属性时,返回值0。).   .   @note Reading / writing properties involves many layers. Some unexpected result might happens.   along this chain.(读/写属性涉及许多层。 在此链上可能会发生一些意外的结果。).   @code {.txt}.   `VideoCapture -> API Backend -> Operating System -> Device Driver -> Device Hardware`(一连串的因素都可能导致出错).   @endcode.   The returned value might be different from what really used by the device or it could be encoded.   using device dependent rules (eg. steps or percentage). Effective behaviour depends from device.   driver and API Backend(返回的值可能与设备实际使用的值不同,或者可以使用设备相关的规则(例如,步骤或百分比)对其进行编码。 有效行为取决于设备驱动程序和API后端)"""passdef getBackendName(self): # real signature unknown; restored from __doc__"""getBackendName() -> retval.   @brief Returns used backend API name(返回使用的后端API名称).   .   @note Stream should be opened.(流应打开。)"""passdef grab(self): # real signature unknown; restored from __doc__"""grab() -> retval.   @brief Grabs the next frame from video file or capturing device.(从视频文件或捕获设备中获取下一帧。).   .   @return `true` (non-zero) in the case of success.(如果成功,则为“ true”(非零)).   .   The method/function grabs the next frame from video file or camera and returns true (non-zero) in.   the case of success.(该方法/函数从视频文件或摄像机中获取下一帧,并在成功的情况下返回true(非零)。).   .   The primary use of the function is in multi-camera environments, especially when the cameras do not.   have hardware synchronization. That is, you call VideoCapture::grab() for each camera and after that.   call the slower method VideoCapture::retrieve() to decode and get frame from each camera. This way.   the overhead on demosaicing or motion jpeg decompression etc. is eliminated and the retrieved frames.   from different cameras will be closer in time.(该功能的主要用途是在多相机环境中,尤其是在相机没有硬件同步的情况下。 也就是说,您为每个摄像机调用VideoCapture :: grab(),然后调用较慢的方法VideoCapture :: retrieve()解码并从每个摄像机获取帧。 这样,消除了去马赛克或运动jpeg压缩等方面的开销,并且从不同摄像机检索到的帧将在时间上更近。).   .   Also, when a connected camera is multi-head (for example, a stereo camera or a Kinect device), the.   correct way of retrieving data from it is to call VideoCapture::grab() first and then call.   VideoCapture::retrieve() one or more times with different values of the channel parameter.(另外,当连接的摄像机是多头摄像机(例如,立体摄像机或Kinect设备)时,从中检索数据的正确方法是先调用VideoCapture :: grab(),然后再调用VideoCapture :: retrieve() 使用不同的channel参数值一次或多次。).   .   @ref tutorial_kinect_openni"""passdef isOpened(self): # real signature unknown; restored from __doc__"""isOpened() -> retval.   @brief Returns true if video capturing has been initialized already.(如果视频捕获已经初始化,则返回true。).   .   If the previous call to VideoCapture constructor or VideoCapture::open() succeeded, the method returns.   true.(如果先前对VideoCapture构造函数或VideoCapture :: open()的调用成功,则该方法返回true。)"""passdef open(self, filename, apiPreference=None): # real signature unknown; restored from __doc__"""open(filename[, apiPreference]) -> retval.   @brief  Opens a video file or a capturing device or an IP video stream for video capturing.(打开视频文件或捕获设备或IP视频流以进行视频捕获。).   .   @overload.   .   Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY)(参数与构造函数VideoCapture相同(常量字符串和文件名,int apiPreference = CAP_ANY)).   @return `true` if the file has been successfully opened(如果文件已成功打开,则为true).   .   The method first calls VideoCapture::release to close the already opened file or camera.(该方法首先调用VideoCapture :: release以关闭已打开的文件或摄像机。)open(index[, apiPreference]) -> retval.   @brief  Opens a camera for video capturing(打开相机进行视频拍摄).   .   @overload.   .   Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY)(与构造函数VideoCapture(int index,int apiPreference = CAP_ANY)相同).   @return `true` if the camera has been successfully opened.(如果相机已成功打开,则为true。).   .   The method first calls VideoCapture::release to close the already opened file or camera.(该方法首先调用VideoCapture :: release以关闭已打开的文件或摄像机。)"""passdef read(self, image=None): # real signature unknown; restored from __doc__"""read([, image]) -> retval, image.   @brief Grabs, decodes and returns the next video frame.(抓取,解码并返回下一个视频帧。).   .   @param [out] image the video frame is returned here. If no frames has been grabbed the image will be empty.([out]图片视频帧返回此处。 如果没有抓取帧,图像将为空。).   @return `false` if no frames has been grabbed(如果没有抓取任何帧,则为false).   .   The method/function combines VideoCapture::grab() and VideoCapture::retrieve() in one call. This is the.   most convenient method for reading video files or capturing data from decode and returns the just.   grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more.   frames in video file), the method returns false and the function returns empty image (with %cv::Mat, test it with Mat::empty()).(该方法/函数在一次调用中将VideoCapture :: grab()和VideoCapture :: retrieve()组合在一起。 这是读取视频文件或从解码中捕获数据并返回刚抓取的帧的最便捷方法。 如果没有抓取任何帧(相机已断开连接,或者视频文件中没有其他帧),则该方法返回false,并且该函数返回空图像(使用%cv :: Mat,使用Mat :: empty()对其进行测试 )。).   .   @note In @ref videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video.   capturing structure. It is not allowed to modify or release the image! You can copy the frame using.   cvCloneImage and then do whatever you want with the copy.(在@ref videoio_c“ C API”中,函数cvRetrieveFrame()和cv.RetrieveFrame()返回存储在视频捕获结构内的图像。 禁止修改或释放图像! 您可以使用cvCloneImage复制框架,然后对副本进行任何操作。)"""passdef release(self): # real signature unknown; restored from __doc__"""release() -> None.   @brief Closes video file or capturing device.(关闭视频文件或捕获设备。).   .   The method is automatically called by subsequent VideoCapture::open and by VideoCapture.   destructor.(该方法由随后的VideoCapture :: open和VideoCapture析构函数自动调用。).   .   The C function also deallocates memory and clears \*capture pointer.(C函数还会取消分配内存并清除\ * capture指针。)"""passdef retrieve(self, image=None, flag=None): # real signature unknown; restored from __doc__"""retrieve([, image[, flag]]) -> retval, image.   @brief Decodes and returns the grabbed video frame.(解码并返回抓取的视频帧。).   .   @param [out] image the video frame is returned here. If no frames has been grabbed the image will be empty.([out]图片视频帧返回此处。 如果没有抓取帧,图像将为空。).   @param flag it could be a frame index or a driver specific flag(它可以是帧索引或驱动程序特定标志).   @return `false` if no frames has been grabbed(如果没有抓取任何帧,则为false).   .   The method decodes and returns the just grabbed frame. If no frames has been grabbed.   (camera has been disconnected, or there are no more frames in video file), the method returns false.   and the function returns an empty image (with %cv::Mat, test it with Mat::empty()).(该方法解码并返回刚抓取的帧。 如果没有抓取任何帧(相机已断开连接,或者视频文件中没有其他帧),则该方法返回false,并且该函数返回空图像(使用%cv :: Mat,使用Mat :: empty( ))。).   .   @sa read().   .   @note In @ref videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video.   capturing structure. It is not allowed to modify or release the image! You can copy the frame using.   cvCloneImage and then do whatever you want with the copy.(在@ref videoio_c“ C API”中,函数cvRetrieveFrame()和cv.RetrieveFrame()返回存储在视频捕获结构内的图像。 禁止修改或发布图像! 您可以使用cvCloneImage复制框架,然后对副本进行任何操作。)"""passdef set(self, propId, value): # real signature unknown; restored from __doc__"""set(propId, value) -> retval.   @brief Sets a property in the VideoCapture.(在VideoCapture中设置属性。).   .   @param propId Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...).   or one from @ref videoio_flags_others(来自cv :: VideoCaptureProperties的属性标识符(例如cv :: CAP_PROP_POS_MSEC,cv :: CAP_PROP_POS_FRAMES等)或@ref videoio_flags_others中的一个).   @param value Value of the property.(属性的值).   @return `true` if the property is supported by backend used by the VideoCapture instance.(如果属性由VideoCapture实例使用的后端支持,则为true。).   @note Even if it returns `true` this doesn't ensure that the property.   value has been accepted by the capture device. See note in VideoCapture::get()(即使返回“ true”,也不能确保捕获设备已接受该属性值。 请参阅VideoCapture :: get()中的注释)"""passdef __init__(self, *args, **kwargs): # real signature unknownpass@staticmethod # known case of __new__def __new__(*args, **kwargs): # real signature unknown""" Create and return a new object.  See help(type) for accurate signature. (创建并返回一个新对象。 请参阅help(type)以获取准确的签名。)"""passdef __repr__(self, *args, **kwargs): # real signature unknown""" Return repr(self). """pass

python opencv cv2.VideoCapture(),read(),waitKey()的使用 ret,frame参数相关推荐

  1. python opencv cv2在图片中画mask掩码/掩膜

    python opencv cv2在图片中画mask掩膜 import cv2 import numpy as np from PIL import Image import matplotlib.p ...

  2. python opencv cv2.imread

    python opencv cv2.imread 环境说明 opencv 安装 pip install opencv-python opencv:opencv_python 4.5.5.64 介绍 方 ...

  3. python opencv cv2.cvtColor()方法(将图像从一种颜色空间转换为另一种颜色空间)(转换成灰度图)

    def cvtColor(src, code, dst=None, dstCn=None): # real signature unknown; restored from __doc__" ...

  4. Python OpenCV(cv2) 摄像头开启+录像

    最近在研究opencv,也就是cv2库,想实现开启摄像头实时显示画面+录像,从网上看了不少案例和代码,动手实践时发现很多案例和代码都没有经过严格验证,导致bug不断,生成的视频文件也不能播放.经过持续 ...

  5. python opencv cv2.resize()函数

    **def resize(src, dsize, dst=None, fx=None, fy=None, interpolation=None): # real signature unknown; ...

  6. python:cv2.VideoCapture().get()/.set()及cv2.VideoWriter_fourcc()

    cv2.VideoCapture().get(propId) 获取参数 **propId**: *parameter* *function* 0:CV_CAP_PROP_POS_MSEC 视频文件的当 ...

  7. Python Opencv cv2提取图像中某种特定颜色区域(例如黑字白纸背景下的红色公章提取),并将纯色背景透明化

    拜拜PHOTOSHOP- 领导突然让我帮他把公章从图片中抠出来,在确保了不是要做坏事的情况下,我打开了PHOTOSHOP,用魔棒工具一点一点抠,但由于魔棒工具的原理是对比临近区域像素差值,导致封闭字体 ...

  8. Python OpenCV cv2和二进制图片互转

    文章目录 问题描述 代码 参考文献 问题描述 1.png https://img-blog.csdnimg.cn/20200819095325567.png 代码 import cv2 import ...

  9. python opencv cv2.rectangle 参数含义

    因为做程序图像剪切一直不太明白是怎么切片的,这里就用 cv2.rectangle 这个函数来看一下 opencv 是怎么计量图像的坐标轴的. cv2.rectangle 这个函数的作用是在图像上绘制一 ...

最新文章

  1. 一起学微软Power BI系列-使用技巧(1)连接Oracle与Mysql数据库
  2. Contact Bubble View
  3. 简述网卡的作用和工作原理_凯狄简述抽芯铆钉的作用原理
  4. 互联网1分钟 |1128
  5. CiscoIOUKeygen
  6. c语言微信昵称大全女生优雅经典的,微信昵称大全女生优雅_有深度有内涵的昵称...
  7. day6作业--游戏人生
  8. 企业c语言的编程风格,c语言优秀编程风格.docx
  9. 4.android.mk编写规范
  10. 关于方程a^x=1(mod m)的最小x解
  11. Windows 环境下运用Python制作网络爬虫
  12. monotouch在ipad中的实例应用--显示图像和文字
  13. 指针与引用的混合使用总结
  14. LKY-智慧景区可视对讲广播融合平台系统解决方案
  15. 十代主板改win7_微星(MSI)z490主板装win7系统及bios设置教程(支持10代usb驱动)
  16. 干货合辑!Ms08067安全实验室2020年度盘点
  17. 74HC573并联输出
  18. C语言程序设计第五次作业——循环结构(1)
  19. BAPI_PO_CREATE1--单价增大10倍问题
  20. 招投标行业114个数据源盘点

热门文章

  1. dram和nand哪个难生产_草缸能不能用陶粒,看完和水草泥的对比,你就知道哪个更好了...
  2. 【学习笔记】37、用正则表达式解析和提取数据
  3. 25、Power Query-日期与时间数据处理
  4. 售达方、送达方的区别
  5. 按实际价格重估在版本 0, 财政年度 2016 中不可能
  6. 你知道Material Type(ROH,HALB,FERT…)为什么缩写是ROH,HALB,FERT吗?哈哈哈
  7. ABAP EXCEL 上传 和下载 过程
  8. 发挥数据库价值,企业实现最大数据价值挖掘的路径在这里
  9. 万亿市场下,电商代运营还需另求“第二曲线”
  10. 计算机里的文件弄不到桌面怎么办,笔记本电脑桌面上的文件夹不见了怎么办