Ejemplo n.º 1
0
        /// <summary>
        /// Deserializes the object out of a JSON dynamic object.
        /// </summary>
        /// <param name="jsonObject">the JSON dynamic object</param>
        /// <returns>the deserialized object</returns>
        public new static ClarifaiURLVideo Deserialize(dynamic jsonObject)
        {
            var positiveConcepts = new List <Concept>();
            var negativeConcepts = new List <Concept>();

            if (jsonObject.data.concepts != null)
            {
                foreach (dynamic c in jsonObject.data.concepts)
                {
                    var concept = Concept.Deserialize(c);
                    if (concept.Value == 0.0M)
                    {
                        negativeConcepts.Add(concept);
                    }
                    else
                    {
                        positiveConcepts.Add(concept);
                    }
                }
            }
            JObject metadata = null;

            if (jsonObject.data.metadata != null)
            {
                metadata = (JObject)jsonObject.data.metadata;
            }
            GeoPoint geoPoint = null;

            if (jsonObject.data.geo != null)
            {
                geoPoint = GeoPoint.Deserialize(jsonObject.data.geo);
            }
            DateTime?createdAt = null;

            if (jsonObject.created_at != null)
            {
                createdAt = (DateTime)jsonObject.created_at;
            }

            ClarifaiStatus status = null;

            if (jsonObject.status != null)
            {
                status = ClarifaiStatus.Deserialize(jsonObject.status);
            }

            return(new ClarifaiURLVideo(
                       id: (string)jsonObject.id,
                       url: (string)jsonObject.data.video.url,
                       positiveConcepts: positiveConcepts,
                       negativeConcepts: negativeConcepts,
                       metadata: metadata,
                       createdAt: createdAt,
                       geo: geoPoint,
                       status: status));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deserializes the object out of a JSON dynamic object.
        /// </summary>
        /// <param name="jsonObject">the JSON dynamic object</param>
        /// <returns>the deserialized object</returns>
        public new static ClarifaiFileVideo Deserialize(dynamic jsonObject)
        {
            var positiveConcepts = new List <Concept>();
            var negativeConcepts = new List <Concept>();

            if (jsonObject.data.concepts != null)
            {
                foreach (dynamic c in jsonObject.data.concepts)
                {
                    var concept = Concept.Deserialize(c);
                    if (concept.Value == 0.0M)
                    {
                        negativeConcepts.Add(concept);
                    }
                    else
                    {
                        positiveConcepts.Add(concept);
                    }
                }
            }
            JObject metadata = null;

            if (jsonObject.data.metadata != null)
            {
                metadata = (JObject)jsonObject.data.metadata;
            }
            GeoPoint geoPoint = null;

            if (jsonObject.data.geo != null)
            {
                geoPoint = GeoPoint.Deserialize(jsonObject.data.geo);
            }
            DateTime?createdAt = null;

            if (jsonObject.created_at != null)
            {
                createdAt = (DateTime)jsonObject.created_at;
            }
            return(new ClarifaiFileVideo(
                       bytes: Convert.FromBase64String((string)jsonObject.data.video.base64),
                       id: (string)jsonObject.id,
                       positiveConcepts: positiveConcepts,
                       negativeConcepts: negativeConcepts,
                       metadata: metadata,
                       createdAt: createdAt,
                       geo: geoPoint));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Deserializes the object out of a JSON dynamic object.
        /// </summary>
        /// <param name="jsonObject">the JSON dynamic object</param>
        /// <returns>the deserialized object</returns>
        public new static ClarifaiFileImage Deserialize(dynamic jsonObject)
        {
            var positiveConcepts = new List <Concept>();
            var negativeConcepts = new List <Concept>();

            if (jsonObject.data.concepts != null)
            {
                foreach (dynamic c in jsonObject.data.concepts)
                {
                    var concept = Concept.Deserialize(c);
                    if (concept.Value == 0.0M)
                    {
                        negativeConcepts.Add(concept);
                    }
                    else
                    {
                        positiveConcepts.Add(concept);
                    }
                }
            }
            Crop crop = null;

            if (jsonObject.data.image.crop != null)
            {
                crop = DTOs.Crop.Deserialize(jsonObject.data.image.crop);
            }
            JObject metadata = null;

            if (jsonObject.data.metadata != null)
            {
                metadata = (JObject)jsonObject.data.metadata;
            }
            GeoPoint geoPoint = null;

            if (jsonObject.data.geo != null)
            {
                geoPoint = GeoPoint.Deserialize(jsonObject.data.geo);
            }
            DateTime?createdAt = null;

            if (jsonObject.created_at != null)
            {
                createdAt = (DateTime)jsonObject.created_at;
            }

            var regions = new List <Region>();

            if (jsonObject.data != null && jsonObject.data.regions != null)
            {
                foreach (dynamic region in jsonObject.data.regions)
                {
                    regions.Add(Region.Deserialize(region));
                }
            }
            return(new ClarifaiFileImage(
                       bytes: Convert.FromBase64String((string)jsonObject.data.image.base64),
                       id: (string)jsonObject.id,
                       positiveConcepts: positiveConcepts,
                       negativeConcepts: negativeConcepts,
                       crop: crop,
                       metadata: metadata,
                       createdAt: createdAt,
                       geo: geoPoint,
                       regions: regions));
        }