Summary description for CameraWindow.
Inheritance: AForge.Controls.PictureBox
Esempio n. 1
0
        public TextToSpeech(CameraWindow cw = null)
        {
            InitializeComponent();

            CW = cw;
            Text = LocRm.GetString("TextToSpeech");
            button1.Text = LocRm.GetString("OK");
        }
Esempio n. 2
0
        private static void SynthToCam(string text, CameraWindow cw)
        {
            var synthFormat = new System.Speech.AudioFormat.SpeechAudioFormatInfo(System.Speech.AudioFormat.EncodingFormat.Pcm, 11025, 16, 1, 22100, 2, null);
            using (var synthesizer = new SpeechSynthesizer())
            {
                using (var waveStream = new MemoryStream())
                {

                    //write some silence to the stream to allow camera to initialise properly
                    var silence = new byte[1 * 22050];
                    waveStream.Write(silence, 0, silence.Length);

                    var pbuilder = new PromptBuilder();
                    var pStyle = new PromptStyle
                    {
                        Emphasis = PromptEmphasis.Strong,
                        Rate = PromptRate.Slow,
                        Volume = PromptVolume.ExtraLoud
                    };

                    pbuilder.StartStyle(pStyle);
                    pbuilder.StartParagraph();
                    pbuilder.StartVoice(VoiceGender.Male, VoiceAge.Adult, 2);
                    pbuilder.StartSentence();
                    pbuilder.AppendText(text);
                    pbuilder.EndSentence();
                    pbuilder.EndVoice();
                    pbuilder.EndParagraph();
                    pbuilder.EndStyle();

                    synthesizer.SetOutputToAudioStream(waveStream, synthFormat);
                    synthesizer.Speak(pbuilder);
                    synthesizer.SetOutputToNull();

                    //write some silence to the stream to allow camera to end properly
                    waveStream.Write(silence, 0, silence.Length);
                    waveStream.Seek(0, SeekOrigin.Begin);

                    var ds = new DirectStream(waveStream) { RecordingFormat = new WaveFormat(11025, 16, 1) };
                    var talkTarget = TalkHelper.GetTalkTarget(cw.Camobject, ds); 
                    ds.Start();
                    talkTarget.Start();
                    while (ds.IsRunning)
                    {
                        Thread.Sleep(100);
                    }
                    ds.Stop();
                    talkTarget.Stop();
                    talkTarget = null;
                    ds = null;
                }
            }


        }
Esempio n. 3
0
        private static void SynthToCam(string fileName, CameraWindow cw)
        {
            using (var waveStream = new MemoryStream())
            {

                //write some silence to the stream to allow camera to initialise properly
                var silence = new byte[1 * 22050];
                waveStream.Write(silence, 0, silence.Count());

                //read in and convert the wave stream into our format
                using (var reader = new WaveFileReader(fileName))
                {
                    var newFormat = new WaveFormat(11025, 16, 1);
                    byte[] buff = new byte[22050];

                    using (var conversionStream = new WaveFormatConversionStream(newFormat, reader))
                    {
                        do
                        {
                            int i = conversionStream.Read(buff, 0, 22050);
                            waveStream.Write(buff, 0, i);
                            if (i < 22050)
                                break;
                        } while (true);
                    }
                }

                //write some silence to the stream to allow camera to end properly
                waveStream.Write(silence, 0, silence.Count());

                waveStream.Seek(0, SeekOrigin.Begin);

                var ds = new DirectStream(waveStream) { RecordingFormat = new WaveFormat(11025, 16, 1) };
                var talkTarget = TalkHelper.GetTalkTarget(cw.Camobject, ds);

                ds.Start();
                talkTarget.Start();
                while (ds.IsRunning)
                {
                    Thread.Sleep(100);
                }
                ds.Stop();
                talkTarget.Stop();
                talkTarget = null;
                ds = null;

                waveStream.Close();
            }
        }
Esempio n. 4
0
 public PTZController(CameraWindow cameraControl)
 {
     _cameraControl = cameraControl;
 }
Esempio n. 5
0
 public void PTZToolUpdate(CameraWindow cw)
 {
     if (_ptzTool != null)
     {
         _ptzTool.CameraControl = cw;
     }
 }
Esempio n. 6
0
 internal void ShowFiles(CameraWindow cw)
 {
     string foldername = Helper.GetMediaDirectory(2, cw.Camobject.id) + "video\\" + cw.Camobject.directory + "\\";
     if (!foldername.EndsWith(@"\"))
         foldername += @"\";
     Process.Start(foldername);
     cw.Camobject.newrecordingcount = 0;
 }
Esempio n. 7
0
        public void TalkTo(CameraWindow cw, bool talk)
        {
            if (string.IsNullOrEmpty(Conf.TalkMic))
                return;

            if (_talkSource != null)
            {
                _talkSource.Stop();
                _talkSource = null;
            }
            if (_talkTarget != null)
            {
                _talkTarget.Stop();
                _talkTarget = null;
            }

            if (!talk)
            {
                if (cw.VolumeControl != null)
                {
                    cw.VolumeControl.Listening = false;
                }
                return;
            }
            Application.DoEvents();
            TalkCamera = cw;
            _talkSource = new TalkDeviceStream(Conf.TalkMic) {RecordingFormat = new WaveFormat(8000, 16, 1)};
            _talkSource.AudioFinished += _talkSource_AudioFinished;

            if (!_talkSource.IsRunning)
                _talkSource.Start();

            _talkTarget = TalkHelper.GetTalkTarget(cw.Camobject, _talkSource);
            _talkTarget.TalkStopped += TalkTargetTalkStopped;
            _talkTarget.Start();

            //auto listen
            if (cw.VolumeControl != null)
            {
                cw.VolumeControl.Listening = true;
            }
        }
Esempio n. 8
0
        private CameraWindow NewCameraWindow(int videoSourceIndex)
        {
            var oc = new objectsCamera
                         {
                             alerts = new objectsCameraAlerts(),
                             detector = new objectsCameraDetector
                                            {
                                                motionzones =
                                                    new objectsCameraDetectorZone
                                                    [0]
                                            },
                             notifications = new objectsCameraNotifications(),
                             recorder = new objectsCameraRecorder(),
                             schedule = new objectsCameraSchedule {entries = new objectsCameraScheduleEntry[0]},
                             settings = new objectsCameraSettings(),
                             ftp = new objectsCameraFtp(),
                             id = -1,
                             directory = RandomString(5),
                             ptz = -1,
                             x = Convert.ToInt32(Random.NextDouble()*100),
                             y = Convert.ToInt32(Random.NextDouble()*100),
                             name = LocRm.GetString("Camera") + " " + NextCameraId
            };
            oc.ptzschedule = new objectsCameraPtzschedule
            {
                active = false,
                entries = new objectsCameraPtzscheduleEntry[] { }
            };
            oc.flipx = oc.flipy = false;
            oc.width = 320;
            oc.height = 240;
            oc.description = "";
            oc.resolution = "320x240";
            oc.newrecordingcount = 0;

            oc.alerts.active = true;
            oc.alerts.mode = "movement";
            oc.alerts.alertoptions = "false,false";
            oc.alerts.objectcountalert = 1;
            oc.alerts.minimuminterval = 180;
            oc.alerts.processmode = "continuous";
            oc.alerts.pluginconfig = "";
            oc.alerts.trigger = "";

            oc.notifications.sendemail = false;
            oc.notifications.sendsms = false;
            oc.notifications.sendmms = false;
            oc.notifications.emailgrabinterval = 0;

            oc.ftp.enabled = false;
            oc.ftp.port = 21;
            oc.ftp.mode = 0;
            oc.ftp.server = "ftp://";
            oc.ftp.interval = 10;
            oc.ftp.filename = "mylivecamerafeed.jpg";
            oc.ftp.localfilename = "{0:yyyy-MM-dd_HH-mm-ss_fff}.jpg";
            oc.ftp.ready = true;
            oc.ftp.text = "www.ispyconnect.com";
            oc.ftp.quality = 75;

            oc.schedule.active = false;

            oc.settings.active = false;
            oc.settings.deleteavi = true;
            oc.settings.ffmpeg = Conf.FFMPEG_Camera;
            oc.settings.emailaddress = EmailAddress;
            oc.settings.smsnumber = MobileNumber;
            oc.settings.suppressnoise = true;
            oc.settings.login = "";
            oc.settings.password = "";
            oc.settings.useragent = "Mozilla/5.0";
            oc.settings.frameinterval = 10;
            oc.settings.sourceindex = videoSourceIndex;
            oc.settings.micpair = -1;
            oc.settings.frameinterval = 200;
            oc.settings.maxframerate = 10;
            oc.settings.maxframeraterecord = 10;
            oc.settings.ptzautotrack = false;
            oc.settings.framerate = 10;
            oc.settings.timestamplocation = 1;
            oc.settings.ptztimetohome = 100;
            oc.settings.ptzchannel = "0";
            oc.settings.timestampformatter = "FPS: {FPS} {0:G} ";
            oc.settings.timestampfontsize = 10;
            oc.settings.notifyondisconnect = false;
            oc.settings.ptzautohomedelay = 30;
            oc.settings.accessgroups = "";

            oc.settings.youtube = new objectsCameraSettingsYoutube
            {
                autoupload = false,
                category = Conf.YouTubeDefaultCategory,
                tags = "iSpy, Motion Detection, Surveillance",
                @public = false
            };
            oc.settings.desktopresizeheight = 480;
            oc.settings.desktopresizewidth = 640;
            oc.settings.resize = false;

            if (VlcHelper.VlcInstalled)
                oc.settings.vlcargs = "-I" + NL + "dummy" + NL + "--ignore-config" + NL +
                                      "--plugin-path=\"" + VlcHelper.VlcPluginsFolder + "\"";
            else
                oc.settings.vlcargs = "";

            oc.detector.recordondetect = true;
            oc.detector.keepobjectedges = false;
            oc.detector.processeveryframe = 1;
            oc.detector.nomovementinterval = 30;
            oc.detector.movementinterval = 0;
            oc.detector.calibrationdelay = 15;
            oc.detector.color = ColorTranslator.ToHtml(Conf.TrackingColor.ToColor());
            oc.detector.type = "Two Frames";
            oc.detector.postprocessor = "None";
            oc.detector.minsensitivity = 20;
            oc.detector.maxsensitivity = 100;
            oc.detector.minwidth = 20;
            oc.detector.minheight = 20;
            oc.detector.highlight = true;

            oc.recorder.bufferseconds = 3;
            oc.recorder.inactiverecord = 8;
            oc.recorder.timelapse = 0;
            oc.recorder.timelapseframes = 0;
            oc.recorder.maxrecordtime = 900;
            oc.recorder.timelapsesave = 60;
            oc.recorder.quality = 8;
            oc.recorder.timelapseframerate = 5;
            oc.recorder.crf = true;

            oc.settings.audioport = 80;
            oc.settings.audiomodel = "None";
            oc.settings.audioip = "";

            var cameraControl = new CameraWindow(oc) { BackColor = Conf.BackColor.ToColor() };
            _pnlCameras.Controls.Add(cameraControl);

            cameraControl.Location = new Point(oc.x, oc.y);
            cameraControl.Size = new Size(320, 240);
            cameraControl.AutoSize = true;
            cameraControl.BringToFront();
            SetCameraEvents(cameraControl);
            if (Conf.AutoLayout)
                LayoutObjects(0, 0);

            cameraControl.Tag = GetControlIndex();

            return cameraControl;
        }
Esempio n. 9
0
        private void RemoveCameraPanel(CameraWindow cameraControl)
        {
            _pnlCameras.Controls.Remove(cameraControl);
            if (!_closing)
            {
                CameraWindow control = cameraControl;
                var oc = Cameras.FirstOrDefault(p => p.id == control.Camobject.id);
                if (oc != null)
                {
                    lock (ThreadLock)
                    {
                        Masterfilelist.RemoveAll(p => p.ObjectId == oc.id && p.ObjectTypeId == 2);
                    }
                    Actions.RemoveAll(p => p.objectid == control.Camobject.id && p.objecttypeid == 2);
                    Cameras.Remove(oc);
                }

                foreach (var ofp in FloorPlans)
                    ofp.needsupdate = true;

                NeedsSync = true;
                SetNewStartPosition();
            }
            Application.DoEvents();
            cameraControl.Dispose();
            if (!_shuttingDown)
            {
                LoadPreviews();
            }
        }
Esempio n. 10
0
        internal void DisplayCamera(objectsCamera cam)
        {
            var cameraControl = new CameraWindow(cam);
            SetCameraEvents(cameraControl);
            cameraControl.BackColor = Conf.BackColor.ToColor();
            _pnlCameras.Controls.Add(cameraControl);
            cameraControl.Location = new Point(cam.x, cam.y);
            cameraControl.Size = new Size(cam.width, cam.height);
            cameraControl.BringToFront();
            cameraControl.Tag = GetControlIndex();

            if (Conf.AutoSchedule && cam.schedule.active && cam.schedule.entries.Any())
            {
                cam.settings.active = false;
                cameraControl.ApplySchedule();
            }
            else
            {
                try
                {
                    if (cam.settings.active)
                        cameraControl.Enable();
                }
                catch (Exception ex)
                {
                    Log.Error("", ex);
                }
            }

            string path = Conf.MediaDirectory + "video\\" + cam.directory + "\\";
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            path = Conf.MediaDirectory + "video\\" + cam.directory + "\\thumbs\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
                //move existing thumbs into directory
                var lfi =
                    Directory.GetFiles(Conf.MediaDirectory + "video\\" + cam.directory + "\\", "*.jpg").ToList();
                foreach (string file in lfi)
                {
                    string destfile = file;
                    int i = destfile.LastIndexOf(@"\", StringComparison.Ordinal);
                    destfile = file.Substring(0, i) + @"\thumbs" + file.Substring(i);
                    File.Move(file, destfile);
                }
            }
            path = Conf.MediaDirectory + "video\\" + cam.directory + "\\grabs\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
        }
Esempio n. 11
0
        public void RemoveCamera(CameraWindow cameraControl, bool confirm)
        {
            if (confirm &&
                MessageBox.Show(LocRm.GetString("AreYouSure"), LocRm.GetString("Confirm"), MessageBoxButtons.OKCancel,
                                MessageBoxIcon.Warning) == DialogResult.Cancel)
                return;
            cameraControl.ShuttingDown = true;
            cameraControl.MouseDown -= CameraControlMouseDown;
            cameraControl.MouseUp -= CameraControlMouseUp;
            cameraControl.MouseMove -= CameraControlMouseMove;
            cameraControl.DoubleClick -= CameraControlDoubleClick;
            cameraControl.RemoteCommand -= CameraControlRemoteCommand;
            cameraControl.Notification -= ControlNotificationHandler;
            if (cameraControl.Recording)
                cameraControl.RecordSwitch(false);

            cameraControl.Disable();
            cameraControl.SaveFileList();

            if (cameraControl.VolumeControl != null)
                RemoveMicrophone(cameraControl.VolumeControl, false);

            if (InvokeRequired)
                Invoke(new CameraCommandDelegate(RemoveCameraPanel), cameraControl);
            else
                RemoveCameraPanel(cameraControl);
        }
Esempio n. 12
0
 public static void Say(string text,CameraWindow cw)
 {
     var t = new Thread(() => SynthToCam(Uri.UnescapeDataString(text), cw));
     t.Start();
 }
Esempio n. 13
0
 public static void Play(string fileName,CameraWindow cw)
 {
     var t = new Thread(() => SynthToCam(fileName, cw));
     t.Start();
 }
Esempio n. 14
0
        private static void SynthToCam(string fileName, CameraWindow cw)
        {
            using (var waveStream = new MemoryStream())
            {

                //write some silence to the stream to allow camera to initialise properly
                var silence = new byte[1 * 22050];
                waveStream.Write(silence, 0, silence.Count());

                //read in and convert the wave stream into our format
                using (var reader = new WaveFileReader(fileName))
                {
                    var newFormat = new WaveFormat(11025, 16, 1);
                    byte[] buff = new byte[22050];

                    using (var conversionStream = new WaveFormatConversionStream(newFormat, reader))
                    {
                        do
                        {
                            int i = conversionStream.Read(buff, 0, 22050);
                            waveStream.Write(buff, 0, i);
                            if (i < 22050)
                                break;
                        } while (true);
                    }
                }

                //write some silence to the stream to allow camera to end properly
                waveStream.Write(silence, 0, silence.Count());

                waveStream.Seek(0, SeekOrigin.Begin);

                ITalkTarget talkTarget;

                var ds = new DirectStream(waveStream) { RecordingFormat = new WaveFormat(11025, 16, 1) };
                switch (cw.Camobject.settings.audiomodel)
                {
                    case "Foscam":
                        ds.Interval = 40;
                        ds.PacketSize = 882; // (40ms packet at 22050 bytes per second)
                        talkTarget = new TalkFoscam(cw.Camobject.settings.audioip, cw.Camobject.settings.audioport,
                                                    cw.Camobject.settings.audiousername,
                                                    cw.Camobject.settings.audiopassword, ds);
                        break;
                    case "NetworkKinect":
                        ds.Interval = 40;
                        ds.PacketSize = 882;
                        talkTarget = new TalkNetworkKinect(cw.Camobject.settings.audioip, cw.Camobject.settings.audioport, ds);
                        break;
                    case "iSpyServer":
                        ds.Interval = 40;
                        ds.PacketSize = 882;
                        talkTarget = new TalkiSpyServer(cw.Camobject.settings.audioip,
                                                        cw.Camobject.settings.audioport,
                                                        ds);
                        break;
                    case "Axis":
                        talkTarget = new TalkAxis(cw.Camobject.settings.audioip, cw.Camobject.settings.audioport,
                                                    cw.Camobject.settings.audiousername,
                                                    cw.Camobject.settings.audiopassword, ds);
                        break;
                    default:
                        //local playback
                        talkTarget = new TalkLocal(ds);

                        break;
                }
                ds.Start();
                talkTarget.Start();
                while (ds.IsRunning)
                {
                    Thread.Sleep(100);
                }
                ds.Stop();
                if (talkTarget != null)
                    talkTarget.Stop();
                talkTarget = null;
                ds = null;

                waveStream.Close();
            }
        }
Esempio n. 15
0
 public ConfigureProcessorForm(CameraWindow CW)
 {
     InitializeComponent();
     RenderResources();
     CameraControl = CW;
 }
Esempio n. 16
0
        private void OpenVideoSource(CameraWindow cw)
        {
            cw.CameraReconnect -= CWCameraReconnect;
            cw.CameraDisabled -= CWCameraDisabled;
            cw.CameraReconnected -= CWCameraReconnected;
            cw.CameraEnabled -= CWCameraEnabled;

            cw.CameraReconnect += CWCameraReconnect;
            cw.CameraDisabled += CWCameraDisabled;
            cw.CameraReconnected += CWCameraReconnected;
            cw.CameraEnabled += CWCameraEnabled;
            cw.HasClones = true;

            bool opened = false;
            if (cw.Camera?.VideoSource != null)
            {
                var source = cw.Camera.VideoSource;
                Camera = new Camera(source);

                Camera.NewFrame -= CameraNewFrame;
                Camera.PlayingFinished -= VideoDeviceVideoFinished;
                Camera.Alarm -= Alarm;
                Camera.ErrorHandler -= CameraWindow_ErrorHandler;
                    
                Camera.NewFrame += CameraNewFrame;
                Camera.PlayingFinished += VideoDeviceVideoFinished;
                Camera.Alarm += Alarm;
                Camera.ErrorHandler += CameraWindow_ErrorHandler;
              
                Calibrating = true;
                _lastRun = Helper.Now.Ticks;
                Camera.Start();
                if (cw.VolumeControl != null && !Camobject.settings.ignoreaudio)
                {
                    if (Camobject.id == -1)
                    {
                        Camobject.id = MainForm.NextCameraId;
                        MainForm.Cameras.Add(Camobject);
                    }
                    var vl = VolumeControl;
                    if (vl == null)
                    {
                        vl = MainForm.InstanceReference.AddCameraMicrophone(Camobject.id, Camobject.name + " mic");
                        Camobject.settings.micpair = vl.Micobject.id;
                    }
                       
                    var m = vl.Micobject;
                    if (m != null)
                    {
                        m.settings.samples = cw.VolumeControl.Micobject.settings.samples;
                        m.settings.channels = cw.VolumeControl.Micobject.settings.channels;
                        m.settings.typeindex = 4;
                        m.settings.buffer = Camobject.recorder.bufferseconds;
                        m.settings.bits = 16;
                        //m.alerts.active = false;
                        //m.detector.recordonalert = false;
                        //m.detector.recordondetect = false;
                    }

                    vl.Disable();
                    vl.Enable();

                    cw.VolumeControl.AudioDeviceEnabled += VLAudioDeviceEnabled;
                        
                }
                opened = true;
            }
            if (!opened)
            {
                SetErrorState("Source camera offline");
                VideoSourceErrorState = true;
                _requestRefresh = true;
            }
        }
Esempio n. 17
0
        public void RemoveCamera(CameraWindow cameraControl, bool confirm)
        {
            if (confirm &&
                MessageBox.Show(LocRm.GetString("AreYouSure"), LocRm.GetString("Confirm"), MessageBoxButtons.OKCancel,
                                MessageBoxIcon.Warning) == DialogResult.Cancel)
                return;

            var dr = DialogResult.No;
            if (confirm)
            {
                dr = MessageBox.Show(LocRm.GetString("DeleteAllAssociatedMedia"), LocRm.GetString("Confirm"),
                    MessageBoxButtons.YesNoCancel,
                    MessageBoxIcon.Question);
            }
            if (dr == DialogResult.Cancel)
                return;

            string folder = cameraControl.Dir.Entry + "video\\" + cameraControl.Camobject.directory + "\\";

            cameraControl.ShuttingDown = true;
            cameraControl.MouseDown -= CameraControlMouseDown;
            cameraControl.MouseUp -= CameraControlMouseUp;
            cameraControl.MouseMove -= CameraControlMouseMove;
            cameraControl.DoubleClick -= CameraControlDoubleClick;
            cameraControl.RemoteCommand -= CameraControlRemoteCommand;
            cameraControl.Notification -= ControlNotification;
            if (cameraControl.Recording)
                cameraControl.RecordSwitch(false);

            cameraControl.Disable();
            cameraControl.SaveFileList();

            if (cameraControl.VolumeControl != null)
                RemoveMicrophone(cameraControl.VolumeControl, false);

            if (InvokeRequired)
                Invoke(new Delegates.CameraCommandDelegate(RemoveCameraPanel), cameraControl);
            else
                RemoveCameraPanel(cameraControl);

            if (dr == DialogResult.Yes)
            {
                try
                {
                    Directory.Delete(folder, true);
                }
                catch (Exception ex)
                {
                    LogExceptionToFile(ex);
                }
            }
        }
Esempio n. 18
0
        private void RemoveCameraPanel(CameraWindow cameraControl)
        {
            _pnlCameras.Controls.Remove(cameraControl);
            if (!MainForm._closing)
            {
                CameraWindow control = cameraControl;
                var oc = MainForm.Cameras.FirstOrDefault(p => p.id == control.Camobject.id);
                if (oc != null)
                {
                    if (ObjectRemoved != null)
                    {
                        ObjectRemoved(this, new ObjectEventArgs(2, oc.id));
                    }

                    MainForm.Cameras.Remove(oc);
                }

                foreach (var ofp in MainForm.FloorPlans)
                    ofp.needsupdate = true;

                MainForm.NeedsSync = true;
                SetNewStartPosition();
            }
            Application.DoEvents();
            cameraControl.Dispose();
            if (!MainForm._closing)
            {
                //LoadPreviews();
            }
        }
Esempio n. 19
0
        private void RemoveCameraPanel(CameraWindow cameraControl)
        {
            _pnlCameras.Controls.Remove(cameraControl);
            if (!_closing)
            {
                CameraWindow control = cameraControl;
                objectsCamera oc = Cameras.FirstOrDefault(p => p.id == control.Camobject.id);
                if (oc != null)
                    Cameras.Remove(oc);

                NeedsSync = true;
                SetNewStartPosition();
            }
            Application.DoEvents();
            cameraControl.Dispose();
            if (!_shuttingDown)
            {
                LoadPreviews();
            }
        }
Esempio n. 20
0
        public void DisplayCamera(objectsCamera cam, bool enableOnDisplay = false)
        {
            var cameraControl = new CameraWindow(cam,this);
            SetCameraEvents(cameraControl);
            cameraControl.BackColor = Conf.BackColor.ToColor();
            _pnlCameras.Controls.Add(cameraControl);
            cameraControl.Location = new Point(cam.x, cam.y);
            cameraControl.Size = new Size(cam.width, cam.height);
            cameraControl.BringToFront();
            cameraControl.Tag = GetControlIndex();

            var dir = Helper.GetMediaDirectory(2, cam.id);
            string path = dir + "video\\" + cam.directory + "\\";
            try
            {
                if (!Directory.Exists(path))
                    Directory.CreateDirectory(path);
                path = dir + "video\\" + cam.directory + "\\thumbs\\";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                    //move existing thumbs into directory
                    var lfi =
                        Directory.GetFiles(dir + "video\\" + cam.directory + "\\", "*.jpg").ToList();
                    foreach (string file in lfi)
                    {
                        string destfile = file;
                        int i = destfile.LastIndexOf(@"\", StringComparison.Ordinal);
                        destfile = file.Substring(0, i) + @"\thumbs" + file.Substring(i);
                        File.Move(file, destfile);
                    }
                }
                path = dir + "video\\" + cam.directory + "\\grabs\\";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
            }
            catch (Exception ex)
            {
                LogExceptionToFile(ex);
            }
            if (enableOnDisplay)
                cameraControl.Enable();
            cameraControl.GetFiles();
        }
Esempio n. 21
0
        public void TalkTo(CameraWindow cw, bool talk)
        {
            if (_talkSource != null)
            {
                _talkSource.Stop();
                _talkSource = null;
            }
            if (_talkTarget != null)
            {
                _talkTarget.Stop();
                _talkTarget = null;
            }

            if (!talk)
            {
                if (cw.VolumeControl != null)
                {
                    cw.VolumeControl.Listening = false;
                }
                return;
            }
            Application.DoEvents();
            TalkCamera = cw;
            _talkSource = new TalkDeviceStream(Conf.TalkMic) { RecordingFormat = new WaveFormat(8000, 16, 1) };
            _talkSource.AudioSourceError += _talkSource_AudioSourceError;

            if (!_talkSource.IsRunning)
                _talkSource.Start();

            switch (cw.Camobject.settings.audiomodel)
            {
                default:
                    _talkTarget = new TalkFoscam(cw.Camobject.settings.audioip, cw.Camobject.settings.audioport, cw.Camobject.settings.audiousername, cw.Camobject.settings.audiopassword, _talkSource);
                    break;
                case "iSpyServer":
                    _talkTarget = new TalkiSpyServer(cw.Camobject.settings.audioip, cw.Camobject.settings.audioport, _talkSource);
                    break;
                case "NetworkKinect":
                    _talkTarget = new TalkNetworkKinect(cw.Camobject.settings.audioip, cw.Camobject.settings.audioport, _talkSource);
                    break;
                case "Axis":
                    _talkTarget = new TalkAxis(cw.Camobject.settings.audioip, cw.Camobject.settings.audioport, cw.Camobject.settings.audiousername, cw.Camobject.settings.audiopassword, _talkSource);
                    break;
            }

            _talkTarget.TalkStopped += TalkTargetTalkStopped;
            _talkTarget.Start();

            //auto listen
            if (cw.VolumeControl != null)
            {
                cw.VolumeControl.Listening = true;
            }
        }
Esempio n. 22
0
        private CameraWindow NewCameraWindow(int videoSourceIndex)
        {
            var oc = new objectsCamera
            {
                alerts = new objectsCameraAlerts(),
                detector = new objectsCameraDetector
                {
                    motionzones =
                        new objectsCameraDetectorZone
                        [0]
                },
                notifications = new objectsCameraNotifications(),
                recorder = new objectsCameraRecorder(),
                schedule = new objectsCameraSchedule { entries = new objectsCameraScheduleEntry[0] },
                settings = new objectsCameraSettings { pip = new objectsCameraSettingsPip { enabled = false, config = ""}},
                ftp = new objectsCameraFtp(),
                savelocal = new objectsCameraSavelocal(),
                id = -1,
                directory = RandomString(5),
                ptz = -1,
                x = Convert.ToInt32(Random.NextDouble() * 100),
                y = Convert.ToInt32(Random.NextDouble() * 100),
                ptzschedule = new objectsCameraPtzschedule
                {
                    active = false,
                    entries = new objectsCameraPtzscheduleEntry[] { }
                }
            };

            string friendlyName = LocRm.GetString("Camera") + " " + NextCameraId;

            string t = friendlyName;
            int i = 1;
            while (Cameras.FirstOrDefault(p => p.name == t) != null)
            {
                t = friendlyName + " (" + i + ")";
                i++;
            }

            oc.name = t;

            oc.flipx = oc.flipy = false;
            oc.width = 320;
            oc.height = 240;
            oc.description = "";
            oc.resolution = "320x240";
            oc.newrecordingcount = 0;

            oc.alerts.active = true;
            oc.alerts.mode = "movement";
            oc.alerts.alertoptions = "false,false";
            oc.alerts.objectcountalert = 1;
            oc.alerts.minimuminterval = 180;
            oc.alerts.processmode = "continuous";
            oc.alerts.pluginconfig = "";
            oc.alerts.trigger = "";

            oc.notifications.sendemail = false;
            oc.notifications.sendsms = false;
            oc.notifications.sendmms = false;
            oc.notifications.emailgrabinterval = 0;

            oc.ftp.enabled = false;
            oc.ftp.port = 21;
            oc.ftp.mode = 0;
            oc.ftp.server = "ftp://";
            oc.ftp.interval = 10;
            oc.ftp.intervalnew = 10;
            oc.ftp.filename = "mylivecamerafeed.jpg";
            oc.ftp.ready = true;
            oc.ftp.text = "www.ispyconnect.com";
            oc.ftp.quality = 75;
            oc.ftp.counter = 0;
            oc.ftp.countermax = 20;
            oc.ftp.minimumdelay = 0;

            oc.savelocal.enabled = false;
            oc.savelocal.mode = 0;
            oc.savelocal.intervalnew = 10;
            oc.savelocal.filename = "{0:yyyy-MM-dd_HH-mm-ss_fff}.jpg";
            oc.savelocal.text = "www.ispyconnect.com";
            oc.savelocal.quality = 75;
            oc.savelocal.counter = 0;
            oc.savelocal.countermax = 20;
            oc.savelocal.minimumdelay = 0;

            oc.schedule.active = false;

            oc.settings.active = false;
            oc.settings.deleteavi = true;
            oc.settings.ffmpeg = Conf.FFMPEG_Camera;
            oc.settings.emailaddress = EmailAddress;
            oc.settings.smsnumber = MobileNumber;
            oc.settings.suppressnoise = true;
            oc.settings.login = "";
            oc.settings.password = "";
            oc.settings.useragent = "Mozilla/5.0";
            oc.settings.frameinterval = 10;
            oc.settings.sourceindex = videoSourceIndex;
            oc.settings.micpair = -1;
            oc.settings.frameinterval = 200;
            oc.settings.maxframerate = 10;
            oc.settings.maxframeraterecord = 10;
            oc.settings.ptzautotrack = false;
            oc.settings.framerate = 10;
            oc.settings.timestamplocation = 1;
            oc.settings.ptztimetohome = 100;
            oc.settings.ptzchannel = "0";
            oc.settings.timestampformatter = "FPS: {FPS} {0:G} ";
            oc.settings.timestampfontsize = 10;
            oc.settings.notifyondisconnect = false;
            oc.settings.ptzautohomedelay = 30;
            oc.settings.accessgroups = "";
            oc.settings.nobuffer = true;
            oc.settings.reconnectinterval = 0;
            oc.settings.timestampforecolor = "255,255,255";
            oc.settings.timestampbackcolor = "70,70,70";
            oc.settings.timestampfont = FontXmlConverter.ConvertToString(Drawfont);
            oc.settings.timestampshowback = true;

            oc.settings.youtube = new objectsCameraSettingsYoutube
            {
                category = Conf.YouTubeDefaultCategory,
                tags = "iSpy, Motion Detection, Surveillance",
                @public = true
            };
            oc.settings.cloudprovider = new objectsCameraSettingsCloudprovider();

            oc.settings.storagemanagement = new objectsCameraSettingsStoragemanagement
            {
                enabled = false,
                maxage = 72,
                maxsize = 1024

            };

            oc.alertevents = new objectsCameraAlertevents { entries = new objectsCameraAlerteventsEntry[] { } };

            oc.settings.desktopresizeheight = 480;
            oc.settings.desktopresizewidth = 640;
            oc.settings.resize = false;
            oc.settings.directoryIndex = Conf.MediaDirectories.First().ID;

            oc.settings.vlcargs = VlcHelper.VlcInstalled ? "--rtsp-caching=100" : "";

            oc.detector.recordondetect = Conf.DefaultRecordOnDetect;
            oc.detector.recordonalert = Conf.DefaultRecordOnAlert;
            oc.detector.keepobjectedges = false;
            oc.detector.processeveryframe = 1;
            oc.detector.nomovementintervalnew = oc.detector.nomovementinterval = 30;
            oc.detector.movementintervalnew = oc.detector.movementinterval = 0;

            oc.detector.calibrationdelay = 15;
            oc.detector.color = ColorTranslator.ToHtml(Conf.TrackingColor.ToColor());
            oc.detector.type = "Two Frames";
            oc.detector.postprocessor = "None";
            oc.detector.minsensitivity = 20;
            oc.detector.maxsensitivity = 100;
            oc.detector.minwidth = 20;
            oc.detector.minheight = 20;
            oc.detector.highlight = true;

            oc.recorder.bufferseconds = 2;
            oc.recorder.inactiverecord = 8;
            oc.recorder.timelapse = 0;
            oc.recorder.timelapseframes = 0;
            oc.recorder.maxrecordtime = 900;
            oc.recorder.timelapsesave = 60;
            oc.recorder.quality = 8;
            oc.recorder.timelapseframerate = 5;
            oc.recorder.crf = true;

            oc.settings.audioport = 80;
            oc.settings.audiomodel = "None";
            oc.settings.audioip = "";
            oc.rotateMode = "RotateNoneFlipNone";

            var cameraControl = new CameraWindow(oc,this) { BackColor = Conf.BackColor.ToColor() };
            _pnlCameras.Controls.Add(cameraControl);

            cameraControl.Location = new Point(oc.x, oc.y);
            cameraControl.Size = new Size(320, 240);
            cameraControl.AutoSize = true;
            cameraControl.BringToFront();
            SetCameraEvents(cameraControl);
            if (Conf.AutoLayout)
                LayoutObjects(0, 0);

            cameraControl.Tag = GetControlIndex();

            return cameraControl;
        }
Esempio n. 23
0
 public ConfigureProcessor(CameraWindow cw)
 {
     InitializeComponent();
     RenderResources();
     _cameraControl = cw;
 }
Esempio n. 24
0
 private void SetCameraEvents(CameraWindow cameraControl)
 {
     cameraControl.MouseDown += CameraControlMouseDown;
     cameraControl.MouseWheel += CameraControlMouseWheel;
     cameraControl.MouseUp += CameraControlMouseUp;
     cameraControl.MouseMove += CameraControlMouseMove;
     cameraControl.DoubleClick += CameraControlDoubleClick;
     cameraControl.RemoteCommand += CameraControlRemoteCommand;
     cameraControl.Notification += ControlNotification;
     cameraControl.FileListUpdated += CameraControlFileListUpdated;
 }
Esempio n. 25
0
 public void Init(CameraWindow cw)
 {
     CW = cw;
     SetText();
 }