C# 如何在EmguCV中将位图转换为Mat结构&;如何检测两幅图像的偏移
亲爱的论坛成员大家好 我正在做一个项目,从安全摄像头检测视图的变化。我的意思是,当有人试图移动摄像机(某种破坏…)时,我必须注意到这一点。我的想法是:C# 如何在EmguCV中将位图转换为Mat结构&;如何检测两幅图像的偏移,c#,opencv,image-processing,bitmap,emgucv,C#,Opencv,Image Processing,Bitmap,Emgucv,亲爱的论坛成员大家好 我正在做一个项目,从安全摄像头检测视图的变化。我的意思是,当有人试图移动摄像机(某种破坏…)时,我必须注意到这一点。我的想法是: 每10秒从相机拍摄一次图像,并比较这两张照片(旧照片和实际照片) 我需要控制将近70个摄像头,所以我不能使用流媒体直播,因为它可能会占用我的互联网连接。我使用Emgu简历库来完成这项任务,但在工作中我遇到了一些问题。。下面是我编写的一段代码: public class EmguCV { static public Model Test
- 每10秒从相机拍摄一次图像,并比较这两张照片(旧照片和实际照片)
public class EmguCV
{
static public Model Test(string BaseImagePath, string ActualImagePath)
{
double noise = 0;
Mat curr64f = new Mat();
Mat prev64f = new Mat();
Mat hann = new Mat();
Mat src1 = CvInvoke.Imread(BaseImagePath, 0);
Mat src2 = CvInvoke.Imread(ActualImagePath, 0);
Size size = new Size(50, 50);
src1.ConvertTo(prev64f, Emgu.CV.CvEnum.DepthType.Cv64F);
src2.ConvertTo(curr64f, Emgu.CV.CvEnum.DepthType.Cv64F);
CvInvoke.CreateHanningWindow(hann, src1.Size, Emgu.CV.CvEnum.DepthType.Cv64F);
MCvPoint2D64f shift = CvInvoke.PhaseCorrelate(curr64f, prev64f, hann, out noise );
double value = noise ;
double radius = Math.Sqrt(shift.X * shift.X + shift.Y * shift.Y);
Model Test = new Model() { osX = shift.X, osY = shift.Y, noise = value };
return Test;
}
}
因此,我有两个问题:
Mariusz我知道现在回答这个问题已经很晚了,但今天我在互联网上寻找这个问题,我发现了类似这样的问题:
Bitmap bitmap; //This is your bitmap
Image<Bgr, byte> imageCV = new Image<Bgr, byte>(bitmap); //Image Class from Emgu.CV
Mat mat = imageCV.Mat; //This is your Image converted to Mat
位图//这是你的位图
图像imageCV=新图像(位图)//Emgu.CV中的图像类
Mat Mat=图像CV.Mat//这是您转换为Mat的图像
欢迎使用StackOverflow,您可能希望通过编辑答案并通过选择行并单击大括号{}图标将包含的代码片段转换为代码块来清理答案。我不知道,这是我第一次发布。谢谢,这仍然很有用。谢谢你节省了我的时间。