protected override RequestedAction Render(ImageState s) { bool detect = NameValueCollectionExtensions.Get(s.settings, "f.detect", false); bool getlayout = NameValueCollectionExtensions.Get(s.settings, "f.getlayout", false); if (!detect && !getlayout) { return(RequestedAction.None); } var d = new DetectionResponse <Face>(); try { //Only detect faces if it was requested. if (detect) { using (var detector = ConfigureDetection(s.settings)) d.features = detector.DetectFeatures(s.sourceBitmap); } } catch (TypeInitializationException e) { throw e; } catch (Exception e) { d.message = e.Message; } d.PopulateFrom(s); throw d.GetResponseException(s.settings["callback"]); }
/// <summary> /// This is where we hijack the resizing process, interrupt it, and send back the json data we created. /// </summary> /// <param name="sender"></param> /// <param name="context"></param> /// <param name="e"></param> void Pipeline_PreHandleImage(System.Web.IHttpModule sender, System.Web.HttpContext context, Caching.IResponseArgs e) { bool detect = NameValueCollectionExtensions.Get(e.RewrittenQuerystring, "f.detect", false); bool getlayout = NameValueCollectionExtensions.Get(e.RewrittenQuerystring, "f.getlayout", false); if (!detect && !getlayout) { return; } DetectionResponse <Face> .InjectExceptionHandler(e as ResponseArgs); }