//运行飞机检测程序
        //一共有四条支路:TerraSAR,JB,MiniSAR,Unknown
        private void RunDetectionButton_Click(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
            process = new Process();
            process.StartInfo.FileName         = "cmd.exe";
            process.StartInfo.WorkingDirectory = ".";
            //新加入可以得到exe结束信息的代码
            process.EnableRaisingEvents = true;
            process.Exited += new EventHandler(process_Exited);

            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardInput  = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.CreateNoWindow         = true;
            //Process.Start("cmd.exe");
            process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
            process.Start();

            string[] route_str = PluginfoldPath.Split(':');
            string   disk_pos  = route_str[0].ToString() + ":";

            process.StandardInput.WriteLine(disk_pos);
            process.StandardInput.WriteLine("cd " + PluginfoldPath + @".\\bin_detection\\");
            if (this.ChooseRSPlatformComboBox.SelectedItem.ToString() == "TerraSAR-X")
            {
                process.StandardInput.WriteLine(".\\SAR_ADR_TerraSAR_Algorithm.exe");
            }
            else if (this.ChooseRSPlatformComboBox.SelectedItem.ToString() == "J5/J7")
            {
                process.StandardInput.WriteLine(".\\SAR_ADR_JB_Algorithm.exe");
            }
            else if (this.ChooseRSPlatformComboBox.SelectedItem.ToString() == "MiniSAR")
            {
                process.StandardInput.WriteLine(".\\SAR_ADR_MiniSAR_Algorithm.exe");
            }
            else if (this.ChooseRSPlatformComboBox.SelectedItem.ToString() == "Unknown")
            {
                process.StandardInput.WriteLine(".\\SAR_ADR_Unknown_Algorithm.exe");
            }
            else
            {
                DialogResult PluginErrorMsg;
                PluginErrorMsg = MessageBox.Show("未找到适合的平台", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (PluginErrorMsg == DialogResult.OK)
                {
                    this.Dispose();
                }
                process.StandardInput.WriteLine("exit");
                process.WaitForExit();
            }
            process.BeginOutputReadLine();
            process.CloseMainWindow();
            process.StandardInput.WriteLine(">Finish");
            process.StandardInput.WriteLine("exit");

            process.WaitForExit();
        }
Exemple #2
0
        //获得图像信息按钮
        private void GetImageInfoButton_Click(object sender, EventArgs e)
        {
            #region 读取并记录图像信息,写入config.txt,ImageINFO.txt
            Control.CheckForIllegalCrossThreadCalls = false;
            process_ReadImageInfo = new Process();
            process_ReadImageInfo.StartInfo.FileName         = "cmd.exe";
            process_ReadImageInfo.StartInfo.WorkingDirectory = ".";
            //新加入可以得到exe结束信息的代码
            process_ReadImageInfo.EnableRaisingEvents = true;
            process_ReadImageInfo.Exited += new EventHandler(process_ReadImageInfo_Exited);

            process_ReadImageInfo.StartInfo.UseShellExecute        = false;
            process_ReadImageInfo.StartInfo.RedirectStandardInput  = true;
            process_ReadImageInfo.StartInfo.RedirectStandardOutput = true;
            process_ReadImageInfo.StartInfo.CreateNoWindow         = true;
            //Process.Start("cmd.exe");
            process_ReadImageInfo.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
            process_ReadImageInfo.Start();

            string[] route_str = PluginfoldPath.Split(':');
            string   disk_pos  = route_str[0].ToString() + ":";
            process_ReadImageInfo.StandardInput.WriteLine(disk_pos);
            process_ReadImageInfo.StandardInput.WriteLine("cd " + PluginfoldPath + @".\\bin_readinfo\\");
            process_ReadImageInfo.StandardInput.WriteLine(".\\GDAL_ReadImageInfo.exe");



            process_ReadImageInfo.BeginOutputReadLine();
            process_ReadImageInfo.CloseMainWindow();
            process_ReadImageInfo.StandardInput.WriteLine(">Finish");
            process_ReadImageInfo.StandardInput.WriteLine("exit");

            process_ReadImageInfo.WaitForExit();
            #endregion

            #region 从.\\bin_readinfo\\ImageINFO中读取图像信息,写入pixelsizeTxtBox
            StreamReader sr      = new StreamReader(PluginfoldPath + @".\bin_readinfo\ImageINFO.txt", Encoding.Default);
            string       Rez_s   = "";
            string       sr_line = sr.ReadLine();
            while (sr_line != null)
            {
                if (sr_line == "<PixelSize>")
                {
                    sr_line = sr.ReadLine();
                    Rez_s   = sr_line.ToString();
                }
                sr_line = sr.ReadLine();
            }
            sr.Close();
            this.pixelsizeTxtBox.AppendText(Rez_s);
            #endregion
        }
        //获得图像信息
        private void GetImageInfoButton_Click(object sender, EventArgs e)
        {
            if (SpatialDataViewer.ActiveViewControl != null || SpatialDataViewer.ActiveViewControl.View != null)
            {
                //确定当前文件夹路径
                string current_Path = Environment.CurrentDirectory;
                //确定插件文件夹路径
                this.InfoMonitor.AppendText("PluginfoldPath: " + PluginfoldPath + "\n");
                string AimFolder = PluginfoldPath;
                if (!Directory.Exists(AimFolder))
                {
                    Directory.CreateDirectory(AimFolder);
                }
                GxView _v = SpatialDataViewer.ActiveViewControl.View;
                GxImageGraphicsItem image  = _v.ImageLayer.EdittedImage;
                GxImageGraphicsItem image2 = image;
                //(1)图像名称
                string img_Name = image2.Name;
                //为每一幅图像创建文件夹树
                ImageFolder = AimFolder + @"\SAR_Result\" + img_Name;
                if (!Directory.Exists(ImageFolder))
                {
                    Directory.CreateDirectory(ImageFolder);
                }
                StreamWriter sw = new StreamWriter(AimFolder + @".\bin_readinfo\ImageINFO.txt", false, Encoding.UTF8);
                //(2)通过GxImageGraphicsItem Class下的Properties获取各种图像信息
                //(2-1)图像的绝对路径名
                this.PL_img_path = image2.FileName;

                # region 将图像路径写出,做缩略图
                //
                StreamWriter image_path = new StreamWriter(PluginfoldPath + @"\config\image_path.txt", false, Encoding.UTF8);
                image_path.Write("<ImagePath>" + "\r\n");
                image_path.Write(PL_img_path + "\r\n");
                image_path.Write("<PluginFolderPath>" + "\r\n");
                image_path.Write(PluginfoldPath + "\r\n");
                image_path.Close();
                //缩略图
                Control.CheckForIllegalCrossThreadCalls = false;
                process_Thumbnail = new Process();
                process_Thumbnail.StartInfo.FileName         = "cmd.exe";
                process_Thumbnail.StartInfo.WorkingDirectory = ".";
                //新加入可以得到exe结束信息的代码
                process_Thumbnail.EnableRaisingEvents = true;
                process_Thumbnail.Exited += new EventHandler(process_Thumbnail_Exited);

                process_Thumbnail.StartInfo.UseShellExecute        = false;
                process_Thumbnail.StartInfo.RedirectStandardInput  = true;
                process_Thumbnail.StartInfo.RedirectStandardOutput = true;
                process_Thumbnail.StartInfo.CreateNoWindow         = true;
                //Process.Start("cmd.exe");
                process_Thumbnail.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
                process_Thumbnail.Start();

                string[] route_str = PluginfoldPath.Split(':');
                string   disk_pos  = route_str[0].ToString() + ":";
                process_Thumbnail.StandardInput.WriteLine(disk_pos);
                process_Thumbnail.StandardInput.WriteLine("cd " + PluginfoldPath + @".\\bin_thumbnail\\");
                process_Thumbnail.StandardInput.WriteLine(".\\GetThumbImageFromPyramid.exe");
                //process.StandardInput.WriteLine("exit");

                process_Thumbnail.BeginOutputReadLine();
                process_Thumbnail.CloseMainWindow();
                process_Thumbnail.StandardInput.WriteLine(">Finish");
                process_Thumbnail.StandardInput.WriteLine("exit");
                // process.
                process_Thumbnail.WaitForExit();
                #endregion

                this.ImageMonitor.Image    = Image.FromFile(PluginfoldPath + @".\\bin_thumbnail\\img_thumbnail.tiff"); //动态加载缩略图片
                this.ImageMonitor.SizeMode = PictureBoxSizeMode.Zoom;                                                  //设置图片显示方式
                this.InfoMonitor.AppendText("ImagePath: " + PL_img_path + "\n");
                sw.Write("<SARImagePath>" + "\r\n");
                sw.Write(PL_img_path + "\r\n");
                sw.Write("<RefImgPath>" + "\r\n");
                sw.Write(ImageFolder + @"\img_en.tif" + "\r\n");
                this.InfoMonitor.AppendText("ImageName: " + img_Name + "\n");
                sw.Write("<OutputDir>" + "\r\n");
                sw.Write(ImageFolder + "\\" + " \r\n");
                sw.Write("<ImageName>" + "\r\n");
                sw.Write(img_Name + "\r\n");
                //(2-2) 获取图像的分辨率
                PL_img_Rez = image2.ImgPR;
                double curPixel_size = image2.CurrentImageSource.PadfTransform[1];
                string Rez_s         = PL_img_Rez.ToString();
                this.InfoMonitor.AppendText("ImageResolution: " + Rez_s + "\n");
                this.InfoMonitor.AppendText("ImagePixelSize: " + curPixel_size + "\n");
                this.pixelsizeTxtBox.AppendText(Rez_s);
                //(2-3) 获取图像尺寸信息
                PL_img_Height = image2.Height;
                PL_img_Width  = image2.Width;
                string Height_s = PL_img_Height.ToString();
                string Width_s  = PL_img_Width.ToString();
                this.InfoMonitor.AppendText("ImageHeight(Rows): " + Height_s + "\n");
                this.InfoMonitor.AppendText("ImageWidth(Columns): " + Width_s + "\n");
                sw.Write("<ImageHeight(Rows)>" + "\r\n");
                sw.Write(PL_img_Height + "\r\n");
                sw.Write("<ImageWidth(Cols)>" + "\r\n");
                sw.Write(PL_img_Width + "\r\n");
                //(2-4)获取平台中的地理经纬度(与图像旁边的一列表中的数据一致)
                LatMin  = image2.MinY;
                LatMax  = image2.MaxY;
                LongMin = image2.MinX;
                LongMax = image2.MaxX;
                if (!string.IsNullOrEmpty(image2.PszProjection))
                {
                    GeoPoint gpt  = GxView.Meter2Degree(new GeoPoint(LongMin, LatMax), image2.PszProjection);
                    GeoPoint gpt2 = GxView.Meter2Degree(new GeoPoint(LongMax, LatMin), image2.PszProjection);
                    LongMin = gpt.X;
                    LatMax  = gpt.Y;
                    LongMax = gpt2.X;
                    LatMin  = gpt2.Y;
                }
                this.InfoMonitor.AppendText("LatMin: " + LatMin + "\n");
                this.InfoMonitor.AppendText("LatMax: " + LatMax + "\n");
                this.InfoMonitor.AppendText("LongMin: " + LongMin + "\n");
                this.InfoMonitor.AppendText("LongMax: " + LongMax + "\n");
                sw.Write("<LatMin>" + "\r\n");
                sw.Write(LatMin + "\r\n");
                sw.Write("<LatMax>" + "\r\n");
                sw.Write(LatMax + "\r\n");
                sw.Write("<LongMin>" + "\r\n");
                sw.Write(LongMin + "\r\n");
                sw.Write("<LongMax>" + "\r\n");
                sw.Write(LongMax + "\r\n");

                sw.Write("<PixelSize>" + "\r\n");
                sw.Write(PL_img_Rez + "\r\n");
                sw.Write("<CooridinateDelta>" + "\r\n");
                sw.Write(0 + "\r\n");
                sw.Close();
                //用C#写config.txt
                StreamWriter config_W = new StreamWriter(AimFolder + @".\config\config.txt", false, Encoding.UTF8);
                config_W.Write("<SARImagePath>" + "\r\n");
                config_W.Write(PL_img_path + "\r\n");
                config_W.Write("<SARImageName>" + "\r\n");
                config_W.Write(img_Name + "\r\n");
                config_W.Write("<MaskPath>" + "\r\n");
                config_W.Write(ImageFolder + @"\SAR_maskimg.tif" + "\r\n");
                config_W.Write("<RefImgPath>" + "\r\n");
                config_W.Write(ImageFolder + @"\img_en.tif" + "\r\n");
                config_W.Write("<TemplatePath>" + "\r\n");
                config_W.Write(AimFolder + @"\Template\" + "\r\n");
                config_W.Write("<ResultImagePath>" + "\r\n");
                config_W.Write(ImageFolder + @"\" + "\r\n");
                config_W.Write("<ResultXmlPath>" + "\r\n");
                config_W.Write(ImageFolder + @"\" + img_Name + "_SAR.xml" + "\r\n");
                config_W.Write("<SARFusionXmlPath>" + "\r\n");
                config_W.Write(ImageFolder + @"\" + img_Name + "_SAR_Fusion.xml" + "\r\n");
                config_W.Write("<Opt_ResultTXTPath>" + "\r\n");
                config_W.Write(ImageFolder + @"\Opt_result.txt" + "\r\n");
                config_W.Write("<SAR_ResultTXTPath>" + "\r\n");
                config_W.Write(ImageFolder + @"\SAR_result.txt" + "\r\n");

                config_W.Write("<Platform>" + "\r\n");
                config_W.Write("Unknown" + "\r\n");
                config_W.Write("<MinLongtitude>" + "\r\n");
                config_W.Write(LongMin + "\r\n");
                config_W.Write("<MaxLongitude>" + "\r\n");
                config_W.Write(LongMax + "\r\n");
                config_W.Write("<MinLatitude>" + "\r\n");
                config_W.Write(LatMin + "\r\n");
                config_W.Write("<MaxLatitude>" + "\r\n");
                config_W.Write(LatMax + "\r\n");
                config_W.Write("<PixelSize>" + "\r\n");
                config_W.Write(PL_img_Rez + "\r\n");
                config_W.Write("<ImageRows>" + "\r\n");
                config_W.Write(image2.Height + "\r\n");
                config_W.Write("<ImageCols>" + "\r\n");
                config_W.Write(image2.Width + "\r\n");
                config_W.Close();
            }
Exemple #4
0
        //载入图像按钮
        private void LoadImageBtn_Click(object sender, EventArgs e)
        {
            #region 打开文件夹面板,选取图像
            //选择文件
            OpenFileDialog openFileDialog_SARImage = new OpenFileDialog();
            openFileDialog_SARImage.Multiselect = true;
            //文件格式
            openFileDialog_SARImage.Filter = "SAR图像文件|*.tif;*.tiff;*.TIF;*.TIFF";
            //还原当前目录
            openFileDialog_SARImage.RestoreDirectory = true;
            openFileDialog_SARImage.FilterIndex      = 1;
            if (openFileDialog_SARImage.ShowDialog() == DialogResult.OK)
            {
                ImagePath = openFileDialog_SARImage.FileName;
                img_Name  = System.IO.Path.GetFileNameWithoutExtension(ImagePath);
            }
            #endregion

            #region 将图像路径写出,做缩略图
            //获取UI.exe所在路径
            PluginfoldPath = System.Windows.Forms.Application.StartupPath;
            //创建文件夹树
            ImageFolder = PluginfoldPath + @"\SAR_Result\" + img_Name;
            if (!Directory.Exists(ImageFolder))
            {
                Directory.CreateDirectory(ImageFolder);
            }

            StreamWriter image_path = new StreamWriter(PluginfoldPath + @"\config\image_path.txt", false, Encoding.Default);
            image_path.Write("<ImagePath>" + "\r\n");
            image_path.Write(ImagePath + "\r\n");
            image_path.Write("<PluginFolderPath>" + "\r\n");
            image_path.Write(PluginfoldPath + "\r\n");
            image_path.Close();
            //缩略图
            Control.CheckForIllegalCrossThreadCalls = false;
            process_Thumbnail = new Process();
            process_Thumbnail.StartInfo.FileName         = "cmd.exe";
            process_Thumbnail.StartInfo.WorkingDirectory = ".";
            //新加入可以得到exe结束信息的代码
            process_Thumbnail.EnableRaisingEvents = true;
            process_Thumbnail.Exited += new EventHandler(process_Thumbnail_Exited);

            process_Thumbnail.StartInfo.UseShellExecute        = false;
            process_Thumbnail.StartInfo.RedirectStandardInput  = true;
            process_Thumbnail.StartInfo.RedirectStandardOutput = true;
            process_Thumbnail.StartInfo.CreateNoWindow         = true;
            //Process.Start("cmd.exe");
            process_Thumbnail.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
            process_Thumbnail.Start();

            string[] route_str = PluginfoldPath.Split(':');
            string   disk_pos  = route_str[0].ToString() + ":";
            process_Thumbnail.StandardInput.WriteLine(disk_pos);
            process_Thumbnail.StandardInput.WriteLine("cd " + PluginfoldPath + @".\\bin_thumbnail\\");
            process_Thumbnail.StandardInput.WriteLine(".\\GetThumbImageFromPyramid.exe");
            //process.StandardInput.WriteLine("exit");

            process_Thumbnail.BeginOutputReadLine();
            process_Thumbnail.CloseMainWindow();
            process_Thumbnail.StandardInput.WriteLine(">Finish");
            process_Thumbnail.StandardInput.WriteLine("exit");
            // process.
            process_Thumbnail.WaitForExit();

            #endregion
            this.ImageMonitor.Image    = Image.FromFile(PluginfoldPath + @"\bin_thumbnail\img_thumbnail.tiff"); //动态加载缩略图片
            this.ImageMonitor.SizeMode = PictureBoxSizeMode.Zoom;                                               //设置图片显示方式
        }