Example #1
0
        public System.Net.HttpStatusCode GetState(out Model.StateRec rec)
        {
            ValidateIsBound();

            LookRestClient client       = new LookRestClient(_device, _port, _username, _password);
            string         body         = null;
            var            responseCode = client.GetState(out body);

            Trace.TraceInformation("\nRaw JSON data:  {0}", body);

            rec = JsonHelper.JsonToStateRec(body);
            return(responseCode);
        }
Example #2
0
        public System.Net.HttpStatusCode GetSnapshot(out Model.SnapshotRec rec)
        {
            ValidateIsBound();

            var    client       = new LookRestClient(_device, _port, _username, _password);
            string body         = null;
            var    responseCode = client.GetSnapshot(out body);

            Trace.TraceInformation("\nRaw JSON data:  {0}", body);

            rec = JsonHelper.JsonToSnapshotRec(body);
            if (rec != null)
            {
                // Build full path
                rec.FullPath = string.Format("https://{0}:{1}/{2}", _device, _port, rec.Path);
            }
            return(responseCode);
        }
Example #3
0
        public HttpStatusCode GetFaces(DateTime start, DateTime end, out FacesHistoricRec faces)
        {
            ValidateIsBound();

            var    client       = new LookRestClient(_device, _port, _username, _password);
            string body         = null;
            var    responseCode = client.GetFaces(start, end, out body);

            Trace.TraceInformation("\nRaw JSON data:  {0}", body);

            if (responseCode == HttpStatusCode.OK)
            {
                faces = JsonHelper.JsonToFacesHistoricRec(body);
            }
            else
            {
                faces = null;
            }

            return(responseCode);
        }
Example #4
0
        public bool GetMostRelevantUserInfo(out int age, out Gender gender)
        {
            ValidateIsBound();
            age    = 0;
            gender = Gender.Unknown;

            var    client       = new LookRestClient(_device, _port, _username, _password);
            string body         = null;
            var    responseCode = client.GetFaces(out body);

            Trace.TraceInformation("\nRaw JSON data:  {0}", body);

            FacesRec rec = JsonHelper.JsonToFacesRec(body);

            if (rec.faces.Count < 1)
            {
                return(false);
            }
            FaceRec primaryFace = null;

            foreach (var item in rec.faces)
            {
                if (primaryFace == null)
                {
                    primaryFace = item;
                    continue;
                }
                if (item.id < primaryFace.id)
                {
                    primaryFace = item;
                }
            }
            age    = primaryFace.age;
            gender = primaryFace.gender;

            return(responseCode == System.Net.HttpStatusCode.OK);
        }