Exemplo n.º 1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public AccessCamera()
        {
            // カメラObj初期化


            _RightCameraObj = new CArtCam();
            _LeftCameraObj  = new CArtCam();
            _RightCameraObj.FreeLibrary();
            _LeftCameraObj.FreeLibrary();

            _SyncObj = new object();

            IsOpen = false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// OPEN
        /// </summary>
        /// <param name="handle"></param>
        /// <returns></returns>
        public ErrorCode Open(IntPtr handle, int gain_right, int gain_left)
        {
            ERROR     er   = ERROR.CAMERA_UNKNOWN;
            ErrorCode code = new ErrorCode();

            code.Clear();

            IsOpen = false;

            if (!_RightCameraObj.LoadLibrary("ArtCamSdk_036MI2_WOM.dll"))
            {
                _RightCameraObj.GetLastError();


                er            = ERROR.CAMERA_LOADLIBRARY;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (!_LeftCameraObj.LoadLibrary("ArtCamSdk_036MI2_WOM.dll"))
            {
                er            = ERROR.CAMERA_LOADLIBRARY;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }

            if (!_RightCameraObj.Initialize(handle))
            {
                er            = ERROR.CAMERA_INITIALIZE;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (!_LeftCameraObj.Initialize(handle))
            {
                er            = ERROR.CAMERA_INITIALIZE;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }

            if (_RightCameraObj.SetDeviceNumber(0) != 1)
            {
                er            = ERROR.CAMERA_SETDEVICENUMBER;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (_LeftCameraObj.SetDeviceNumber(1) != 1)
            {
                er            = ERROR.CAMERA_SETDEVICENUMBER;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }


            if (_RightCameraObj.SetHalfClock(1) != 1)
            {
                er            = ERROR.CAMERA_SETHALFCLOCK;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (_LeftCameraObj.SetHalfClock(1) != 1)
            {
                er            = ERROR.CAMERA_SETHALFCLOCK;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }

            // IDチェック
            int leftidNo  = 1;
            int rightidNo = 2;

            int left_id_now  = _LeftCameraObj.ReadSromID(0);
            int right_id_now = _LeftCameraObj.ReadSromID(0);

            if (left_id_now == leftidNo && right_id_now == rightidNo)
            {
                // スルー
            }

            else if (left_id_now == rightidNo && right_id_now == leftidNo)
            {
                CArtCam tempobj = _RightCameraObj;
                _RightCameraObj = _LeftCameraObj;
                _LeftCameraObj  = tempobj;
            }
            else
            {
                _RightCameraObj.WriteSromID(0, rightidNo);
                _LeftCameraObj.WriteSromID(0, rightidNo);
            }


            if (_RightCameraObj.SetGlobalGain(gain_right) != 1)
            {
                er            = ERROR.CAMERA_SETGAIN;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (_LeftCameraObj.SetGlobalGain(gain_left) != 1)
            {
                er            = ERROR.CAMERA_SETGAIN;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }

            if (_RightCameraObj.SetMirrorH(true) != 1)
            {
                er            = ERROR.CAMERA_SETMIRROR;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (_LeftCameraObj.SetMirrorH(true) != 1)
            {
                er            = ERROR.CAMERA_SETMIRROR;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }

            if (_RightCameraObj.Capture() != 1)
            {
                er            = ERROR.CAMERA_CAPTURE;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _RightCameraObj.GetLastError();
                return(code);
            }

            if (_LeftCameraObj.Capture() != 1)
            {
                er            = ERROR.CAMERA_CAPTURE;
                code.ErrorNo  = (int)er;
                code.ErrorStr = er.ToString();
                code.DetailNo = _LeftCameraObj.GetLastError();
                return(code);
            }



            IsOpen = true;


            er            = ERROR.CAMERA_NONE;
            code.ErrorNo  = (int)er;
            code.ErrorStr = er.ToString();
            return(code);
        }
 public CameraController()
 {
     m_CArtCam = new CArtCam();
 }