Esempio n. 1
0
        //overload that allows us to read the file from an outside program; returns a new list of settings to be utilized
        public static SettingsData readFile(List<String> audioDeviceLst, List<String> vidDeviceLst)
        {
            //check if the config file exists; if not, create a default config file
            if (File.Exists(Application.StartupPath + @"\config.xml") == false)
            {
                String generateSavePath = @"C:\Users\" + Environment.UserName + @"\Videos\WaLLBoT Recordings\";
                //generate a default save path based on the user that is currently logged in
                System.IO.Directory.CreateDirectory(generateSavePath);
                //write a new file based on the defaults
                SettingsData theSettings = new SettingsData(audioDeviceLst[0], vidDeviceLst[0], generateSavePath, new YCbCr(50, 124, 130), new YCbCr(90, 140, 140), 0.15f, 500, 3);

                //write code just coppied into the static version...for ease
                XmlSerializer toSerialize = new XmlSerializer(typeof(SettingsData));
                //config file is local to the app's executable
                TextWriter textWriter = new StreamWriter(Application.StartupPath + @"\config.xml");
                toSerialize.Serialize(textWriter, theSettings);
                //close the writer...b/c that'd be dumb to leave it open
                textWriter.Close();
            }
            //now that the file is existent, make
            XmlSerializer deserializer = new XmlSerializer(typeof(SettingsData));
            TextReader textReader = new StreamReader(Application.StartupPath + @"\config.xml");
            SettingsData localSettings = (SettingsData)deserializer.Deserialize(textReader);
            textReader.Close();
            //returns the
            return (localSettings);
        }
Esempio n. 2
0
        public mainScreen()
        {
            InitializeComponent();

            //initilize a list of string equivalents of audio visual devices
            initDeviceList();

            //read the datta in
            theSettings = Settings.readFile(audioDeviceLst, vidDeviceLst);

            //construct the values for the actual devices
            convertStringToDevice(theSettings);

            // Starts new job for preview window
            audVidJob = new LiveJob();

            // Create a new device source. We use the first audio and video devices on the system
            deviceSource = audVidJob.AddDeviceSource(videoDevice, audioDevice);
            // Sets preview window to winform panel hosted by xaml window
            deviceSource.PreviewWindow = new PreviewWindow(new HandleRef(this.panel1, this.panel1.Handle));

            // Make this source the active one
            audVidJob.ActivateSource(deviceSource);
            //update the face detection values displayed (based on what is read from the file)
            this.updateDetectionGUI();
            this.statusLbl.Text = BoTStatus.Detecting.ToString();
            //check the number of videos recorded at start by counting how many videos have been recorded
            System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(theSettings.savePath);
            this.numRecorded = dir.GetFiles().Length;
            this.recordedLbl.Text = numRecorded.ToString();
            //now that the form and it's members have been properly initialized, initialize and start the facial
            //recognition system
            faceRecognizer = new FaceHandler(this);
            //initialize the speech recognition system but DO NOT START IT
            voiceRecognizer = new VoiceHandler(this);
            faceRecognizer.Start();
        }
Esempio n. 3
0
 //take the string of the device chosen (from the GUI) and return the audio/video devices we need
 private void convertStringToDevice(SettingsData theSettings)
 {
     foreach (EncoderDevice edv in EncoderDevices.FindDevices(EncoderDeviceType.Video))
     {
         if(edv.Name == theSettings.vidDev)
         {
             videoDevice = edv;
             //break to stop looping
             break;
         }
     }
     foreach (EncoderDevice eda in EncoderDevices.FindDevices(EncoderDeviceType.Audio))
     {
         if (eda.Name == theSettings.audioDev)
         {
             audioDevice = eda;
             //break to stop looping
             break;
         }
     }
 }
Esempio n. 4
0
 private void saveBtn_Click(object sender, EventArgs e)
 {
     //set all the color values
     this.recordColorTextBox();
     //build the settings "structure" with all sorts of good data
     SettingsData theSettings = new SettingsData(audioDevBox.Text, vidDevBox.Text, pathBox.Text,this.minYCbCr,this.maxYCbCr,this.percentSkin,this.msRefresh,this.cycleConfirm);
     //write the current data to a file
     writeFile(theSettings);
     this.Close();
 }
Esempio n. 5
0
        private void readFile()
        {
            //check if the config file exists; if not, create a default config file
            if (File.Exists(Application.StartupPath + @"\config.xml") == false)
            {
                String generateSavePath = @"C:\Users\" + Environment.UserName + @"\Videos\WaLLBoT Recordings\";
                //generate a default save path based on the user that is currently logged in
                System.IO.Directory.CreateDirectory(generateSavePath);
                //write a new file based on the default
                writeFile(new SettingsData(this.audioDeviceLst[0], this.vidDeviceLst[0], generateSavePath, new YCbCr(50, 124, 130), new YCbCr(90, 140, 140), 0.15f, 500, 3));
            }

            //now that the file is existent, make
            XmlSerializer deserializer = new XmlSerializer(typeof(SettingsData));
            TextReader textReader = new StreamReader(Application.StartupPath + @"\config.xml");
            settings = (SettingsData)deserializer.Deserialize(textReader);
            textReader.Close();
        }
Esempio n. 6
0
 public void writeFile(SettingsData theSettings)
 {
     //serialize that shit!
     XmlSerializer toSerialize = new XmlSerializer(typeof(SettingsData));
     //config file is local to the app's executable
     TextWriter textWriter = new StreamWriter(Application.StartupPath + @"\config.xml");
     toSerialize.Serialize(textWriter, theSettings);
     //close the writer...b/c that'd be dumb to leave it open
     textWriter.Close();
 }