Esempio n. 1
0
        public static void addCamera(rigItem p_cam)
        {
            rigItem r_item = new rigItem();

            r_item = p_cam;

            rig.Add(r_item);
        }
        //(VideoCaptureDevice source)
        // Open video source
        private void OpenVideoSource(VideoCaptureDevice source, AForge.Video.MJPEGStream ipStream, Boolean ip)
        {
            MotionDetector detector = new MotionDetector(new SimpleBackgroundModelingDetector());

            string camSource;

            // create camera
            Camera camera;

            if (!ip)
            {

                camSource = source.Source;
                camera = new Camera(source, detector, camSource);

            }
            else
            {

                camSource = ipStream.Source;
                camera = new Camera(ipStream, detector, camSource);

            }

            camera.motionLevelEvent -= new motionLevelEventHandler(bubble.motionEvent);
            camera.motionLevelEvent += new motionLevelEventHandler(bubble.motionEvent);

            // start camera
            camera.Start();

            rigItem rig_item = new rigItem();
            rig_item.cameraName = camSource;//source.Source;
            rig_item.cam = camera;
            rig_item.cam.cam = CameraRig.cameraCount();
            //CameraRig.addCamera(rig_item);
            CameraRig.rig.Add(rig_item);
            int curCam = CameraRig.cameraCount() - 1;
            CameraRig.activeCam = curCam;

            config.getProfile(bubble.profileInUse).webcam = camSource;

            //populate or update rig info
            CameraRig.rigInfoPopulate(config.getProfile(bubble.profileInUse).profileName, curCam);

            CameraRig.rig[curCam].cam.cam = curCam;

            //get desired button or first available button
            int desiredButton = CameraRig.rig[curCam].displayButton;
            //check if the desired button is free and return the next free button if one is available
            int camButton = camButtons.availForClick(desiredButton, true);
            bool freeCamsExist = camButton != 999;

            //if a free camera button exists assign the camera
            if (freeCamsExist)
            {
                CameraRig.rig[curCam].displayButton = camButton;
            }

            //update info for camera
            CameraRig.updateInfo(bubble.profileInUse, config.getProfile(bubble.profileInUse).webcam, CameraRig.infoEnum.displayButton, camButton);

            if (config.getProfile(bubble.profileInUse).selectedCam == "")
            {
                cameraSwitch(CameraRig.rig[curCam].displayButton, false, false);
            }
            else
            {
                if (config.getProfile(bubble.profileInUse).selectedCam == camSource)
                {
                    cameraSwitch(CameraRig.rig[curCam].displayButton, false, false);
                }
            }

            camButtonSetColours();

            if (CameraRig.rig[curCam].cam.alarmActive)
            {

                if (CameraRig.rig[curCam].displayButton == 1) selcam(this.bttncam1sel, 1);
                if (CameraRig.rig[curCam].displayButton == 2) selcam(this.bttncam2sel, 2);
                if (CameraRig.rig[curCam].displayButton == 3) selcam(this.bttncam3sel, 3);
                if (CameraRig.rig[curCam].displayButton == 4) selcam(this.bttncam4sel, 4);
                if (CameraRig.rig[curCam].displayButton == 5) selcam(this.bttncam5sel, 5);
                if (CameraRig.rig[curCam].displayButton == 6) selcam(this.bttncam6sel, 6);
                if (CameraRig.rig[curCam].displayButton == 7) selcam(this.bttncam7sel, 7);
                if (CameraRig.rig[curCam].displayButton == 8) selcam(this.bttncam8sel, 8);
                if (CameraRig.rig[curCam].displayButton == 9) selcam(this.bttncam9sel, 9);

            }

            if (CameraRig.rig[curCam].cam.publishActive)
            {
                if (CameraRig.rig[curCam].displayButton == 1) pubcam(this.bttncam1pub, 1);
                if (CameraRig.rig[curCam].displayButton == 2) pubcam(this.bttncam2pub, 2);
                if (CameraRig.rig[curCam].displayButton == 3) pubcam(this.bttncam3pub, 3);
                if (CameraRig.rig[curCam].displayButton == 4) pubcam(this.bttncam4pub, 4);
                if (CameraRig.rig[curCam].displayButton == 5) pubcam(this.bttncam5pub, 5);
                if (CameraRig.rig[curCam].displayButton == 6) pubcam(this.bttncam6pub, 6);
                if (CameraRig.rig[curCam].displayButton == 7) pubcam(this.bttncam7pub, 7);
                if (CameraRig.rig[curCam].displayButton == 8) pubcam(this.bttncam8pub, 8);
                if (CameraRig.rig[curCam].displayButton == 9) pubcam(this.bttncam9pub, 9);

            }

            CameraRig.alert(bubble.Alert.on);
            CameraRig.rig[curCam].cam.exposeArea = bubble.exposeArea;

            CameraRig.rig[curCam].cam.motionAlarm -= new alarmEventHandler(bubble.camera_Alarm);
            CameraRig.rig[curCam].cam.motionAlarm += new alarmEventHandler(bubble.camera_Alarm);

            bubble.webcamAttached = true;

            button23.SynchronisedInvoke(() => button23.Enabled = CameraRig.camerasAttached());
            //SetButtonEnabled(button23, CameraRig.camerasAttached());
        }