示例#1
0
        public void DestroyMatroxCard()
        {
            if (mapDigitizerImp != null)
            {
                foreach (var s in mapDigitizerImp)
                {
                    s.Value.StopGrab();
                    s.Value.Destroy();
                }
            }


            if (mapMilSystem != null)
            {
                foreach (var vsystem in mapMilSystem)
                {
                    MIL_ID tem = vsystem.Value;
                    MIL.MsysFree(tem);
                    tem = MIL.M_NULL;
                }
            }

            if (MilApplication != MIL.M_NULL)
            {
                MIL.MappFree(MilApplication);
                MilApplication = MIL.M_NULL;
            }
        }
示例#2
0
        private void CameraClose()
        {
            try
            {
                if (!IsStop)
                {
                    this.CameraGrabStop();
                }
                if (MatroxCameraList != null)
                {
                    foreach (var cam in MatroxCameraList)
                    {
                        //cam free
                        MIL.MdigFree(cam.DigitizerID);
                        try
                        {
                            //board free
                            MIL.MsysFree(cam.SystemID);
                        }
                        catch
                        {
                            //보드에 연결된 카메라가 다 닫히지 않았다면 이리로 들어옴
                        }
                    }
                    MatroxCameraList.Clear();

                    //app free
                    MIL.MappFree(_MilApplication);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message + "\n" + err.StackTrace);
            }
        }
示例#3
0
        public void freeSystems()
        {
            // GigE Cam System 해제
            m_iResult = m_System.release();

            MIL.MsysFree(m_MilSystem);
            MIL.MappFree(m_MilApp);
        }
示例#4
0
        ///////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Frees the MIL Application and its associated resources.
        /// </summary>
        public void Free()
        {
            // Stop the grab if necessary.
            if (CanStopGrab)
            {
                StopGrab();
            }

            // Free the display.
            if (_dispId != MIL.M_NULL)
            {
                // If an image buffer is selected on the display, deselect it before freeing the display.
                MIL_ID selectedBufferId = (MIL_ID)MIL.MdispInquire(_dispId, MIL.M_SELECTED, MIL.M_NULL);
                if (selectedBufferId != MIL.M_NULL)
                {
                    MIL.MdispSelectWPF(_dispId, MIL.M_NULL, null);
                }

                MIL.MdispFree(_dispId);
                _dispId = MIL.M_NULL;
            }

            // Free the image buffer.
            if (_bufId != MIL.M_NULL)
            {
                MIL.MbufFree(_bufId);
                _bufId = MIL.M_NULL;
            }

            // Free the digitizer.
            if (_digId != MIL.M_NULL)
            {
                MIL.MdigFree(_digId);
                _digId = MIL.M_NULL;
            }

            // Free the system.
            if (_sysId != MIL.M_NULL)
            {
                MIL.MsysFree(_sysId);
                _sysId = MIL.M_NULL;
            }

            // Free the application.
            if (_appId != MIL.M_NULL)
            {
                MIL.MappFree(_appId);
                _appId = MIL.M_NULL;
            }

            // The object has been cleaned up.
            // This call removes the object from the finalization queue and
            // prevent finalization code object from executing a second time.
            GC.SuppressFinalize(this);
        }
示例#5
0
        private void CloseApp(object obj)
        {
            if (IsGrabbing)
            {
                MIL.MdigHalt(_digitizer);
                IsGrabbing = false;
            }

            // Free MIL objects
            MIL.MdispFree(_display);

            MIL.MgraFree(_calibrationGraphicsContext);
            MIL.MgraFree(_calibrationGraphics);

            MIL.MbufFree(_buffer);

            // MIL.MdigFree(_digitizer);

            MIL.MsysFree(_system);

            MIL.MappFree(_app);
        }
示例#6
0
        //**************************************************************************
        //
        // Name:         MilApplication()
        //
        // Synopsis:     This function is the core of the MIL application that
        //               is executed when the "Start" menu item of this
        //               Windows forms program is selected. See main() in the
        //               program.cs file for the program's entry point.
        //
        //               It uses MIL to display a welcoming message in the
        //               specified user window and to grab in it (if it is supported)
        //               using the target system.
        //
        //**************************************************************************
        private void MilApplication(IntPtr UserWindowHandle)
        {
            // MIL variables
            MIL_ID  MilApplication = MIL.M_NULL; // MIL Application identifier.
            MIL_ID  MilSystem      = MIL.M_NULL; // MIL System identifier.
            MIL_ID  MilDisplay     = MIL.M_NULL; // MIL Display identifier.
            MIL_ID  MilDigitizer   = MIL.M_NULL; // MIL Digitizer identifier.
            MIL_ID  MilImage       = MIL.M_NULL; // MIL Image buffer identifier.
            MIL_INT BufSizeX       = DEFAULT_IMAGE_SIZE_X;
            MIL_INT BufSizeY       = DEFAULT_IMAGE_SIZE_Y;
            MIL_INT BufSizeBand    = DEFAULT_IMAGE_SIZE_BAND;

            // Allocate a MIL application.
            MIL.MappAlloc(MIL.M_NULL, MIL.M_DEFAULT, ref MilApplication);

            // Allocate a MIL system.
            MIL.MsysAlloc(MIL.M_DEFAULT, "M_DEFAULT", MIL.M_DEFAULT, MIL.M_DEFAULT, ref MilSystem);

            // Allocate a MIL display.
            MIL.MdispAlloc(MilSystem, MIL.M_DEFAULT, "M_DEFAULT", MIL.M_WINDOWED, ref MilDisplay);

            // Allocate a MIL digitizer, if supported, and set the target image size.
            if (MIL.MsysInquire(MilSystem, MIL.M_DIGITIZER_NUM, MIL.M_NULL) > 0)
            {
                MIL.MdigAlloc(MilSystem, MIL.M_DEFAULT, "M_DEFAULT", MIL.M_DEFAULT, ref MilDigitizer);
                MIL.MdigInquire(MilDigitizer, MIL.M_SIZE_X, ref BufSizeX);
                MIL.MdigInquire(MilDigitizer, MIL.M_SIZE_Y, ref BufSizeY);
                MIL.MdigInquire(MilDigitizer, MIL.M_SIZE_BAND, ref BufSizeBand);

                // Resize the display window
                if ((BufSizeX > DEFAULT_IMAGE_SIZE_X) || (BufSizeY > DEFAULT_IMAGE_SIZE_Y))
                {
                    FromHandle(UserWindowHandle).Size = new Size((int)BufSizeX, (int)BufSizeY);
                }
            }

            // Allocate a MIL buffer.
            long Attributes = MIL.M_IMAGE + MIL.M_DISP;

            if (MilDigitizer != MIL.M_NULL)
            {
                // Add M_GRAB attribute if a digitizer is allocated.
                Attributes |= MIL.M_GRAB;
            }
            MIL.MbufAllocColor(MilSystem, BufSizeBand, BufSizeX, BufSizeY, 8 + MIL.M_UNSIGNED, Attributes, ref MilImage);

            // Clear the buffer.
            MIL.MbufClear(MilImage, 0);

            // Select the MIL buffer to be displayed in the user-specified window.
            MIL.MdispSelectWindow(MilDisplay, MilImage, UserWindowHandle);

            // Print a string in the image buffer using MIL.
            // Note: When a MIL buffer is modified using a MIL command, the display
            // automatically updates the window passed to MIL.MdispSelectWindow().

            MIL.MgraFont(MIL.M_DEFAULT, MIL.M_FONT_DEFAULT_LARGE);
            MIL.MgraText(MIL.M_DEFAULT, MilImage, (BufSizeX / 8) * 2, BufSizeY / 2, " Welcome to MIL !!! ");
            MIL.MgraRect(MIL.M_DEFAULT, MilImage, ((BufSizeX / 8) * 2) - 60, (BufSizeY / 2) - 80, ((BufSizeX / 8) * 2) + 370, (BufSizeY / 2) + 100);
            MIL.MgraRect(MIL.M_DEFAULT, MilImage, ((BufSizeX / 8) * 2) - 40, (BufSizeY / 2) - 60, ((BufSizeX / 8) * 2) + 350, (BufSizeY / 2) + 80);
            MIL.MgraRect(MIL.M_DEFAULT, MilImage, ((BufSizeX / 8) * 2) - 20, (BufSizeY / 2) - 40, ((BufSizeX / 8) * 2) + 330, (BufSizeY / 2) + 60);

            // Open a message box to wait for a key press.
            MessageBox.Show("\"Welcome to MIL !!!\" was printed", "MIL application example", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            // Grab in the user window if supported.
            if (MilDigitizer != MIL.M_NULL)
            {
                // Grab continuously.
                MIL.MdigGrabContinuous(MilDigitizer, MilImage);

                // Open a message box to wait for a key press.
                MessageBox.Show("Continuous grab in progress", "MIL application example", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                // Stop continuous grab.
                MIL.MdigHalt(MilDigitizer);
            }

            // Remove the MIL buffer from the display.
            MIL.MdispSelect(MilDisplay, MIL.M_NULL);

            // Free allocated objects.
            MIL.MbufFree(MilImage);

            if (MilDigitizer != MIL.M_NULL)
            {
                MIL.MdigFree(MilDigitizer);
            }

            MIL.MdispFree(MilDisplay);
            MIL.MsysFree(MilSystem);
            MIL.MappFree(MilApplication);
        }