コード例 #1
0
        public void AnnSelectionChanged(object sender)
        {
            CamWindowViewModel.mDeleteVertices();
            foreach (var thisAnnoShapeModel in AnnoShapeModelCollection)
            {
                thisAnnoShapeModel.Shape.Fill   = defaultBrush;
                thisAnnoShapeModel.Shape.Stroke = defaultStroke;
            }
            if (sender != null)
            {
                AnnoShapeModel thisAnnoShapeModel = sender as AnnoShapeModel;
                SelectedAnnoShapeModel = thisAnnoShapeModel;
                if (SelectedAnnoShapeModel.shapetype != ShapeType.line)
                {
                    SelectedAnnoShapeModel.Shape.Fill = selectedBrush;
                }

                CamWindowViewModel.AnnSelectionChanged();

                SelectedAnnoShapeModel.Shape.Stroke = selectedStroke;
                SignImage = SelectedAnnoShapeModel.signImageSource;
                NotifyOfPropertyChange(() => SignImage);
                CroppedBoxViewModel = new CroppedBoxViewModel(SelectedAnnoShapeModel, selectedImageNodeModel);
                GC.Collect();
            }
        }
コード例 #2
0
ファイル: httpRequest.cs プロジェクト: gtod8010/IngAnnC
        //DELETE /api/v1/annotation/one/:image
        //outout : 성공 - 0 / bad request - 1 / server 문제 - 2 / 기타문제 - 3
        public int deleteAnnotation(AnnoShapeModel annoShapeModel)
        {
            string responseBody;
            HttpResponseMessage response;

            var entrypoint = String.Format("/api/v1/annotation/one/{0}/{1}", annoShapeModel.imageid, annoShapeModel.uniqueShapeid);

            try
            {
                response = client.DeleteAsync(entrypoint).Result;
                response.EnsureSuccessStatusCode();
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine(String.Format("\nThe request : {0}is fail!", entrypoint));
                Console.WriteLine("Message :{0} ", e.Message);
                return(2);
            }

            try
            {
                responseBody = response.Content.ReadAsStringAsync().Result;
            }
            catch (Exception e)
            {
                Console.WriteLine("response body is not readable");
                return(3);
            }
            return(0);
        }
コード例 #3
0
ファイル: httpRequest.cs プロジェクト: gtod8010/IngAnnC
        public void assignColRowFromshapeCoordsJson(JToken coords, AnnoShapeModel annoShapeModel)
        {
            switch (annoShapeModel.shapetype)
            {
            case ShapeType.none:
                break;

            case ShapeType.point:
                annoShapeModel.col.Add(coords.Value <double>("x"));
                annoShapeModel.row.Add(coords.Value <double>("y"));
                break;

            case ShapeType.boundingbox:
                JArray bBoxCoords = coords as JArray;
                annoShapeModel.col.Add(coords[0].Value <double>("x"));
                annoShapeModel.row.Add(coords[0].Value <double>("y"));
                annoShapeModel.col.Add(coords[1].Value <double>("x"));
                annoShapeModel.row.Add(coords[1].Value <double>("y"));
                annoShapeModel.width  = coords[2].Value <double>("width");
                annoShapeModel.height = coords[2].Value <double>("height");
                break;

            case ShapeType.line:
            case ShapeType.polygon:
                JArray points = coords as JArray;
                foreach (var point in points)
                {
                    annoShapeModel.col.Add(point.Value <double>("x"));
                    annoShapeModel.row.Add(point.Value <double>("y"));
                }
                break;
            }
            return;
        }
コード例 #4
0
        public void MouseUp(MouseEventArgs e)
        {
            if (_annoShapeModel != null)
            {
                mGetCurrentSize();
                switch (selectedShapeType)
                {
                case ShapeType.boundingbox:
                    _annoShapeModel.row.Add(_annoShapeModel.row[0] + OriginalHeight * boundingBoxShape.Height / CurrentHeight);
                    _annoShapeModel.col.Add(_annoShapeModel.col[0] + OriginalWidth * boundingBoxShape.Width / CurrentWidth);

                    _annoShapeModel.width  = _annoShapeModel.col[1] - _annoShapeModel.col[0];
                    _annoShapeModel.height = _annoShapeModel.row[1] - _annoShapeModel.row[0];

                    GetCamWindowView().ImageCanvas.Children.Remove(boundingBoxShape);
                    if (_annoShapeModel.width < 30 | _annoShapeModel.height < 30)
                    {
                        _annoShapeModel = null;
                        return;
                    }
                    mRegisterAnnShape(_annoShapeModel);

                    mDrawAnnShapeModel(_annoShapeModel);

                    ShellView.ShapeDataGrid.SelectedIndex = AnnoShapeModelCollection.IndexOf(_annoShapeModel);

                    _annoShapeModel = null;
                    break;

                case ShapeType.point:
                    _annoShapeModel.row.Add(OriginalHeight * downPoint.Y / CurrentHeight);
                    _annoShapeModel.col.Add(OriginalWidth * downPoint.X / CurrentWidth);

                    _annoShapeModel.width  = OriginalWidth * 8 / CurrentWidth;
                    _annoShapeModel.height = OriginalHeight * 8 / CurrentHeight;

                    mRegisterAnnShape(_annoShapeModel);

                    GetCamWindowView().ImageCanvas.Children.Remove(pointShape);
                    mDrawAnnShapeModel(_annoShapeModel);

                    ShellView.ShapeDataGrid.SelectedIndex = AnnoShapeModelCollection.IndexOf(_annoShapeModel);

                    _annoShapeModel = null;
                    break;

                case ShapeType.line:
                    _annoShapeModel.row.Add(OriginalHeight * downPoint.Y / CurrentHeight);
                    _annoShapeModel.col.Add(OriginalWidth * downPoint.X / CurrentWidth);
                    break;

                case ShapeType.polygon:
                    _annoShapeModel.row.Add(OriginalHeight * downPoint.Y / CurrentHeight);
                    _annoShapeModel.col.Add(OriginalWidth * downPoint.X / CurrentWidth);
                    break;
                }
            }
            GC.Collect();
        }
コード例 #5
0
ファイル: httpRequest.cs プロジェクト: gtod8010/IngAnnC
        private JObject getPointJson(AnnoShapeModel annoShapeModel)
        {
            var point = new JObject();

            point.Add("x", annoShapeModel.col[0]);
            point.Add("y", annoShapeModel.row[0]);

            return(point);
        }
コード例 #6
0
        public void Handle(ShapeType message)
        {
            selectedShapeType = message;
            NotifyOfPropertyChange(() => selectedShapeType);

            _annoShapeModel = null;
            polylineCollection.Clear();
            polygonCollection.Clear();
        }
コード例 #7
0
        public void AnnMouseRightButtonDown(object sender)
        {
            var            menuItem           = (MenuItem)sender;
            var            contextMenu        = (ContextMenu)menuItem.Parent;
            var            item               = (DataGrid)contextMenu.PlacementTarget;
            AnnoShapeModel thisAnnoShapeModel = (AnnoShapeModel)item.SelectedItem;

            if (thisAnnoShapeModel != null)
            {
                CamWindow.ImageCanvas.Children.Remove(thisAnnoShapeModel.Shape);
                AnnoShapeModelCollection.Remove(thisAnnoShapeModel);
            }
        }
コード例 #8
0
ファイル: httpRequest.cs プロジェクト: gtod8010/IngAnnC
        private JArray getPolyJson(AnnoShapeModel annoShapeModel)
        {
            var poly = new JArray();

            foreach (var item in annoShapeModel.col.Select((value, index) => new { Value = value, Index = index }))
            {
                double x = item.Value;
                double y = annoShapeModel.row[item.Index];

                var singlePoint = new JObject();

                singlePoint.Add("x", x);
                singlePoint.Add("y", y);

                poly.Add(singlePoint);
            }

            return(poly);
        }
コード例 #9
0
ファイル: httpRequest.cs プロジェクト: gtod8010/IngAnnC
        private JArray getBboxJson(AnnoShapeModel annoShapeModel)
        {
            var pointList = new JArray();
            var point1    = new JObject();
            var point2    = new JObject();
            var RectSize  = new JObject();

            point1.Add("x", annoShapeModel.col[0]);
            point1.Add("y", annoShapeModel.row[0]);

            point2.Add("x", annoShapeModel.col[1]);
            point2.Add("y", annoShapeModel.row[1]);

            RectSize.Add("width", annoShapeModel.width);
            RectSize.Add("height", annoShapeModel.height);

            pointList.Add(point1);
            pointList.Add(point2);
            pointList.Add(RectSize);
            return(pointList);
        }
コード例 #10
0
        public void MouseDoubleClick(MouseEventArgs e)
        {
            if (_annoShapeModel != null)
            {
                switch (selectedShapeType)
                {
                case ShapeType.line:
                    if (polylineCollection.Count == 2)
                    {
                        polylineCollection.Clear();
                        return;
                    }
                    mRegisterAnnShape(_annoShapeModel);
                    GetCamWindowView().ImageCanvas.Children.Remove(lineShape);
                    polylineCollection.Clear();
                    break;

                case ShapeType.polygon:
                    if (polygonCollection.Count == 2)
                    {
                        polygonCollection.Clear();
                        return;
                    }
                    mRegisterAnnShape(_annoShapeModel);
                    GetCamWindowView().ImageCanvas.Children.Remove(polygonShape);
                    polygonCollection.Clear();
                    break;

                default:
                    return;
                }
                mDrawAnnShapeModel(_annoShapeModel);
                e.Handled = true;
                ShellView.ShapeDataGrid.SelectedIndex = AnnoShapeModelCollection.IndexOf(_annoShapeModel);
                httpRequestClient.addAnnotation(_annoShapeModel);
                _annoShapeModel = null;
            }
        }
コード例 #11
0
 public void mRegisterAnnShape(AnnoShapeModel annoShapeModel)
 {
     AnnoShapeModelCollection.Add(annoShapeModel);
 }
コード例 #12
0
        public void mLoadCsv()
        {
            if (File.Exists(SelectedImageNodeModel.AnnCsvPath))
            {
                using (FileStream fs = new FileStream(SelectedImageNodeModel.AnnCsvPath, FileMode.Open))
                {
                    using (StreamReader sr = new StreamReader(fs, Encoding.UTF8, false))
                    {
                        //string Lines = sr.ReadLine();
                        string   Lines;
                        string[] Values;
                        //if (Lines != null)
                        //    Values = Lines.Split(',');

                        while ((Lines = sr.ReadLine()) != null)
                        {
                            Values = Lines.Split(',');

                            if (SelectedImageNodeModel.imageid == Convert.ToInt32(Values[0]))
                            {
                                _annoShapeModel         = new AnnoShapeModel(selectedShapeType);
                                _annoShapeModel.imageid = Convert.ToInt32(Values[0]);
                                _annoShapeModel.shapeid = Convert.ToInt32(Values[1]);

                                _annoShapeModel.signfield = mIdentifySignField(Convert.ToInt32(Values[2]));
                                _annoShapeModel.shapetype = (ShapeType)Enum.Parse(typeof(ShapeType), Values[3]);

                                string[] rows = Values[4].Split(';');
                                if (rows.Length == 0)
                                {
                                    _annoShapeModel.row.Add(Convert.ToDouble(Values[4]));
                                }
                                for (int i = 0; i < rows.Length - 1; i++)
                                {
                                    _annoShapeModel.row.Add(Convert.ToDouble(rows[i]));
                                }

                                string[] cols = Values[5].Split(';');
                                if (cols.Length == 0)
                                {
                                    _annoShapeModel.col.Add(Convert.ToDouble(Values[5]));
                                }
                                for (int i = 0; i < cols.Length - 1; i++)
                                {
                                    _annoShapeModel.col.Add(Convert.ToDouble(cols[i]));
                                }

                                _annoShapeModel.width           = Convert.ToDouble(Values[6]);
                                _annoShapeModel.height          = Convert.ToDouble(Values[7]);
                                _annoShapeModel.memo            = Convert.ToString(Values[8]);
                                _annoShapeModel.signImageSource = "/Resources/" + ((int)_annoShapeModel.signfield).ToString() + ".png";
                                mRegisterAnnShape(_annoShapeModel);
                                mDrawAnnShapeModel(_annoShapeModel);
                                _annoShapeModel = null;
                            }
                        }
                        sr.Close();
                    }
                    fs.Dispose();
                    fs.Close();
                }
            }
        }
コード例 #13
0
        public void LeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            downPoint = e.GetPosition(GetCamWindowView().SelectedImageNode as Image);

            switch (selectedShapeType)
            {
            case ShapeType.boundingbox:
                var boundingBoxRect = new Rectangle()
                {
                    Stroke          = defaultStroke,
                    Fill            = defaultBrush,
                    Height          = 1,
                    Width           = 1,
                    StrokeThickness = 1,
                    Margin          = new Thickness(downPoint.X, downPoint.Y, 0, 0)
                };
                boundingBoxShape = boundingBoxRect;
                GetCamWindowView().ImageCanvas.Children.Add(boundingBoxShape);
                break;

            case ShapeType.point:
                var pointEllipse = new Ellipse()
                {
                    Stroke          = defaultStroke,
                    Fill            = defaultBrush,
                    Height          = 8,
                    Width           = 8,
                    StrokeThickness = 1,
                    Margin          = new Thickness(downPoint.X, downPoint.Y, 0, 0)
                };
                pointShape = pointEllipse;
                GetCamWindowView().ImageCanvas.Children.Add(pointShape);
                break;

            case ShapeType.line:
                if (polylineCollection.Count == 0)
                {
                    var linePolyline = new Polyline()
                    {
                        Stroke          = defaultStroke,
                        Fill            = defaultBrush,
                        StrokeThickness = 1,
                        FillRule        = FillRule.EvenOdd
                    };
                    polylineCollection.Add(downPoint);
                    linePolyline.Points = polylineCollection;
                    lineShape           = linePolyline;
                    GetCamWindowView().ImageCanvas.Children.Add(lineShape);
                    mDrawTempLine(downPoint);
                }
                else
                {
                    polylineCollection.Add(downPoint);
                    mDrawTempLine(downPoint);
                    return;
                }
                break;

            case ShapeType.polygon:
                if (polygonCollection.Count == 0)
                {
                    var polygonPolygon = new Polygon()
                    {
                        Stroke          = defaultStroke,
                        Fill            = defaultBrush,
                        StrokeThickness = 1,
                        FillRule        = FillRule.EvenOdd
                    };
                    polygonCollection.Add(downPoint);
                    polygonPolygon.Points = polygonCollection;
                    polygonShape          = polygonPolygon;
                    GetCamWindowView().ImageCanvas.Children.Add(polygonShape);
                    mDrawTempLine(downPoint);
                }
                else
                {
                    polygonCollection.Add(downPoint);
                    mDrawTempLine(downPoint);
                    return;
                }
                break;

            default:
                return;
            }
            _annoShapeModel           = new AnnoShapeModel(selectedShapeType);
            _annoShapeModel.signfield = SelectedAnnoShapeModel.signfield;
            _annoShapeModel.imageid   = SelectedImageNodeModel.imageid;
            _annoShapeModel.shapeid   = mDecideShapeid();
        }
コード例 #14
0
 public void Handle(AnnoShapeModel message)
 {
     SelectedAnnoShapeModel = message;
 }
コード例 #15
0
ファイル: httpRequest.cs プロジェクト: gtod8010/IngAnnC
        //GET /api/v1/annotation/multiple/:image
        public List <AnnoShapeModel> getAnnotations(int imageId)
        {
            List <AnnoShapeModel> annoShapes = new List <AnnoShapeModel>();

            string responseBody;
            HttpResponseMessage response;

            var entrypoint = String.Format("api/v1/annotation/multiple/{0}?annotations=[\"all\"]", imageId);

            try
            {
                response = client.GetAsync(entrypoint).Result;
                response.EnsureSuccessStatusCode();
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine(String.Format("\nThe request : {0}is fail!", entrypoint));
                Console.WriteLine("Message :{0} ", e.Message);
                return(annoShapes);
            }

            try
            {
                responseBody = response.Content.ReadAsStringAsync().Result;
            }
            catch (Exception e)
            {
                Console.WriteLine("response body is not readable");
                return(annoShapes);
            }


            JObject resJsonObj         = JObject.Parse(responseBody);
            var     annotationJsonList = resJsonObj.SelectToken("annotations");

            if (annotationJsonList == null)
            {
                return(annoShapes);
            }
            foreach (var annotationJsonObj in annotationJsonList)
            {
                List <double> cols        = new List <double>();
                List <double> rows        = new List <double>();
                int           shapeId     = annotationJsonObj.Value <int>("shape_id");
                string        typeString  = annotationJsonObj.Value <string>("shape_type");
                ShapeType     shapeType   = stringToShapeType(typeString);
                int           shapeClass  = annotationJsonObj.Value <int>("class");
                int           recognition = annotationJsonObj.Value <int>("recognition");
                var           signField   = mIdentifySignField(recognition);
                var           shapeCoord  = annotationJsonObj.SelectToken(typeString);

                AnnoShapeModel annoShapeModel = new AnnoShapeModel(shapeType);
                annoShapeModel.uniqueShapeid = shapeId;
                annoShapeModel.imageid       = imageId;
                annoShapeModel.shapetype     = shapeType;
                annoShapeModel.signfield     = signField;
                annoShapeModel.col           = cols;
                annoShapeModel.row           = rows;
                assignColRowFromshapeCoordsJson(shapeCoord, annoShapeModel);

                if (annotationJsonObj.SelectToken("memo") != null)
                {
                    annoShapeModel.memo = annotationJsonObj.Value <string>("memo");
                }

                annoShapes.Add(annoShapeModel);
            }
            return(annoShapes);
        }
コード例 #16
0
ファイル: httpRequest.cs プロジェクト: gtod8010/IngAnnC
 //DELETE /api/v1/annotation/one/:image
 //outout : 성공 - 0 / bad request - 1 / server 문제 - 2
 public int deleteAnnotation(AnnoShapeModel annoShapeModel)
 {
     return(0);
 }
コード例 #17
0
ファイル: httpRequest.cs プロジェクト: gtod8010/IngAnnC
 //PUT /api/v1/annotation/one/:image
 public JObject modifyAnnotation(AnnoShapeModel annoShapeModel)
 {
     return(new JObject());
 }
コード例 #18
0
ファイル: httpRequest.cs プロジェクト: gtod8010/IngAnnC
        // input : curl -X GET /api/v1/image/urls/5
        // output :

        /*
         * (
         * 'status' : 'success',
         * 'images' : [{
         * 'pvrid' : 1201101012345, 'width' : 13000, 'height' : 6500,
         * 'img_url' : 'stryx.iptime.org/imagepath/image1.jpg'
         * },{
         * 'pvrid' : 1201101012346, 'width' : 13000, 'height' : 6500,
         * 'img_url' : 'stryx.iptime.org/imagepath/image2.jpg'
         * },{
         * 'pvrid' : 1201101012347, 'width' : 13000, 'height' : 6500,
         * 'img_url' : 'stryx.iptime.org/imagepath/image3.jpg'
         * },{
         * 'pvrid' : 1201101012348, 'width' : 13000, 'height' : 6500,
         * 'img_url' : 'stryx.iptime.org/imagepath/image4.jpg'
         * },{
         * 'pvrid' : 1201101012349, 'width' : 13000, 'height' : 6500,
         * 'img_url' : 'stryx.iptime.org/imagepath/image5.jpg'
         * }
         * ]
         * }
         */

        //POST /api/v1/annotation/one/:image
        public AnnoShapeModel addAnnotation(AnnoShapeModel annoShapeModel)
        {
            return(annoShapeModel);
        }
コード例 #19
0
 public void Handle(AnnoShapeModel message)
 {
     SelectedAnnoShapeModel = message;
     selectedSignField      = SelectedAnnoShapeModel.signfield;
 }
コード例 #20
0
        public void mDrawAnnShapeModel(AnnoShapeModel thisAnnoShapeModel)
        {
            mGetCurrentSize();
            switch (thisAnnoShapeModel.shapetype)
            {
            case ShapeType.boundingbox:
                var boundingBoxRect = new Rectangle()
                {
                    Stroke          = defaultStroke,
                    Fill            = defaultBrush,
                    Height          = CurrentHeight * thisAnnoShapeModel.height / OriginalHeight,
                    Width           = CurrentWidth * thisAnnoShapeModel.width / OriginalWidth,
                    StrokeThickness = 1,
                    Margin          = new Thickness(CurrentWidth * thisAnnoShapeModel.col[0] / OriginalWidth, CurrentHeight * thisAnnoShapeModel.row[0] / OriginalHeight, 0, 0)
                };
                thisAnnoShapeModel.Shape = boundingBoxRect;

                AddEventHandlers(boundingBoxRect);

                GetCamWindowView().ImageCanvas.Children.Add(boundingBoxRect);
                break;

            case ShapeType.point:
                var pointEllipse = new Ellipse()
                {
                    Stroke          = defaultStroke,
                    Fill            = defaultBrush,
                    Height          = 8,
                    Width           = 8,
                    StrokeThickness = 1,
                    Margin          = new Thickness(CurrentWidth * thisAnnoShapeModel.col[0] / OriginalWidth, CurrentHeight * thisAnnoShapeModel.row[0] / OriginalHeight, 0, 0)
                };
                thisAnnoShapeModel.Shape = pointEllipse;
                AddEventHandlers(pointEllipse);
                GetCamWindowView().ImageCanvas.Children.Add(pointEllipse);
                break;

            case ShapeType.line:
                var linePolyline = new Polyline()
                {
                    Stroke          = defaultStroke,
                    Fill            = defaultBrush,
                    StrokeThickness = 1,
                    FillRule        = FillRule.EvenOdd
                };
                PointCollection linePolylineCollection = new PointCollection();

                for (int i = 0; i < thisAnnoShapeModel.row.Count; i++)
                {
                    Point point = new Point()
                    {
                        X = CurrentWidth * thisAnnoShapeModel.col[i] / OriginalWidth, Y = CurrentHeight * thisAnnoShapeModel.row[i] / OriginalHeight
                    };
                    linePolylineCollection.Add(point);
                }
                linePolyline.Points = linePolylineCollection;

                thisAnnoShapeModel.Shape = linePolyline;
                AddEventHandlers(linePolyline);
                GetCamWindowView().ImageCanvas.Children.Add(linePolyline);
                break;

            case ShapeType.polygon:
                var polygonPolygon = new Polygon()
                {
                    Stroke          = defaultStroke,
                    Fill            = defaultBrush,
                    StrokeThickness = 1,
                    FillRule        = FillRule.EvenOdd
                };
                PointCollection polygonPolygonCollection = new PointCollection();

                for (int i = 0; i < thisAnnoShapeModel.row.Count; i++)
                {
                    Point point = new Point()
                    {
                        X = CurrentWidth * thisAnnoShapeModel.col[i] / OriginalWidth, Y = CurrentHeight * thisAnnoShapeModel.row[i] / OriginalHeight
                    };
                    polygonPolygonCollection.Add(point);
                }
                polygonPolygon.Points = polygonPolygonCollection;

                thisAnnoShapeModel.Shape = polygonPolygon;
                AddEventHandlers(polygonPolygon);
                GetCamWindowView().ImageCanvas.Children.Add(polygonPolygon);
                break;
            }
        }
コード例 #21
0
ファイル: httpRequest.cs プロジェクト: gtod8010/IngAnnC
        //PUT /api/v1/annotation/one/:image
        //outout : 성공 - 0 / bad request - 1 / server 문제 - 2 / 기타문제 - 3
        public int modifyAnnotation(AnnoShapeModel annoShapeModel)
        {
            string responseBody;
            HttpResponseMessage response;


            var annotationJson = new JObject();

            annotationJson.Add("shape_id", annoShapeModel.uniqueShapeid);
            annotationJson.Add("shape_type", shapeTypeEnumToSring(annoShapeModel.shapetype));
            annotationJson.Add("class", 0);
            annotationJson.Add("recognition", Convert.ToInt32(annoShapeModel.signfield));
            if (annoShapeModel.memo != null && !string.Equals(annoShapeModel.memo, ""))
            {
                annotationJson.Add("memo", annoShapeModel.memo);
            }


            switch (annoShapeModel.shapetype)
            {
            case ShapeType.point:
                annotationJson.Add("point", getPointJson(annoShapeModel));
                break;

            case ShapeType.boundingbox:
                annotationJson.Add("bbox", getBboxJson(annoShapeModel));
                break;

            case ShapeType.line:
                annotationJson.Add("polyline", getPolyJson(annoShapeModel));
                break;

            case ShapeType.polygon:
                annotationJson.Add("polygon", getPolyJson(annoShapeModel));
                break;
            }

            string entrypoint = String.Format("/api/v1/annotation/one/{0}", annoShapeModel.imageid);

            try
            {
                response = client.PutAsJsonAsync(entrypoint, annotationJson).Result;
                response.EnsureSuccessStatusCode(); // 오류 코드를 던집니다.
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine(String.Format("\nThe request : {0}is fail!", entrypoint));
                Console.WriteLine("Message :{0} ", e.Message);
                return(2);
            }

            try
            {
                responseBody = response.Content.ReadAsStringAsync().Result;
            }
            catch (Exception e)
            {
                Console.WriteLine("response body is not readable");
                return(3);
            }


            return(0);
        }
コード例 #22
0
        public void mTranslatePosition(AnnoShapeModel thisnAnnoShapeModel)
        {
            try
            {
                mGetCurrentSize();
                L_X = (SelectedAnnoShapeModel.col[0]) / OriginalWidth * CurrentWidth - size / 2;
                U_Y = (SelectedAnnoShapeModel.row[0]) / OriginalHeight * CurrentHeight - size / 2;
                R_X = (SelectedAnnoShapeModel.col[0] + SelectedAnnoShapeModel.width) / OriginalWidth * CurrentWidth - size / 2;
                D_Y = (SelectedAnnoShapeModel.row[0] + SelectedAnnoShapeModel.height) / OriginalHeight * CurrentHeight - size / 2;

                if (GetCamWindowView().ImageCanvas.Children.Contains(LD))
                {
                    LD.Margin = new Thickness(L_X, D_Y, 0, 0);
                }
                if (GetCamWindowView().ImageCanvas.Children.Contains(LU))
                {
                    LU.Margin = new Thickness(L_X, U_Y, 0, 0);
                }
                if (GetCamWindowView().ImageCanvas.Children.Contains(RU))
                {
                    RU.Margin = new Thickness(R_X, U_Y, 0, 0);
                }
                if (GetCamWindowView().ImageCanvas.Children.Contains(RD))
                {
                    RD.Margin = new Thickness(R_X, D_Y, 0, 0);
                }
                switch (thisnAnnoShapeModel.shapetype)
                {
                case ShapeType.boundingbox:
                    Rectangle boundingBox = thisnAnnoShapeModel.Shape as Rectangle;
                    boundingBox.Margin = new Thickness(CurrentWidth * thisnAnnoShapeModel.col[0] / OriginalWidth, CurrentHeight * thisnAnnoShapeModel.row[0] / OriginalHeight, 0, 0);
                    boundingBox.Width  = CurrentWidth * thisnAnnoShapeModel.width / OriginalWidth;
                    boundingBox.Height = CurrentHeight * thisnAnnoShapeModel.height / OriginalHeight;
                    break;

                case ShapeType.point:
                    Ellipse point = thisnAnnoShapeModel.Shape as Ellipse;
                    point.Margin = new Thickness(CurrentWidth * thisnAnnoShapeModel.col[0] / OriginalWidth, CurrentHeight * thisnAnnoShapeModel.row[0] / OriginalHeight, 0, 0);
                    point.Width  = CurrentWidth * thisnAnnoShapeModel.width / OriginalWidth;
                    point.Height = CurrentHeight * thisnAnnoShapeModel.height / OriginalHeight;
                    break;

                case ShapeType.line:
                    Polyline        line           = thisnAnnoShapeModel.Shape as Polyline;
                    PointCollection lineCollection = new PointCollection();
                    line.Points = null;
                    for (int i = 0; i < thisnAnnoShapeModel.row.Count; i++)
                    {
                        Point pt = new Point()
                        {
                            X = CurrentWidth * thisnAnnoShapeModel.col[i] / OriginalWidth, Y = CurrentHeight * thisnAnnoShapeModel.row[i] / OriginalHeight
                        };
                        lineCollection.Add(pt);
                    }
                    line.Points = lineCollection;
                    break;

                case ShapeType.polygon:
                    Polygon         polygon           = thisnAnnoShapeModel.Shape as Polygon;
                    PointCollection polygonCollection = new PointCollection();
                    polygon.Points = null;
                    for (int i = 0; i < thisnAnnoShapeModel.row.Count; i++)
                    {
                        Point pt = new Point()
                        {
                            X = CurrentWidth * thisnAnnoShapeModel.col[i] / OriginalWidth, Y = CurrentHeight * thisnAnnoShapeModel.row[i] / OriginalHeight
                        };
                        polygonCollection.Add(pt);
                    }
                    polygon.Points = polygonCollection;
                    break;
                }
            }
            catch
            {
            }
        }
コード例 #23
0
 public CroppedBoxViewModel(AnnoShapeModel _annoShapeModel, ImageNodeModel _imageNodeModel)
 {
     AnnoShapeModel = _annoShapeModel;
     ImageNodeModel = _imageNodeModel;
     cropImage();
 }