public IdentificationResponse Identify(IdentificationRequest request)
        {
            Debug.WriteLine("Request!");

            //var request = JsonConvert.DeserializeObject<IdentificationRequest>(requestJson);

            //decode

            Bitmap bmp = new Bitmap(request.Width, request.Height, PixelFormat.Format8bppIndexed);

            var rect    = new Rectangle(0, 0, request.Width, request.Height);
            var bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);

            var ptr = bmpData.Scan0;

            for (var i = 0; i < request.Height; i++)
            {
                Marshal.Copy(request.Pixels, i * request.Width, ptr, request.Width);
                ptr += bmpData.Stride;
            }

            bmp.UnlockBits(bmpData);

            var objName = ml.IdentifyObject(bmp);

            Console.WriteLine("Identified object = '" + objName + "'");

            var response = new IdentificationResponse()
            {
                ObjectName = objName
            };


            return(response);
        }
        public void SendRequest(Bitmap image)
        {
            IFormatter formatter = new BinaryFormatter();

            IdentificationRequest request = new IdentificationRequest()
            {
                Image     = image,
                Timestamp = DateTime.Now
            };

            formatter.Serialize(stream, request);

            stream.Flush();

            IdentificationResponse response = (IdentificationResponse)formatter.Deserialize(stream);

            Console.WriteLine(response.Object);
        }