Example #1
0
        /// <summary>
        /// SelectCamera: 카메라의 영상의 크기로 Byte array 크기를 할당하고,
        /// Mil 변수에 영상을 할당한다.
        /// </summary>
        /// <param name="pCamera"></param>
        /// <returns></returns>
        public int SelectCamera(MVisionCamera pCamera)
        {
            if (pCamera == null)
            {
                return(GenerateErrorCode(ERR_VISION_CAMERA_NON_USEFUL));
            }

            Size CameraPixelSize;

            // View의 Camera 주소에 객체를 대입한다.
            m_pCamera = pCamera;

            // Camera Pixel Size 대입
            CameraPixelSize = m_pCamera.GetCameraPixelSize();

            m_CameraWidth  = CameraPixelSize.Width;
            m_CameraHeight = CameraPixelSize.Height;

            if (m_CameraWidth == 0 || m_CameraHeight == 0)
            {
                return(GenerateErrorCode(ERR_VISION_CAMERA_IMAGE_SIZE_FAIL));
            }

            // image byte 변수
            m_ImgBits = new Byte[m_CameraWidth * m_CameraHeight];

            // set source image size Rect size
            m_recImage.X      = 0;
            m_recImage.Y      = 0;
            m_recImage.Width  = m_CameraWidth;
            m_recImage.Height = m_CameraHeight;

            // MIL Buffer 초기화
            if (m_MilImage != MIL.M_NULL)
            {
                MIL.MbufFree(m_MilImage);
            }
            MIL.MbufAlloc2d(m_pMilSystemID, m_recImage.Width, m_recImage.Height,
                            MIL.M_UNSIGNED + 8, MIL.M_IMAGE + MIL.M_PROC + MIL.M_DISP,
                            ref m_MilImage);

            MIL.MbufClear(m_MilImage, 0);

            return(SUCCESS);
        }
Example #2
0
        int CreateVisionCamera(CObjectInfo objInfo)
        {
#if SIMULATION_VISION
            return(SUCCESS);
#endif
            m_VisionCamera = new MVisionCamera[DEF_MAX_CAMERA_NO];

            // Camera & View 를 생성함.
            for (int iIndex = 0; iIndex < DEF_MAX_CAMERA_NO; iIndex++)
            {
                // Camera를 생성함.
                m_VisionCamera[iIndex] = new MVisionCamera(objInfo);
                // Vision Library MIL
                m_VisionCamera[iIndex].SetMil_ID(m_VisionSystem.GetMilSystem());
                // Camera 초기화
                m_VisionCamera[iIndex].Initialize(iIndex, m_VisionSystem.GetSystem());
            }

            return(SUCCESS);
        }
Example #3
0
        public int Initialize(int iViewNo, MVisionCamera pCamera)
        {
            // Num 설정
            m_iViewID = iViewNo;

            // Mil Displayt 할당
            MIL.MdispAlloc(m_pMilSystemID, MIL.M_DEFAULT, "M_DEFAULT", MIL.M_WINDOWED, ref m_MilDisplay);

            // Camera Select
            if (SelectCamera(pCamera) == SUCCESS)
            {
                // System Init 결과 저장
                m_iResult = SUCCESS;

                return(SUCCESS);
            }
            else
            {
                return(GenerateErrorCode(ERR_VISION_CAMERA_CREATE_FAIL));
            }
        }
Example #4
0
 public void SelectCamera(MVisionCamera m_Camera)
 {
     m_pCamera[m_Camera.GetCamID()] = m_Camera;
 }