Пример #1
0
        public static string AddBuildingWallImg(string jsons)//添加立面图片信息
        {
            BuildingWallImage data   = JsonConvert.DeserializeObject <BuildingWallImage>(jsons);
            string            result = HTTPService.AddWallImage(data);

            return(result);
        }
Пример #2
0
        public static string GetAssembleInfo(string id)//获取拼装的信息
        {
            int[]  ID     = JsonConvert.DeserializeObject <int[]>(id);
            string result = HTTPService.GetAssembleInfo(ID);

            return(result);
        }
Пример #3
0
        public static string GetBuidlingWallImgInfo(string id)//获取立面图片信息
        {
            int[] ID = JsonConvert.DeserializeObject <int[]>(id);

            string result = HTTPService.GetBuildingImgInfo(ID);

            return(result);
        }
Пример #4
0
        public static string UpdateBuildingBlock(string jsons)//更新板块信息
        {
            UpdateBlock block  = JsonConvert.DeserializeObject <UpdateBlock>(jsons);
            string      result = "";

            for (int i = 0; i < block.blocks.Count(); i++)
            {
                result = HTTPService.UpdateWallBlock(block.blocks[i], block.blockvalue[i]);
            }
            return(result);
        }
Пример #5
0
        public static string AddBuildingWallBlock(string jsons)//添加幕墙板块信息
        {
            int count = 0;

            try
            {
                string            path     = ConfigurationSettings.AppSettings["Savepath"];
                AddBuildingBlock  data     = JsonConvert.DeserializeObject <AddBuildingBlock>(jsons);
                BuildingWallBlock block    = new BuildingWallBlock();
                string            Response = "";
                for (int i = 0; i < data.blocks.Count(); i++)
                {
                    block.adjustedLocationTopLeftX = data.blocks[i].adjustedLocationTopLeftX;
                    block.adjustedLocationTopLeftY = data.blocks[i].adjustedLocationTopLeftY;
                    block.blockLocationTopLeftX    = data.blocks[i].blockLocationTopLeftX;
                    block.blockLocationTopLeftY    = data.blocks[i].blockLocationTopLeftY;
                    block.buildingWallBlockNo      = data.blocks[i].buildingWallBlockNo;
                    block.buildingWallId           = data.buildingWallId;
                    block.buildingWallImageId      = data.buildingWallImageId;
                    block.width  = data.blocks[i].width;
                    block.height = data.blocks[i].height;
                    if (data.blocks[i].name == null)
                    {
                        data.blocks[i].name = data.blocks[i].value;
                    }
                    Response = HTTPService.AddWallBlock(block, data.blocks[i].name, data.blocks[i].value);
                    count++;
                }
                string savepath = path + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".jpg";
                Base64Convert.Base64ToFileAndSave(data.resultImageFile, savepath);//文件流保存到文件
                int resultImageFileId = UploadFile.Upload(savepath);
                File.Delete(savepath);
                string result = HTTPService.UpdateWallimg(data.buildingWallImageId, resultImageFileId);
                return(result);
            }
            catch (Exception ex)
            {
                Console.WriteLine(count);
                Console.WriteLine(ex.Message + "," + ex.TargetSite + "," + ex.Source);
                return(ex.Message + "," + ex.TargetSite + "," + ex.Source);
            }
        }
Пример #6
0
        public static string UpdateBuildingAssemble(string jsons, string code, string img)//立面拼装信息
        {
            string save = ConfigurationSettings.AppSettings["Savepath"];

            save += DateTime.Now.ToString("yyyyMMddhhmmssff") + ".jpg";
            Base64Convert.Base64ToFileAndSave(img, save);
            JObject             jResult = JObject.Parse(jsons);
            JArray              jData   = (JArray)jResult["data"];
            List <AssembleInfo> results = jData.ToObject <List <AssembleInfo> >();

            Console.WriteLine(code);
            string result         = "";
            int    buildingWallId = 0;

            for (int i = 0; i < results.Count(); i++)
            {
                buildingWallId = HTTPService.UpdateBuidlingAssemble(results[i]);
            }
            result = HTTPService.UpdateBuildingWallAssemble(buildingWallId, code, save);
            Console.WriteLine(result);
            return(result);
        }
Пример #7
0
        /// <summary>
        /// 图像截取、矫正
        /// </summary>
        public static string Pic_Rectity(string FileName, string point_json, int originalImageFileId, int buildingWallId)
        {
            BuildingWallImage building = new BuildingWallImage();
            string            path     = ConfigurationSettings.AppSettings["Savepath"];
            string            savepath = path + DateTime.Now.ToString("yyyyMMddhhmmss") + ".jpg";

            Base64Convert.Base64ToFileAndSave(FileName, savepath);//文件流保存到文件
            Positions    positions = new Positions();
            string       filepath  = path;
            Mat          src       = Cv2.ImRead(savepath); //原始图像
            List <Point> getpt     = JsonConvert.DeserializeObject <List <Point> >(point_json);
            Mat          dst       = new Mat();
            //new Window("1", WindowMode.FreeRatio, src);
            Mat roi = Mat.Zeros(src.Size(), MatType.CV_8U);

            Point[] points = getpt.ToArray();
            int     maxX = points[0].X, maxY = points[0].Y, minX = points[0].X, minY = points[0].Y;

            Point[][] contours = { points };
            for (int i = 0; i < points.Length; i++)//求出最小坐标
            {
                if (points[i].X > maxX)
                {
                    maxX = points[i].X;
                }
                if (points[i].Y > maxY)
                {
                    maxY = points[i].Y;
                }
                if (points[i].X < minX)
                {
                    minX = points[i].X;
                }
                if (points[i].Y < minY)
                {
                    minY = points[i].Y;
                }
            }
            int width  = maxX - minX;
            int height = maxY - minY;

            Cv2.DrawContours(roi, contours, 0, Scalar.All(255), -1);
            src.CopyTo(dst, roi);//保存到新画布
            //new Window("转化前", WindowMode.FreeRatio, dst);

            dst = dst.SubMat(new Rect(minX, minY, width, height));

            Point2f[] pt = new Point2f[4];
            for (int i = 0; i < points.Length; i++)//图像坐标
            {
                pt[i].X = points[i].X - minX;
                pt[i].Y = points[i].Y - minY;
            }
            Point2f[] box = new Point2f[4];//画布角点
            box[0] = new Point(0, 0);
            box[1] = new Point(width, 0);
            box[2] = new Point(width, height);
            box[3] = new Point(0, height);
            //图像的拉伸处理
            var h = Cv2.GetPerspectiveTransform(pt, box);

            Cv2.WarpPerspective(dst, dst, h, new Size(width, height));
            string time = DateTime.Now.ToString("yyyyMMddhhmmssff") + ".jpg";

            filepath += time;
            Cv2.ImWrite(filepath, dst);
            positions.FileName            = ConfigurationSettings.AppSettings["Returnpath"] + time;
            positions.point2              = Findarea(dst);
            positions.imgFileId           = UploadFile.Upload(savepath);
            positions.adjustedImageFileId = UploadFile.Upload(filepath);
            building.adjustedImageFileId  = positions.adjustedImageFileId;
            //building.selectedImageFileId = positions.adjustedImageFileId;
            building.areaTopLeftX        = points[0].X;
            building.areaTopLeftY        = points[0].Y;
            building.areaTopRightX       = points[1].X;
            building.areaTopRightY       = points[1].Y;
            building.areaBottomLeftX     = points[2].X;
            building.areaBottomLeftY     = points[2].Y;
            building.areaBottomRightX    = points[3].X;
            building.areaBottomRightY    = points[3].Y;
            building.buildingWallId      = buildingWallId;
            building.originalImageFileId = originalImageFileId;
            building.resultImageFileId   = 1870;
            string        result = HTTPService.AddWallImage(building);
            ResultMessage s      = JsonConvert.DeserializeObject <ResultMessage>(result);

            positions.buildingWallImageId = s.data;
            string js = JsonConvert.SerializeObject(positions);

            Console.WriteLine(js);
            File.Delete(savepath);
            return(js);
        }
Пример #8
0
        public static string GetBuildingImg(int id)//获取需要修改的信息
        {
            string result = HTTPService.GetUpBuildingInfo(id);

            return(result);
        }
Пример #9
0
        public static string GetAssembleImgInfo(int id)//获取拼装信息
        {
            string result = HTTPService.GetAssembleImgInfo(id);

            return(result);
        }