private static OpenCvSharp.CvRect FrameToPortrait(OpenCvSharp.CvRect bounds, OpenCvSharp.CvRect faceBounds) { faceBounds.X -= bounds.X; faceBounds.Y -= bounds.Y; return(faceBounds); }
public static OpenCvSharp.IplImage GetSub(this OpenCvSharp.IplImage ipl, OpenCvSharp.CvRect subRect) { if (ipl == null) { throw new ArgumentNullException("ipl", "ipl is null."); } var boundingRect = new CvRect(0, 0, ipl.Width, ipl.Height); if (!boundingRect.Contains(subRect)) { throw new InvalidOperationException("subRect is outside of ipl"); } try { ipl.SetROI(subRect); OpenCvSharp.IplImage sub = new IplImage( ipl.GetSize(), ipl.Depth, ipl.NChannels); ipl.Copy(sub); return(sub); } finally { ipl.ResetROI(); } }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="image"></param> /// <param name="roi"></param> /// <param name="mask"></param> #else /// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="image"></param> /// <param name="roi"></param> /// <param name="mask"></param> #endif public static void BGCodeBookUpdate(CvBGCodeBookModel model, CvArr image, CvRect roi, CvArr mask) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (image == null) { throw new ArgumentNullException(nameof(image)); } NativeMethods.cvBGCodeBookUpdate(model.CvPtr, image.CvPtr, roi, ToPtr(mask)); KeepAlive(model, image, mask); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="image"></param> /// <param name="roi"></param> /// <param name="mask"></param> #else /// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="image"></param> /// <param name="roi"></param> /// <param name="mask"></param> #endif public static void BGCodeBookUpdate(CvBGCodeBookModel model, CvArr image, CvRect roi, CvArr mask) { if (model == null) { throw new ArgumentNullException("model"); } if (image == null) { throw new ArgumentNullException("image"); } IntPtr maskPtr = ToPtr(mask); NativeMethods.cvBGCodeBookUpdate(model.CvPtr, image.CvPtr, roi, maskPtr); }
/// <summary> /// cvCreateSubdivDelaunay2Dで初期化 /// </summary> /// <param name="rect"></param> /// <param name="storage"></param> #else /// <summary> /// Initializes using cvCreateSubdivDelaunay2D /// </summary> /// <param name="rect"></param> /// <param name="storage"></param> #endif public CvSubdiv2D(CvRect rect, CvMemStorage storage) { if (storage == null) { throw new ArgumentNullException(); } IntPtr subdiv = NativeMethods.cvCreateSubdiv2D( SeqType.KindSubdiv2D, SizeOf, CvSubdiv2DPoint.SizeOf, CvQuadEdge2D.SizeOf, storage.CvPtr ); if (subdiv == IntPtr.Zero) { throw new OpenCvSharpException("Failed to create CvSubdiv2D"); } NativeMethods.cvInitSubdivDelaunay2D(subdiv, rect); Initialize(subdiv); holdingStorage = storage; }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="image"></param> /// <param name="roi"></param> #else /// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="image"></param> /// <param name="roi"></param> #endif public static void BGCodeBookUpdate(CvBGCodeBookModel model, CvArr image, CvRect roi) { BGCodeBookUpdate(model, image, roi, null); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="staleThresh"></param> /// <param name="roi"></param> /// <param name="mask"></param> #else /// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="staleThresh"></param> /// <param name="roi"></param> /// <param name="mask"></param> #endif public static void BGCodeBookClearStale(CvBGCodeBookModel model, int staleThresh, CvRect roi, CvArr mask) { if (model == null) { throw new ArgumentNullException(nameof(model)); } NativeMethods.cvBGCodeBookClearStale(model.CvPtr, staleThresh, roi, ToPtr(mask)); KeepAlive(model, mask); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="image"></param> /// <param name="fgmask"></param> /// <param name="roi"></param> /// <returns></returns> #else /// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="image"></param> /// <param name="fgmask"></param> /// <param name="roi"></param> /// <returns></returns> #endif public static int BGCodeBookDiff(CvBGCodeBookModel model, CvArr image, CvArr fgmask, CvRect roi) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (image == null) { throw new ArgumentNullException(nameof(image)); } if (fgmask == null) { throw new ArgumentNullException(nameof(fgmask)); } try { return(NativeMethods.cvBGCodeBookDiff(model.CvPtr, image.CvPtr, fgmask.CvPtr, roi)); } finally { KeepAlive(model, image, fgmask); } }
public void DrawToGraphics(Graphics g, CvRect dstRect);
/// <summary> /// 初期化 /// </summary> /// <param name="rect">オブジェクトを内包する矩形(グループの平均矩形)</param> /// <param name="neighbors">グループ内に存在する隣接矩形の数</param> #else /// <summary> /// Constructor /// </summary> /// <param name="rect">Bounding rectangle for the object (average rectangle of a group)</param> /// <param name="neighbors">number of neighbor rectangles in the group</param> #endif public CvAvgComp(CvRect rect, int neighbors) { this.Rect = rect; this.Neighbors = neighbors; }
/// <summary> /// /// </summary> /// <param name="image"></param> /// <param name="fgmask"></param> /// <param name="roi"></param> /// <returns></returns> #else /// <summary> /// /// </summary> /// <param name="image"></param> /// <param name="fgmask"></param> /// <param name="roi"></param> /// <returns></returns> #endif public int Diff(CvArr image, CvArr fgmask, CvRect roi) { return(Cv.BGCodeBookDiff(this, image, fgmask, roi)); }
/// <summary> /// /// </summary> /// <param name="staleThresh"></param> /// <param name="roi"></param> #else /// <summary> /// /// </summary> /// <param name="staleThresh"></param> /// <param name="roi"></param> #endif public void ClearStale(int staleThresh, CvRect roi) { Cv.BGCodeBookClearStale(this, staleThresh, roi); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="staleThresh"></param> /// <param name="roi"></param> /// <param name="mask"></param> #else /// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="staleThresh"></param> /// <param name="roi"></param> /// <param name="mask"></param> #endif public static void BGCodeBookClearStale(CvBGCodeBookModel model, int staleThresh, CvRect roi, CvArr mask) { if (model == null) { throw new ArgumentNullException("model"); } IntPtr maskPtr = ToPtr(mask); NativeMethods.cvBGCodeBookClearStale(model.CvPtr, staleThresh, roi, maskPtr); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="image"></param> /// <param name="fgmask"></param> /// <param name="roi"></param> /// <returns></returns> #else /// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="image"></param> /// <param name="fgmask"></param> /// <param name="roi"></param> /// <returns></returns> #endif public static int BGCodeBookDiff(CvBGCodeBookModel model, CvArr image, CvArr fgmask, CvRect roi) { if (model == null) { throw new ArgumentNullException("model"); } if (image == null) { throw new ArgumentNullException("image"); } if (fgmask == null) { throw new ArgumentNullException("fgmask"); } return(NativeMethods.cvBGCodeBookDiff(model.CvPtr, image.CvPtr, fgmask.CvPtr, roi)); }
/// <summary> /// /// </summary> /// <param name="mouthRect"></param> /// <param name="leftEyeRect"></param> /// <param name="rightEyeRect"></param> public CvFaceData(CvRect mouthRect, CvRect leftEyeRect, CvRect rightEyeRect) { this.MouthRect = mouthRect; this.LeftEyeRect = leftEyeRect; this.RightEyeRect = rightEyeRect; }
private void btnOk_Click(object sender, EventArgs e) { if (this.picTargetPerson.Image == null) { MessageBox.Show("请选定一张人脸图片"); return; } if (drawRectangle == Rectangle.Empty) { MessageBox.Show("请定位人脸"); return; } String oldFileName = this.picTargetPerson.Image.Tag as string; String fileName = System.Guid.NewGuid().ToString().ToUpper() + System.IO.Path.GetExtension(oldFileName); //搜索人脸 OpenCvSharp.IplImage iplFace = BitmapConverter.ToIplImage((Bitmap)this.picTargetPerson.Image); string savePath = Path.Combine(FileSavePath, fileName); iplFace.SaveImage(savePath); //归一化 OpenCvSharp.CvRect rect = new OpenCvSharp.CvRect( this.drawRectangle.X, this.drawRectangle.Y, this.drawRectangle.Width, this.drawRectangle.Height); OpenCvSharp.IplImage[] normalizedImages = Program.searcher.NormalizeImageForTraining(iplFace, rect); for (int i = 0; i < normalizedImages.Length; ++i) { string normalizedFaceName = string.Format("{0}_{1:d4}.jpg", System.IO.Path.GetFileNameWithoutExtension(fileName), i); string fullPath = System.IO.Path.Combine(faceFeatureImagePath, normalizedFaceName); normalizedImages[i].SaveImage(fullPath); } string id = txtId.Text.ToString(); string name = txtName.Text.ToString(); string sex = rabMan.Checked ? "男" : "女"; int age = 0; int.TryParse(txtAge.Text, out age); string card = txtCard.Text.ToString(); PersonInfo info = new PersonInfo(); info.ID = id; info.Name = name; info.Sex = sex; info.Age = age; info.CardId = card; info.FileName = fileName; info.Similarity = 0; perinfo.WriteInfo(info); MessageBox.Show("添加成功"); Array.ForEach(normalizedImages, ipl => ipl.Dispose()); }
public IplImage GetSubImage(CvRect rect);
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="staleThresh"></param> /// <param name="roi"></param> #else /// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="staleThresh"></param> /// <param name="roi"></param> #endif public static void BGCodeBookClearStale(CvBGCodeBookModel model, int staleThresh, CvRect roi) { BGCodeBookClearStale(model, staleThresh, roi, null); }
/// <summary> /// CvSubdiv2Dの初期化 /// </summary> /// <param name="rect"></param> #else /// <summary> /// CvSubdiv2Dの初期化 /// </summary> /// <param name="rect"></param> #endif public void InitSubdivDelaunay2D(CvRect rect) { Cv.InitSubdivDelaunay2D(this, rect); }
/// <summary> /// /// </summary> /// <param name="rect"></param> /// <param name="score"></param> #else /// <summary> /// /// </summary> /// <param name="rect"></param> /// <param name="score"></param> #endif public CvObjectDetection(CvRect rect, float score) { this.Rect = rect; this.Score = score; }
public void SetROI(CvRect rect);
/// <summary> /// /// </summary> /// <param name="staleThresh"></param> /// <param name="roi"></param> /// <param name="mask"></param> #else /// <summary> /// /// </summary> /// <param name="staleThresh"></param> /// <param name="roi"></param> /// <param name="mask"></param> #endif public void ClearStale(int staleThresh, CvRect roi, CvArr mask) { Cv.BGCodeBookClearStale(this, staleThresh, roi, mask); }
public void DrawToHDC(IntPtr hdc, CvRect dstRect);
/// <summary> /// /// </summary> /// <param name="image"></param> /// <param name="roi"></param> /// <param name="mask"></param> #else /// <summary> /// /// </summary> /// <param name="image"></param> /// <param name="roi"></param> /// <param name="mask"></param> #endif public void Update(CvArr image, CvRect roi, CvArr mask) { Cv.BGCodeBookUpdate(this, image, roi, mask); }