protected override RequestedAction PostPrepareSourceBitmap(ImageState s) { if (s.sourceBitmap == null) { return(RequestedAction.None); } bool focusFaces = ("faces".Equals(s.settings["c.focus"], StringComparison.OrdinalIgnoreCase)); bool showFaces = "true".Equals(s.settings["f.show"], StringComparison.OrdinalIgnoreCase); List <Face> faces = null; //Perform face detection for either (or both) situations if (showFaces || focusFaces) { using (var detector = ConfigureDetection(s.settings)) { //Store faces s.Data["faces"] = faces = detector.DetectFeatures(s.sourceBitmap); } //Store points List <PointF> points = new List <PointF>(); foreach (Face r in faces) { points.Add(new PointF(r.X, r.Y)); points.Add(new PointF(r.X2, r.Y2)); } s.layout.AddInvisiblePolygon("faces", points.ToArray()); } //Capture and rewrite requests with &c.focus=faces if (focusFaces) { //Write the face points as focus values List <double> focusPoints = new List <double>(); foreach (Face r in faces) { focusPoints.Add(r.X); focusPoints.Add(r.Y); focusPoints.Add(r.X2); focusPoints.Add(r.Y2); } NameValueCollectionExtensions.SetList <double>(s.settings, "c.focus", focusPoints.ToArray(), false); } return(RequestedAction.None); }