Beispiel #1
0
        // Gig-E System을 초기화 한다.
        public int Initialize()
        {
            //====================================================================
            // Camera System 초기화
            m_System = new BGAPI.System();
            m_State  = new BGAPI.BGAPI_FeatureState();

            // check system.
            m_iResult = BGAPI.EntryPoint.countSystems(ref m_iSystemNo);
            if (m_iResult != BGAPI.Result.OK)
            {   // BGAPI.EntryPoint.CountSystems failed
                return(GenerateErrorCode(ERR_VISION_SYSTEM_CHECK_FAIL));
            }
            // create system.
            m_iResult = BGAPI.EntryPoint.createSystem(m_iSystemIndex, ref m_System);
            if (m_iResult != BGAPI.Result.OK)
            {   // BGAPI.EntryPoint.createSystems failed
                return(GenerateErrorCode(ERR_VISION_SYSTEM_CREATE_FAIL));
            }
            // open system
            m_iResult = m_System.open();
            if (m_iResult != BGAPI.Result.OK)
            {   // System open failed
                return(GenerateErrorCode(ERR_VISION_SYSTEM_OPEN_FAIL));
            }

            // get camera num
            m_iResult = m_System.countCameras(ref m_iCheckCamNo);
            if (m_iResult != BGAPI.Result.OK)
            {   // System count cameras failed!
                return(GenerateErrorCode(ERR_VISION_SYSTEM_CHECK_CAM_FAIL));
            }

            //====================================================================
            // Library System 초기화

            //MIL.MappAllocDefault(MIL.M_DEFAULT, ref m_MilApp, ref m_MilSystem, ref m_MilDisplay, MIL.M_NULL, MIL.M_NULL);

            MIL.MappAlloc(MIL.M_NULL, MIL.M_DEFAULT, ref m_MilApp);

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

            // System Init 결과 저장
            m_iResult = SUCCESS;

            return(SUCCESS);
        }
        private static int init_systems(ref int system_count, ref BGAPI.System[] externppSystem)
        {
            int res = BGAPI.Result.FAIL;
            int i   = 0;

            //this is the base call to find the bgapi_system modules which are necessary to perform any further action
            //every BGPAPI_Function returns a BGAPI_RESULT
            res = BGAPI.EntryPoint.countSystems(ref system_count);

            //You should always check the result to make sure everything works fine
            if (res != BGAPI.Result.OK)
            {
                //in case of error you will get a result different from BGAPI.Result.OK
                //all resultcodes are defined in bgapiresult.h and are returned for special reasons
                MessageBox.Show(string.Format("BGAPI.EntryPoint.countSystems Errorcode: {0} system_count {1}\n", res, system_count));
                return(res);
            }

            //this is an example how to store pointers for all available systems
            externppSystem = new BGAPI.System[system_count];

            for (i = 0; i < system_count; i++)
            {
                res = BGAPI.EntryPoint.createSystem(i, ref externppSystem[i]);
                if (res != BGAPI.Result.OK)
                {
                    MessageBox.Show(string.Format("BGAPI.EntryPoint.createSystem Errorcode: {0} Systemnumber {1}\n", res, i));
                    return(res);
                }
                res = externppSystem[i].open();
                if (res != BGAPI.Result.OK)
                {
                    MessageBox.Show(string.Format("open Systemnumber {0} Errorcode: {1}\n", i, res));
                    return(res);
                }
            }
            return(res);
        }
Beispiel #3
0
        /// <summary>
        /// Camera 초기화 진행함
        /// </summary>
        /// <param 카메라 번호="iCamNo"></param>
        /// <param 상위 GigE System="pSystem"></param>
        /// <returns></returns>
        public int Initialize(int iCamNo, BGAPI.System pSystem)
        {
            m_iCamID = iCamNo;
            // System 을 받아옴.
            m_CamSystem = pSystem;

            m_CamDeviceInfo = new BGAPI.BGAPIX_CameraInfo();
            m_CamImage      = new BGAPI.Image();

            // create camera
            m_iResult = m_CamSystem.createCamera(iCamNo, ref m_Camera);
            if (m_iResult != BGAPI.Result.OK)
            {
                //"System create camera failed!"
                return(GenerateErrorCode(ERR_VISION_CAMERA_CREATE_FAIL));
            }

            // get camera device information
            m_iResult = m_Camera.getDeviceInformation(ref m_CamState, ref m_CamDeviceInfo);
            m_cCameraData.m_CamDeviceInfo = m_CamDeviceInfo;
            if (m_iResult != BGAPI.Result.OK)
            {   // "Camera get Device Information failed!"
                return(GenerateErrorCode(ERR_VISION_CAMERA_GET_INFO_FAIL));
            }

            // get camera Image information
            m_iResult = m_Camera.getImageFormatDescription(1, ref m_CamImageInfo);

            if (m_iResult != BGAPI.Result.OK)
            {   // "Camera get Device Information failed!"
                return(GenerateErrorCode(ERR_VISION_CAMERA_GET_INFO_FAIL));
            }
            else
            {
                // Camera Pixel Size을 적용한다.
                m_CamPixelSize.Width  = (int)(m_CamImageInfo.iScaleRoiX * m_CamImageInfo.iSizeX);
                m_CamPixelSize.Height = (int)(m_CamImageInfo.iScaleRoiY * m_CamImageInfo.iSizeY);
            }

            // camera open
            m_iResult = m_Camera.open();
            if (m_iResult != BGAPI.Result.OK)
            {   //"Camera open failed!"
                return(GenerateErrorCode(ERR_VISION_CAMERA_CONNECT_FAIL));
            }

            // image create
            m_iResult = BGAPI.EntryPoint.createImage(ref m_CamImage);
            if (m_iResult != BGAPI.Result.OK)
            {   // Create Image failed
                return(GenerateErrorCode(ERR_VISION_CAMERA_CREATE_IMAGE_FAIL));
            }

            // camera & image connect
            m_iResult = m_Camera.setImage(ref m_CamImage);
            if (m_iResult != BGAPI.Result.OK)
            {   // Camera set Image failed!
                return(GenerateErrorCode(ERR_VISION_CAMERA_GET_IMAGE_FAIL));
            }

            // System Init 결과 저장
            m_iResult = SUCCESS;

            return(SUCCESS);
        }