public ImageDetectionResult scoreSingleImage(string imagePath)
        {
            byte[] data = File.ReadAllBytes(imagePath);

            // Generate post objects
            Dictionary <string, object> postParameters = new Dictionary <string, object>();

            postParameters.Add("filename", "Image.jpg");
            postParameters.Add("fileformat", "jpg");
            postParameters.Add("file", new FileUploader.FileParameter(data, "Image.jpg", "image/jpeg"));

            // Create request and receive response
            try
            {
                HttpWebResponse webResponse = FileUploader.MultipartFormDataPost(_serviceUrl, "Prometheus", postParameters);

                if (webResponse != null)
                {
                    // Process response
                    StreamReader responseReader = new StreamReader(webResponse.GetResponseStream());
                    string       fullResponse   = responseReader.ReadToEnd();
                    webResponse.Close();

                    return(JsonConvert.DeserializeObject <ImageDetectionResult>(fullResponse));
                }

                ServiceRunning = false;
                return(null);
            }
            catch (SocketException ex)
            {
                ServiceRunning = false;
                return(null);
            }
        }
        public IEnumerable <ImageDetectionResult> scoreImageBatch(IEnumerable <string> images)
        {
            Dictionary <string, object> postParameters = new Dictionary <string, object>();

            // Generate post objects
            postParameters.Add("filename", "Image.jpg");
            postParameters.Add("fileformat", "jpg");
            int fileIndex = 0;

            foreach (var imagePath in images)
            {
                byte[] data = Settings.RESIZE_IMAGES_FACTOR == 1 ? File.ReadAllBytes(imagePath) : FileUploader.ResizedImage(imagePath, Settings.RESIZE_IMAGES_FACTOR);
                postParameters.Add(string.Format("File{0}", fileIndex++), new FileUploader.FileParameter(data, System.IO.Path.GetFileName(imagePath), "image/jpeg"));
            }

            // Create request and receive response
            try
            {
                HttpWebResponse webResponse = FileUploader.MultipartFormDataPost(_serviceUrl, "Prometheus", postParameters);

                if (webResponse != null)
                {
                    // Process response
                    StreamReader responseReader = new StreamReader(webResponse.GetResponseStream());
                    string       fullResponse   = responseReader.ReadToEnd();
                    webResponse.Close();

                    return(JsonConvert.DeserializeObject <IEnumerable <ImageDetectionResult> >(fullResponse));
                }
                ServiceRunning = false;
                return(null);
            }
            catch (SocketException ex)
            {
                Trace.WriteLine(string.Format("Exception happened {0}: {1}", ex.GetType().ToString(), ex.Message));
                ServiceRunning = false;
                return(null);
            }
        }