Exemplo n.º 1
0
        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"]);
        }