我的情景:
我有一个专注于白色屏幕的相机,它正在拍摄实时信息并显示该信息。凭借FrameReceived事件的图片框。
I have a camera focused at a white screen, which is taking a live feed and displaying that feed in a picture box by virtue of a FrameReceived event.
如果在相机和屏幕之间插入了某些内容,我需要启动裁剪图像的过程。
I need to kick off a process to crop the image if something is inserted between the camera and the screen.
此过程需要在图像首次更改时开始,因此我需要将一帧与另一帧进行比较以查看是否有任何更改。
This process needs to start when the image first changes so I need to compare one frame with another to see if anything has changed.
我的努力
- 我试过哈希图像并比较它们,这不起作用,因为帧是从来没有完全一样
- 我试图循环每个像素,比较不同的值,如亮度,色调等,但这太慢了
- I尝试使用子样本循环,但它太慢或太不可靠。
- 我甚至尝试过我喜欢称之为双绞线解决方案的地方,我倒了一个然后将它们加在一起并检查结果,但这太复杂而且很慢。
- I have tried hashing the images and comparing them, which doesnt work as the frames are never exactly the same
- I have tried to loop through each pixel, comparing different values such as brightness, hue etc but this is too slow
- I have tried looping through with a sub sample but it is either too slow or too unreliable.
- I even tried what I like to call the "Twisted Pair Solution" where I inverted one then added them together and checking the result but this was far too complex and slow.
我的环境
- Visual Studio 2012(2010,如果有必要)
- Ueye camera
- C#
- 图像类型为System.Drawing.Bitmap
- Visual Studio 2012 (2010 if neccessary is available)
- Ueye camera
- C#
- The images are of type System.Drawing.Bitmap
注释
最大的问题似乎是为了可靠地得到这个结果,它需要比合理的帧速率更长的时间,这意味着在新帧进入之前计算没有完成,这意味着我用来存储前一个图像的任何变量都会在它被停止使用之前被覆盖,并且在线程构建之后似乎存在线程并且它会导致整个很多shakin 。
The biggest problem seems to be that to reliably get this result, it takes longer than we have for a reasonable frame rate, meaning that the calculation is not finished before a new frame comes in, which means that whatever variable I use to store the previous image is being overwritten before it can stop being used, and there appears to be thread after thread building up and it causes a whole lotta shakin.
推荐答案我建议使用某种图像处理库,因为默认的.Net图像处理工具有限,你可以使用图像处理库,如 www.aforgenet/framework/ 。
I would recommend using some sort of image processing library , because the default .Net image processing tools are limited ,you can use an image processing library like www.aforgenet/framework/.
例如,您可以从图像2中减去图像1,然后对差异求和。如果它们低于阈值(你选择适合你的需要)它们是相同的。
Than you can for example subtract image 1 from image 2, and sum the differences. If they are below a threshold (you choose the on the fits your need) they are identical.
或者你可以更深入地尝试这个 thecsharper/?p=94
or you can deep deeper and try this thecsharper/?p=94
更多推荐
比较实时Feed的框架
发布评论