Exemplo n.º 1
0
 /// <summary>
 /// Save CameraJob to Url
 /// </summary>
 /// <param name="url"></param>
 public void SaveJob(string url)
 {
     CogSerializer.SaveObjectToFile(AcqFifoTool.Subject as CogAcqFifoTool, url + "\\AqcTool.vpp");
     CogSerializer.SaveObjectToFile(CalibGridCBTool.Subject as CogCalibCheckerboardTool, url + "\\CalibTool.vpp");
     CogSerializer.SaveObjectToFile(PMAlignTool.Subject as CogPMAlignTool, url + "\\PMAlignTool.vpp");
     MessageBox.Show("Save Job Done! :)");
 }
Exemplo n.º 2
0
        public bool SaveVpp(string strVppName)
        {
            try
            {
                // 2011.04.13
                //CogSerializer.SaveObjectToFile(m_cogtgType, strVppName, typeof(System.Runtime.Serialization.Formatters.Soap.SoapFormatter), CogSerializationOptionsConstants.Minimum);
                CogSerializer.SaveObjectToFile(m_cogtgType, strVppName, typeof(System.Runtime.Serialization.Formatters.Binary.BinaryFormatter), CogSerializationOptionsConstants.Minimum);
// 2016.06.20
//#if !_USE_1Camera
#if (!_USE_BASLER_PYLON && !_USE_IMAGING_CONTROL && !_USE_FLIR && !_USE_1Camera)
                //** 2015.10.02 by kdi
                string strFolderName   = Path.GetDirectoryName(strVppName);
                string strOnlyFileName = Path.GetFileNameWithoutExtension(strVppName);
                string strExtName      = Path.GetExtension(strVppName);
                string strAcqVppName   = strFolderName + "\\" + strOnlyFileName + "_CAM" + strExtName;
                CogSerializer.SaveObjectToFile(m_cogtgType_Acq, strAcqVppName, typeof(System.Runtime.Serialization.Formatters.Binary.BinaryFormatter), CogSerializationOptionsConstants.Minimum);
                //*/
#endif
                ReLoad();

                return(true);
            }
            catch
            {
                MessageBox.Show(strVppName + " File Save Error!");
                return(false);
            }
        }
Exemplo n.º 3
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //수정 :
        //목적 : Save
        //설명 :
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public override bool HLSaveRecipe(string strRecipePath, string strRecipeName)
        {
            bool bReturn = false;

            do
            {
                string[] strFileName = new string[( int )CResultData.enumLine.LINE_FINAL];
                strFileName[( int )CResultData.enumLine.LINE_VERTICAL] = strRecipePath + "\\" + strRecipeName + "\\" + string.Format("FindLineVertical{0}.VPP", m_iIndex);
                strFileName[( int )CResultData.enumLine.LINE_HORIZON]  = strRecipePath + "\\" + strRecipeName + "\\" + string.Format("FindLineHorizon{0}.VPP", m_iIndex);

                try {
                    for (int iLoopCount = 0; iLoopCount < ( int )CResultData.enumLine.LINE_FINAL; iLoopCount++)
                    {
                        CogSerializer.SaveObjectToFile(m_objFindLineTool[iLoopCount], strFileName[iLoopCount], typeof(System.Runtime.Serialization.Formatters.Binary.BinaryFormatter), CogSerializationOptionsConstants.All);
                    }
                } catch (System.Exception ex) {
                    Trace.WriteLine(ex.Message + " -> " + ex.StackTrace);
                    MakeErrorMessage("HLLoadRecipe", 5404, ex.Message);
                    break;
                }

                bReturn = true;
            } while(false);

            return(bReturn);
        }
Exemplo n.º 4
0
 private void FrmToolBlock_ToolBlockSave(int toolBlockId, CogToolBlock editTool, CogToolBlock backupTool, bool save)
 {
     if (save)
     {
         processToolBlock = editTool;
         CogSerializer.SaveObjectToFile(processToolBlock, GetValue("ProcessVppPath"));
     }
 }
Exemplo n.º 5
0
 private void button2_Click(object sender, EventArgs e)
 {
     // CogSerializer.SaveObjectToFile(toolBlock,@"C:\PROJECTS\Stahli.Net\Bin\Debug\CognexStahli\Camera1.vpp");
     CogSerializer.SaveObjectToFile(toolBlock, System.IO.Directory.GetCurrentDirectory() + "\\CognexStahli\\Camera1.vpp");
     cogAcqTool                = cogToolBlockEditV21.Subject.Tools["CogAcqFifoTool1"] as CogAcqFifoTool;
     calbCheckerBoard          = cogToolBlockEditV21.Subject.Tools["CogCalibCheckerboardTool1"] as CogCalibCheckerboardTool;
     CalibNPointTool           = cogToolBlockEditV21.Subject.Tools["CogCalibNPointToNPointTool1"] as CogCalibNPointToNPointTool;
     cogPMAlignTool            = cogToolBlockEditV21.Subject.Tools["CogPMAlignTool1"] as CogPMAlignTool;
     cogPMAlignTool.InputImage = CalibNPointTool.OutputImage as CogImage8Grey;
 }
Exemplo n.º 6
0
        /*
         * public void Save_Json(string jCategory, string jVarName, object jObj)
         * {
         *  System.Type type = jObj.GetType();
         *  string TypeName = type.FullName;
         *
         *
         *  // Main Recipe File
         *  var jsonFile = new JObject();
         *
         *  // Recipe File 내에서 구분
         *  var jPart = new JObject();
         *
         *  if (TypeName.Contains("Int16"))
         *      jPart.Add(jVarName, (Int16) jObj);
         *  else if (TypeName.Contains("Int32"))
         *      jPart.Add(jVarName, (Int32)jObj);
         *  else if (TypeName.Contains("Int64"))
         *      jPart.Add(jVarName, (Int64)jObj);
         *  else if (TypeName.Contains("Double"))
         *      jPart.Add(jVarName, (Double)jObj);
         *  else if (TypeName.Contains("String"))
         *      jPart.Add(jVarName, (string)jObj);
         *
         *  // 구분된 Recipe 저장 내용들을 Main Recipe File 에 저장
         *  jsonFile.Add(jCategory, jPart);
         *
         *  string sjsonFile = jsonFile.ToString();
         *
         *  string FilePath = "D:\\test.json";
         *
         *  System.IO.File.WriteAllText(FilePath, sjsonFile);
         * }
         */

        /*
         * public void Load_Json(string jCategory, string jVarName, out object jObj)
         * {
         *  jObj = null; // 초기화
         *
         *  System.Type type = jObj.GetType();
         *  string TypeName = type.FullName;
         *
         *
         *  string FilePath = "D:\\test.json";
         *  if (!System.IO.File.Exists(FilePath))
         *      return;
         *
         *  // Main Recipe File
         *  JObject jsonFile = JObject.Parse(File.ReadAllText(FilePath));
         *
         *  // Recipe File 내에서 구분
         *  // 1. Recipe
         *  JObject jPart = (JObject)jsonFile["jCategory"];
         *
         *  if (TypeName.Contains("Int16") || TypeName.Contains("Int32") || TypeName.Contains("Int64"))
         *      jObj = jPart[jVarName].ToString() == "" ? 0 : int.Parse(jPart[jVarName].ToString());
         *
         *  else if (TypeName.Contains("Double"))
         *      jObj = jPart[jVarName].ToString() == "" ? 0 : Double.Parse(jPart[jVarName].ToString());
         *
         *  else if (TypeName.Contains("String"))
         *      jObj = jPart[jVarName].ToString();
         * }
         */



        public void Save_Vpp(Object CogObj, string FilePath)
        {
            try
            {
                CogSerializer.SaveObjectToFile(CogObj, FilePath);
            }
            catch (Exception e)
            {
            }
        }
Exemplo n.º 7
0
 public void SaveCameraJobToUrl()
 {
     CogSerializer.SaveObjectToFile(cogAcqFifoEdit.Subject, urlCameraJob + "\\AcqTool.vpp");
     CogSerializer.SaveObjectToFile(cogImageFileTool.Subject, urlCameraJob + "\\ImageFileTool.vpp");
     CogSerializer.SaveObjectToFile(pmAlignToolEdit.Subject, urlCameraJob + "\\AlignTool.vpp");
     CogSerializer.SaveObjectToFile(cogFixtureTool.Subject, urlCameraJob + "\\FixtureTool.vpp");
     CogSerializer.SaveObjectToFile(sharpnessToolEdit1.Subject, urlCameraJob + "\\SharpnessTool1.vpp");
     CogSerializer.SaveObjectToFile(sharpnessToolEdit2.Subject, urlCameraJob + "\\SharpnessTool2.vpp");
     SaveSharpnessSettings();
 }
Exemplo n.º 8
0
        private void btnSaveVPP_Click(object sender, EventArgs e)
        {
            string strFName;

            strFName = ASDef._INI_PATH + "\\Img\\" + AVisionProBuild.ToolName(m_nType, m_nPoint, m_aCalibCheckerboard.Name) + ".bmp";
            FileInfo fileDel = new FileInfo(strFName);

            if (fileDel.Exists)
            {
                fileDel.Delete();
            }

            // 2017.06.08
            //m_aCalibCheckerboard.Name = AVisionProBuild.MakeName("CalibCheckerboard", DateTime.Now);

            AVisionProBuild.SaveVpp(m_nType);

            strFName = ASDef._INI_PATH + "\\Img\\" + AVisionProBuild.ToolName(m_nType, m_nPoint, m_aCalibCheckerboard.Name) + ".bmp";
            // 2012.01.17
            //AVisionProBuild.SaveImg(strFName, cogDisplay);
            AVisionProBuild.SaveImg(strFName, m_cogImage);

            // 2012.04.24
#if (!_USE_BASLER_PYLON && !_USE_IMAGING_CONTROL)
            /* 2015.10.18
             * if (m_aAcqFifo.AcqFifoTool.Operator != null)
             * {
             *  // 2013.05.15
             *  if (m_aAcqFifo.GetFrameGrabberName().Contains("acA2500"))
             *  {
             *      AIniExposure aIniExposure = new AIniExposure(m_nType, m_nPoint);
             *      aIniExposure.m_nExposure = Convert.ToInt64(txtExposure.Text);
             *      aIniExposure.Write();
             *  }
             * }
             */
#elif _USE_BASLER_PYLON
            AIniExposure aIniExposure = new AIniExposure(m_nType, m_nPoint);
            // 2015.12.09
            aIniExposure.m_dExposure = Convert.ToDouble(txtExposure.Text);
            if (aIniExposure.m_dExposure > 0)
            {
                aIniExposure.Write();
            }
#endif
            // 2014.10.30
#if _USE_1Camera
            CogSerializer.SaveObjectToFile(m_aAcqFifo.GetTool(), ASDef._INI_PATH + "\\1Camera.vpp", typeof(System.Runtime.Serialization.Formatters.Binary.BinaryFormatter), CogSerializationOptionsConstants.Minimum);
#endif

            //MessageBox.Show("Tool is Saved!");
            // 2013.12.02
            MessageBox.Show(AUtil.GetXmlLanguage("Tool_is_Saved"));
            btnSaveVPP.Enabled = false;
        }
Exemplo n.º 9
0
 private void TrySaveVpp()
 {
     try
     {
         CogSerializer.SaveObjectToFile(_toolBlock, _vppPath, typeof(BinaryFormatter), CogSerializationOptionsConstants.Minimum);
         MessageBox.Show("保存成功");
     }
     catch (Exception e)
     {
         MessageBox.Show("保存失败:\n" + e.Message);
     }
 }
Exemplo n.º 10
0
 public static bool SaveVpp(object tool, string path)
 {
     try
     {
         CogSerializer.SaveObjectToFile(tool, path, typeof(BinaryFormatter), CogSerializationOptionsConstants.Minimum);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 11
0
 static void saveToFile(string vppPath)
 {
     try
     {
         CogSerializer.SaveObjectToFile(manager, vppPath);
         Console.WriteLine("saved");
     }
     catch (Exception e)
     {
         Console.WriteLine("sorry, can not save: " + e.Message);
     }
 }
Exemplo n.º 12
0
 public static void SaveVpp()
 {
     try
     {
         CogSerializer.SaveObjectToFile(block, vppFilePath);
         LoadVpp();
         MessageBox.Show("保存成功");
     }
     catch
     {
         MessageBox.Show("保存失败");
     }
 }
Exemplo n.º 13
0
        private void tsbEditCamera_Click(object sender, EventArgs e)
        {
            Vision.FrmCameraEdit frmCameraEdit = new Vision.FrmCameraEdit();
            bool           save;
            CogAcqFifoTool backTool = (CogAcqFifoTool)VisionProTool.CopyTool(acqFifoTool);
            CogAcqFifoTool tool     = frmCameraEdit.ShowEdit(backTool, "相机编辑", out save);

            if (save)
            {
                acqFifoTool = tool;
            }
            CogSerializer.SaveObjectToFile(acqFifoTool, GetValue("CameraVppPath"));
        }
Exemplo n.º 14
0
        void SavePatternToFile()
        {
            try
            {
                string path = System.IO.Directory.GetCurrentDirectory() + "\\CognexStahli\\PATTERN1.vpp";
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                //path += "PMAlign.vpp";
                CogSerializer.SaveObjectToFile(cogPMAlignTool.Pattern, path);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 15
0
 private void saveCognexFile()
 {
     try
     {
         if (Convert.ToBoolean(settings.CreateOrGetValue("FileDialog", "CreateBackup", "True")))
         {
             String BackupFileName = visionProFilePath + DateTime.Now.ToString("_yyyyMMdd_HHmmss");
             Trace.WriteLine("Creating backup: " + BackupFileName);
             System.IO.File.Move(visionProFilePath, BackupFileName);
         }
         CogSerializer.SaveObjectToFile(myJobManager, visionProFilePath);
         Trace.WriteLine("File saved: " + visionProFilePath);
     }
     catch (Exception ex)
     {
         Trace.WriteLine("Error saving file. Exception: " + ex.Message);
     }
 }
Exemplo n.º 16
0
        public static string SaveVision()
        {
            string f = GetJobFilePath(CurProduct.Name);

            try
            {
                CogSerializer.SaveObjectToFile(Vision.Tb, f);
            }
            catch (Exception ex)
            {
                string str = "保存产品视觉程序出错:" + ex.Message;
                Globals.MLog.Error(str);
                return(str);
            }
            RefreshConfigItems(CurProduct);
            Products.RemoveAll(p => p.Id == CurProduct.Id);
            Products.Add(CurProduct);
            Globals.SaveObjectToXml(Products, DataFile);
            return("OK");
        }
Exemplo n.º 17
0
        private bool Inspection(CogImage8Grey _SrcImage, CogRectangle _Region)
        {
            bool _Result = true;

            try
            {
                CogSerializer.SaveObjectToFile(PatternProc, @"D:\Pattern.vpp");
                PatternProc.InputImage   = _SrcImage;
                PatternProc.SearchRegion = _Region;
                PatternProc.Run();
                //GetResults();
            }

            catch (System.Exception ex)
            {
                //CLogManager.AddSystemLog(CLogManager.LOG_TYPE.ERR, "InspectionPattern - Inspection Exception : " + ex.ToString(), CLogManager.LOG_LEVEL.LOW);
                _Result = false;
            }

            return(_Result);
        }
Exemplo n.º 18
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //수정 :
        //목적 : Save
        //설명 :
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public override bool HLSaveRecipe(string strRecipePath, string strRecipeName)
        {
            bool bReturn = false;

            do
            {
                string strFileName = strRecipePath + "\\" + strRecipeName + "\\" + string.Format("PMAlign{0}.VPP", m_iIndex);

                try {
                    CogSerializer.SaveObjectToFile(m_objPMAlignTool, strFileName, typeof(System.Runtime.Serialization.Formatters.Binary.BinaryFormatter), CogSerializationOptionsConstants.All);
                } catch (System.Exception ex) {
                    Trace.WriteLine(ex.Message + " -> " + ex.StackTrace);
                    MakeErrorMessage("HLSaveRecipe", 5204, ex.Message);
                    break;
                }

                bReturn = true;
            } while(false);

            return(bReturn);
        }
Exemplo n.º 19
0
        public Boolean SaveToVPPFile(string FileName)//檔案參數儲存
        {
            string ProcID = System.Reflection.MethodInfo.GetCurrentMethod().Name.ToString();

            try
            {
                //建立目錄資料夾
                string        strFolderPath = @"D:\VPS_File\Product\FindCircleTool\" + @FileName + @"\";
                DirectoryInfo DIFO          = new DirectoryInfo(strFolderPath);
                if (DIFO.Exists != true)
                {
                    DIFO.Create();
                }

                //塞到CogTool裡面
                CogToolBlock ToolBlock1 = new CogToolBlock();

                mFindCircleTool.Name = FileName + "_FindCircleTool_";

                ToolBlock1.Tools.Add(mFindCircleTool);

                FileName = strFolderPath + FileName + "_FCT.vpp";

                //有使用到定位跟隨的時候不能存成最壓縮的檔案
                //CogSerializer.SaveObjectToFile(ToolBlock1, @FileName, typeof(BinaryFormatter), CogSerializationOptionsConstants.Minimum);
                CogSerializer.SaveObjectToFile(ToolBlock1, @FileName);

                SaveLog.Msg_("Data of FindCircleTool Saved : " + FileName);
                ToolBlock1            = null;
                FindCircleTool_Status = true;
                return(true);
            }
            catch (Exception ex)
            {
                SaveLog.Msg_("Save FindCircleTool Data Failed : " + ModularID + ":\r\n" + ProcID + ":\r\n" + ex.ToString());
                FindCircleTool_Status = false;
                return(false);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Save the vision tool
        /// </summary>
        public override void SaveVisionFile()
        {
            if (CogToolGroup != null)
            {
                try
                {
                    string visonPath = VisionFile.Substring(0, VisionFile.LastIndexOf('\\'));

                    if (!Directory.Exists(visonPath))
                    {
                        Directory.CreateDirectory(visonPath);
                    }
                    CogSerializer.SaveObjectToFile(CogToolGroup, VisionFile);
                }
                catch (Exception ex)
                {
                    U.LogPopup(ex, "Error saving the Cog vpp file");
                }
                finally
                {
                }
            }
        }
Exemplo n.º 21
0
        //Ziv 13.7.15
        public void savePattern(string cameraName, string orderName, CogPMAlignPattern pattern)
        {
            string path;// = Application.StartupPath;

            path = Directory.GetCurrentDirectory();

            if (path.ToLower().EndsWith(@"\bin\release"))
            {
                path = path.ToLower().Replace(@"\bin\release", @"\bin\debug");
            }

            if (!(path.ToLower().EndsWith(@"\bin\debug")))
            {
                return;
            }

            path += ("\\CognexStahli\\" + cameraName);

            try
            {
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                path += ("\\" + orderName + ".vpp");

                CogSerializer.SaveObjectToFile(pattern, path);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 22
0
 private void Window_Closed(object sender, EventArgs e)
 {
     CogSerializer.SaveObjectToFile(blob, Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\tool.vpp");
     camControl.CloseDeviceAcquisitionStop();
     camControl.CamFree();
 }
Exemplo n.º 23
0
 public void Save()
 {
     CogSerializer.SaveObjectToFile(MyCogToolBlock, VppFileName);
     LogMessage(string.Format("CCD{0}检查程序已保存", CcdId + 1));
 }
Exemplo n.º 24
0
 public void saveVSTool()
 {
     CogSerializer.SaveObjectToFile(m_JobManager, m_strVppFileName);
 }
Exemplo n.º 25
0
        static int Main(string[] args)
        {
            //     1          2             3          4
            // bix source.vpp [--bin|--xml] target.vpp [option]
            string help = "usage: bix source.vpp [--bin|--xml] target.vpp [option]\n\t option: min, results, all";

            if (args.Length < 3 || args.Length > 4)
            {
                //foreach (var s in args)
                //{
                //Console.WriteLine(s);
                //}
                Console.WriteLine(help);
                return(-1);
            }
            var           source = args[0];
            var           type   = args[1].Replace("-", "").ToLower();
            var           target = args[2];
            var           option = args.Length == 4 ? args[3].ToLower() : "";
            CogJobManager vpro   = null;

            try
            {
                if (!System.IO.File.Exists(source))
                {
                    Console.WriteLine("source does not exits.");
                    return(-1);
                }
                vpro = (CogJobManager)CogSerializer.LoadObjectFromFile(source);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(-1);
            }
            if (string.IsNullOrEmpty(option))
            {
                try
                {
                    CogSerializer.SaveObjectToFile(vpro, target, type == "xml" ? typeof(SoapFormatter) : typeof(BinaryFormatter));
                }
                catch (System.Runtime.Serialization.SerializationException ex)
                {
                    Console.WriteLine(ex.Message);
                    return(-1);
                }
                Console.WriteLine("converted");
            }
            else
            {
                Dictionary <string, CogSerializationOptionsConstants> options = new Dictionary <string, CogSerializationOptionsConstants>
                {
                    { "min", CogSerializationOptionsConstants.Minimum },
                    { "results", CogSerializationOptionsConstants.Results },
                    { "all", CogSerializationOptionsConstants.All }
                };
                try
                {
                    CogSerializer.SaveObjectToFile(vpro, target,
                                                   type == "xml" ? typeof(SoapFormatter) : typeof(BinaryFormatter),
                                                   options[option]
                                                   );
                }
                catch (System.Runtime.Serialization.SerializationException ex)
                {
                    Console.WriteLine(ex.Message);
                    return(-1);
                }
                Console.WriteLine("converted (" + option + ")");
            }
            vpro.Shutdown();
            return(0);
            //Console.ReadKey();
        }
Exemplo n.º 26
0
 private void button2_Click(object sender, EventArgs e)  //Base function - SaveCogTool
 {
     //CogSerializer.SaveObjectToFile(toolBlock,@"C:\PROJECTS\Stahli.Net\Bin\Debug\CognexStahli\Camera3.vpp"); //need to save with insernt name as given by asaf);
     CogSerializer.SaveObjectToFile(toolBlock, System.IO.Directory.GetCurrentDirectory() + "\\CognexStahli\\Camera3.vpp"); //need to save with insernt name as given by asaf);
 }
Exemplo n.º 27
0
 public static void SaveVPP()
 {
     CogSerializer.SaveObjectToFile(_block, vppFilePath, typeof(BinaryFormatter), CogSerializationOptionsConstants.Minimum);
 }
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            // load image
            var bmp = new System.Drawing.Bitmap(@"D:\test.bmp");

            #region Using Vision Pro
            //vision pro tool initializing
            CogCaliperTool calipertool = new CogCaliperTool();
            //or load .vpp file (specific tool vpp)
            calipertool = CogSerializer.LoadObjectFromFile(@"D:\CaliperTool.vpp") as CogCaliperTool;

            //input processing image
            calipertool.InputImage = new CogImage8Grey(bmp);

            //process
            calipertool.Run();

            //create result record
            var caliper_record = calipertool.CreateLastRunRecord().SubRecords[0];

            //use result
            Console.Write("Edge Position is : X = {0}, Y = {1}", calipertool.Results[0].PositionX, calipertool.Results[0].PositionY);

            //save current tool (it saved specific tool vpp)
            CogSerializer.SaveObjectToFile(calipertool, @"D:\CaliperTool_Saved.vpp");
            #endregion


            #region Using ViDi in Runtime

            //open ViDi control (it has to open only one in the application.)
            ViDi2.Runtime.Local.Control runtime_control = new ViDi2.Runtime.Local.Control();
            //add runtime workspace (and open)
            ViDi2.Runtime.IWorkspace runtime_workspace = runtime_control.Workspaces.Add("TestWorkspace", @"D:\DeeplearningWorkspace.vrws");
            //select stream in workspace
            ViDi2.Runtime.IStream runtime_stream = runtime_workspace.Streams.Single(s => s.Name.Equals("Stream"));


            //pack image for use ViDi
            ViDi2.IImage runtime_ViDiImg = new ViDi2.FormsImage(bmp);
            //process
            ViDi2.ISample runtime_sample = runtime_stream.Process(runtime_ViDiImg);

            //using red result
            ViDi2.IRedMarking redMarking = runtime_sample.Markings["Analyze"] as ViDi2.IRedMarking;

            //marking has a value for each view result
            var r_score  = redMarking.Views[0].Score;
            var r_region = redMarking.Views[0].Regions;
            var r_pose   = redMarking.Views[0].Pose;

            //using blue result
            ViDi2.IBlueMarking blueMarking = runtime_sample.Markings["Locate"] as ViDi2.IBlueMarking;

            var b_features = blueMarking.Views[0].Features;
            var b_pose     = blueMarking.Views[0].Pose;

            //using green result
            ViDi2.IGreenMarking greenMarking = runtime_sample.Markings["Classify"] as ViDi2.IGreenMarking;

            var g_best_tag = greenMarking.Views[0].BestTag;
            var g_tags     = greenMarking.Views[0].Tags;

            //free vidi image
            runtime_ViDiImg.Dispose();

            //close workspace
            runtime_workspace.Close();

            //close vidi control
            runtime_control.Dispose();
            #endregion


            #region Using ViDi - Vision Pro Integration
            //open ViDi control (it has to open only one in the application.)
            ViDi2.Runtime.Local.Control integ_control = new ViDi2.Runtime.Local.Control();
            //add runtime workspace (and open)
            ViDi2.Runtime.IWorkspace integ_workspace = integ_control.Workspaces.Add("TestWorkspace", @"D:\DeeplearningWorkspace.vrws");
            //select stream in workspace
            ViDi2.Runtime.IStream integ_stream = integ_workspace.Streams.Single(s => s.Name.Equals("Stream"));

            //vision pro tool initializing
            CogAffineTransformTool transform_tool = new CogAffineTransformTool();
            //or load .vpp file (specific tool vpp)
            transform_tool = CogSerializer.LoadObjectFromFile(@"D:\TransformTool.vpp") as CogAffineTransformTool;

            //input processing image
            transform_tool.InputImage = new CogImage8Grey(bmp);
            //process Vision Pro
            transform_tool.Run();

            //pack vison pro output image for use ViDi
            ViDi2.IImage integ_ViDiImg = new ViDi2.VisionPro.Image(transform_tool.OutputImage);
            //process ViDi
            var integ_sample = integ_stream.Process(integ_ViDiImg);

            //create vision pro record
            var vp_record = transform_tool.CreateLastRunRecord().SubRecords[0];

            //create ViDi record
            var integ_redMarking = integ_sample.Markings["Analyze"] as ViDi2.IRedMarking;
            var vidi_red_record  = new ViDi2.VisionPro.RedViewRecord(integ_redMarking.Views[0] as ViDi2.IRedView, new ViDi2.VisionPro.Records.DefaultRedToolGraphicCreator());

            var integ_blueMarking = integ_sample.Markings["Locate"] as ViDi2.IBlueMarking;
            var vidi_blue_record  = new ViDi2.VisionPro.BlueViewRecord(integ_blueMarking.Views[0] as ViDi2.IBlueView, new ViDi2.VisionPro.Records.DefaultBlueToolGraphicCreator());

            var integ_greenMarking = integ_sample.Markings["Classify"] as ViDi2.IGreenMarking;
            var vidi_green_record  = new ViDi2.VisionPro.GreenViewRecord(integ_greenMarking.Views[0] as ViDi2.IGreenView, new ViDi2.VisionPro.Records.DefaultGreenToolGraphicCreator());

            //free vidi image
            integ_ViDiImg.Dispose();
            //close workspace
            integ_workspace.Close();
            //close vidi control
            integ_control.Dispose();
            #endregion


            //free image
            bmp.Dispose();
        }