Read Video and Webcams

1.Read video

When it comes to importing videos, it’s a little bit different, because a video is basically a series of images. So, we need to iterate through all the images or all the frames and capture them one by one and display them. So for that we are going to use a while loop. So first of all let’s introduce that while loop. Then we are going to introduce our video capture object so here we are going to write video capture and then we are going to write the name. we will call it cap and now we have to define the path so the way we defined it here. the same way we are going to define the path. And then we are going to read the images one by one and we don’t want to declare it inside, so we will declare it over here we will call it math image, and then inside here we are going to read our image. So we will say that from this object. We are going to read our image and we are going to store it in this image variable so then we can display it as we displayed earlier but this time we don’t want to pause for infinity we want to give it a delay.

视频的读取与图像不同的是,视频是基于一系列图像合成的。我们需要去迭代每张图片,获取图片的每一帧,并将他们一张一张的展示出来,因此我们需要设置一个while循环,设置一个字符串提供视频路径,再利用关键字VedioCapture获取视频路径,并命名cap。设置矩阵Mat img获取图片信息,然后利用while循环读取和显示图像,关键字waitKey设置间隔时间。

 2.Read webCams

Here we can write webcam now the path is what we have to change, so instead of defining the path we can simply write an ID. So here we will remove the string and over here we are going to write the ID number of our camera, so if you have only one camera attached you can put zero. If you have multiple cameras, you are going to put it’s ID.

网络相机的导入,不需要提供存储路径,只需要在关键字VideoCapture后输入对应相机ID即可。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值