是否可以使用网络摄像头定期捕获帧 [英] Is it possible to regularly capture frames using a webcam

查看:108
本文介绍了是否可以使用网络摄像头定期捕获帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种使用普通网络摄像头定期捕捉快速更换帧的方法。



例如,我的pesudo代码是

I am looking for a way to regularly capture quickly changing frames using general webcam.

For example, my pesudo code is

int fps = 0, oldT = 0, curT = 0;
while (1)
{
   fps++;

   std::cout << fps << " ";

   oldT = curT;
   while (curT - oldT < 50) // 50ms time delay
   {   curT = timeGetTime(); }

    //capturing code

}



这意味着网络摄像头会定期捕获显示数量不断增加的屏幕。期望的结果是定期捕获的图像,其中包含越来越多的数字。



一些结果图像包含相同的数字,结果图像序列跳过一些数字,如< br $> b $ b

img1 - > 1

img2 - > 1 2

img3 - > 1 2 //不需要的结果 - >相同的数字

img4 - > 1 2 //不需要的结果 - >相同的数字

img5 - > 1 2 3 4 //不需要的结果 - >跳过号码

img6 - > 1 2 3 4 5

....



由于背景不佳,我试图定期捕捉帧。但是,现在,我怀疑是否可以使用网络摄像头。



我尝试了什么:



我在openCV 中使用了 videocapture或在directshow中使用了 ISampleGrabber ,但是,我无法获得所需的结果。



在我看来,如果这些不需要的结果是由相机内部缓冲区进行编码,则会定期显示不需要的结果。但是....我认为不必要的结果是不规则的。



拜托,帮助我..


It means that webcam regularly captures the screen which shows increasing numbers. The desired results are the regularly captured images which contain the increasing numbers.

Some of the result images contained the same numbers and the result image sequence skipped some numbers such as

img1 -> 1
img2 -> 1 2
img3 -> 1 2 // unwanted result -> same number
img4 -> 1 2 // unwanted result -> same number
img5 -> 1 2 3 4 // unwanted result -> skip number
img6 -> 1 2 3 4 5
....

With poor background, I have tried to regularly capture frames. However, now, I doubt whether it is possible using webcam.

What I have tried:

I have used either videocapture in openCV or ISampleGrabber in directshow, however, I cannot obtain the desired results.

in my opinion, if these unwanted results are due to camera internal buffers for encoding, the unwanted result are regularly presented. But....I think that the unwanted results are irregular.

please, help me..

推荐答案

有些网络摄像头没有这么强大的硬件,所以结果有局限性。尝试更强大的硬件或增强捕获间隔。



您可以通过比较图像和排序不需要的文件来检查结果。通过比较文件大小(和/或名称?),最简单的解决方案可以



最后你做了一个像OpenCV库那样的照片比较,如教程
Some web cams havent such powerful hardware so there are limitations in the result. Try more powerful hardware or enhance the capture interval.

You can check the results by comparing the images and sort out unneeded files. The simplest solution could be by comparing the file size (and or the names?).

At last you make a picture comparision like with the OpenCV libraries like described in this tutorial.


如果您正在谈论在连续帧上查看视频帧中的数字,是的,您将会错过并重复相邻帧上的数字。



Windows不是实时操作系统,因此计时器不会在确切的时间间隔内打勾。此外,无法将计时器帧速率与您使用网络摄像头捕获的视频的帧速率同步。



您将获得视频中丢失的数字和重复的数字。您在有限的测试中还没有看到的是,您将会扫描,这是一个在网络摄像头传感器扫描期间发生变化的数字。



我假设你在图像上做了某种OCR以获得这些数字。您不能依赖任何计时器或任何其他基于时间的技术来解决上述问题。您的代码只需要能够根据您的业务规则检测和处理这些情况,无论结果如何。在重复号码的情况下你会怎么做?如果跳过号码,你会怎么做?如果数字未被识别为数字,您会怎么做?你如何发现这些可能性?
If you're talking about looking at a number in a video frame on consecutive frames, yes, you're going to get missed and duplicate numbers on adjacent frames.

Windows is NOT a real-time operating system so timers don't "tick" on exact intervals. Also, there is no way to synchronize your timer "frame rate" with the frame rate of the video you're capturing with the web cam.

You WILL get numbers in your video that are missing and numbers that are duplicated. What you haven't seen yet in your limited testing is that you're going to get "tearing", a number that changes during the scan of the webcam sensor.

I'm assuming your doing some kind of OCR on the images as well to get these numbers. You cannot rely on any timer or any other time-based technique to fix the above problems. Your code is simply going to have to be able to detect and handle these cases according to your business rules, whatever those turn out to be. What do you do in the case of a duplicate number? What do you do in the case of a skipped number? What do you do in the case where the number wasn't recognized as a number? How do you detect these eventualities?


这篇关于是否可以使用网络摄像头定期捕获帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆