Пример #1
0
        public override void Start()
        {
            if (moduleInfo.Args().Length == 0 || moduleInfo.Args()[0].Equals(""))
            {
                ListAvailableCameras();
                return;
            }

            cameraStr = moduleInfo.Args()[0];

            _frameSource = FindConnectedCamera(cameraStr);

            if (_frameSource != null)
            {
                InitCamera(_frameSource);
            }
            else 
            {
                logger.Log("Camera matching {0} not found", cameraStr);
                ListAvailableCameras();
                logger.Log("Will keep looking");
            }

            cameraSearchTimer = new Timer(PeriodicCameraSearch, null, (int) SearchPeriod.TotalMilliseconds, (int) SearchPeriod.TotalMilliseconds);

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
Пример #2
0
        private void InitCamera(CameraFrameSource frameSource)
        {
            logger.Log("Init-ing camera {0}", _frameSource.Camera.ToString());

            //add the camera service port if we haven't done that already
            if (cameraPort == null)
            {
                VPortInfo pInfo = GetPortInfoFromPlatform("webcam - " + cameraStr);

                List<VRole> roles = new List<VRole>() { RoleCamera.Instance };

                cameraPort = InitPort(pInfo);
                BindRoles(cameraPort, roles, OnOperationInvoke);

                RegisterPortWithPlatform(cameraPort);
            }

            SafeThread worker = new SafeThread(delegate() { GetVideo(); }, "DriverWebCam-GetVideo", logger);
            worker.Start();
        }
Пример #3
0
        private void setFrameSource(CameraFrameSource cameraFrameSource)
        {
            if (_frameSource == cameraFrameSource)
                return;

            _frameSource = cameraFrameSource;
        }
Пример #4
0
        public override void Start()
        {
            if (moduleInfo.Args().Length == 0 || moduleInfo.Args()[0].Equals(""))
            {
                ListAvailableCameras();
                return;
            }

            string cameraStr = moduleInfo.Args()[0];

            foreach (Camera camera in CameraService.AvailableCameras)
            {
                //if (camera.ToString().ToLower().Contains(cameraStr))
                //{
                //    _frameSource = new CameraFrameSource(camera);
                //    break;
                //}

                if (cameraStr.ToLower().Contains(camera.ToString().ToLower()))
                {
                    _frameSource = new CameraFrameSource(camera);
                    break;
                }
            }

            if (_frameSource == null)
            {
                logger.Log("Camera matching {0} not found", cameraStr);
                ListAvailableCameras();
                return;
            }

            logger.Log("Will use camera {0}", _frameSource.Camera.ToString());

            //add the camera service port
            VPortInfo pInfo = GetPortInfoFromPlatform("webcam - " + cameraStr);

            List<VRole> roles = new List<VRole>() {RoleCamera.Instance};

            cameraPort = InitPort(pInfo);
            BindRoles(cameraPort, roles, OnOperationInvoke);

            RegisterPortWithPlatform(cameraPort);
            worker = new SafeThread(delegate()
            {
                GetVideo();
            }, "DriverWebCam-GetVideo", logger);
            worker.Start();

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
Пример #5
0
        private void PeriodicCameraSearch(object state)
        {
            try
            {
                //search only if we haven't received a frame in a while
                if (DateTime.Now - _latestFrameTime > SearchPeriod)
                {
                    if (cameraPort != null)
                    {
                        ForgetCamera();
                    }
                        
                    _frameSource = FindConnectedCamera(cameraStr);

                    if (_frameSource != null)
                    {
                        InitCamera(_frameSource);
                    }
                }
            }
            catch (Exception e)
            {
                logger.Log("Exception during camera search: " + e.ToString());
            }
        }
Пример #6
0
        private void ForgetCamera()
        {
            DeregisterPortWithPlatform(cameraPort);
            cameraPort = null;

            if (_frameSource != null && _frameSource.Camera != null)
                _frameSource.Camera.Dispose();

            _frameSource = null;
        }