Structure containing details about the detected label, including bounding box, name, and level of confidence.
示例#1
0
        public ClsPrediction(ObjectType defaultObjType, Camera cam, Amazon.Rekognition.Model.Label AiDetectionObject, int InstanceIdx, ClsImageQueueItem curImg, ClsURLItem curURL)
        {
            this._defaultObjType = defaultObjType;
            this._cam            = cam;
            this._cururl         = curURL;
            this._curimg         = curImg;
            this.Camera          = cam.Name;
            this.ImageHeight     = curImg.Height;
            this.ImageWidth      = curImg.Width;

            if (AiDetectionObject == null || cam == null || string.IsNullOrWhiteSpace(AiDetectionObject.Name))
            {
                Log("Error: Prediction or Camera was null?", "", this._cam.Name);
                this.Result = ResultType.Error;
                return;
            }
            //"Name": "Car",
            //            "Confidence": 98.87621307373047,
            //            "Instances": [
            //                {
            //                    "BoundingBox": {
            //                        "Width": 0.10527367144823074,
            //                        "Height": 0.18472492694854736,
            //                        "Left": 0.0042892382480204105,
            //                        "Top": 0.5051581859588623
            //                    },
            //                    "Confidence": 98.87621307373047
            //                },

            //Rectangle(xmin, ymin, xmax - xmin, ymax - ymin)
            //          x,    y     Width,       Height

            this.RectHeight = Convert.ToInt32(Math.Round(curImg.Height * AiDetectionObject.Instances[InstanceIdx].BoundingBox.Height));
            this.RectWidth  = Convert.ToInt32(Math.Round(curImg.Width * AiDetectionObject.Instances[InstanceIdx].BoundingBox.Width));

            double right = (curImg.Width * AiDetectionObject.Instances[InstanceIdx].BoundingBox.Left) + this.RectWidth;
            double left  = curImg.Width * AiDetectionObject.Instances[InstanceIdx].BoundingBox.Left;

            double top    = curImg.Height * AiDetectionObject.Instances[InstanceIdx].BoundingBox.Top;
            double bottom = (curImg.Height * AiDetectionObject.Instances[InstanceIdx].BoundingBox.Top) + this.RectHeight;

            this.XMin = Convert.ToInt32(Math.Round(left));
            this.YMin = Convert.ToInt32(Math.Round(top));

            this.XMax = Convert.ToInt32(Math.Round(right));
            this.YMax = Convert.ToInt32(Math.Round(bottom));

            //force first letter to always be capitalized
            this.Label = Global.UpperFirst(AiDetectionObject.Name);

            this.Confidence = AiDetectionObject.Instances[InstanceIdx].Confidence;
            this.Filename   = curImg.image_path;

            this.GetObjectType();
        }