我偶然发现了这个youtube视频http://www.youtube.com/watch?v=Ha5LficiSJM,它演示了使用AForge.NET框架进行颜色检测的人.我想复制作者所做的但我不知道如何进行一些图像处理.
似乎AForge.NET框架允许您从Bitmap格式的视频源下拉图像.我的问题是,有人能指出我的方向或提供一些指导如何询问Bitmap对象,以找到其中的特定颜色?(例如 - 如果图像中有"红色"或"紫色"持续X秒,我想提出一个事件'ColorDetected'左右......)
有没有人对从哪里开始有任何建议?
谢谢,
-R.
编辑:我是否需要遍历整个Bitmap对象并询问每个像素的颜色?像这样:http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.getpixel.aspx
所以我一直在我的网站上分享关于上述主题标题的一些想法,关于快速,不安全的像素访问.一位先生给了我一个粗略的例子,说明他是如何用C++做的,但这对C#没有帮助,除非我可以互操作,而且互操作也很快.我在互联网上找到了一个使用MSDN帮助编写的课程,以便不安全地访问像素.这门课速度非常快,但速度不够快.这是班级:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
namespace DCOMProductions.Desktop.ScreenViewer {
public unsafe class UnsafeBitmap {
Bitmap bitmap;
// three elements used for MakeGreyUnsafe
int width;
BitmapData bitmapData = null;
Byte* pBase = null;
public UnsafeBitmap(Bitmap bitmap) {
this.bitmap = new Bitmap(bitmap);
}
public UnsafeBitmap(int width, int height) {
this.bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
}
public void Dispose() {
bitmap.Dispose();
}
public Bitmap Bitmap {
get {
return (bitmap);
}
}
private Point PixelSize {
get …Run Code Online (Sandbox Code Playgroud)