[英]How to convert Bitmap to Mat structur in EmguCV & How to detect two images shift
尊敬的論壇會員您好!
我正在做一個項目來檢測來自安全攝像頭的變化視圖。 我的意思是,當有人試圖移動相機(某種破壞……)時,我必須注意這一點。 我的想法是:
我需要控制將近 70 台攝像機,因此我無法使用實時流媒體,因為它可能會占用我的互聯網連接。 我使用 Emgu CV 庫來完成這項任務,但在我的工作中我遇到了一些問題.. 這是我准備的代碼:
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;
}
}
因此,我有兩個問題:
目前我根據文件路徑讀取我的圖像以從光盤進行比較。 但我想發送比較位圖集合而不保存在我的硬盤上。
問候,
馬留斯
我知道回答這個問題很晚,但今天我在互聯網上尋找這個問題,我發現了這樣的問題:
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.