Exemplo n.º 1
0
 public static string CaptureWebcamImage(Webcam camera, PictureBox webcamImage)
 {
     if (Properties.Settings.Default.WebcamEnabled)
     {
         try
         {
             camera.StartWebcam();
         }
         catch (Exception)
         {
             MessageBox.Show(Constant.ERROR_MESSAGE_WEBCAM_TROUBLE, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return(null);
         }
         System.Threading.Thread.Sleep(Constant.DELAY_TIME_WEBCAM);
         if (webcamImage.Image == null)
         {
             MessageBox.Show(Constant.ERROR_MESSAGE_WEBCAM_SNAPSHOOT_FAILED, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             camera.StopWebcam();
             return(null);
         }
         else
         {
             camera.StopWebcam();
             Bitmap bmp = new Bitmap(webcamImage.Image, Properties.Settings.Default.WebcamWidth, Properties.Settings.Default.WebcamHeight);
             return(bmp.ToBase64String(ImageFormat.Jpeg));
         }
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        Webcam myTarget = (Webcam)target;

        EditorGUILayout.Separator();
        myTarget.getDeviceByName = EditorGUILayout.Toggle("Device Index/Name: ", myTarget.getDeviceByName);
        if (myTarget.getDeviceByName)
        {
            myTarget.deviceName = EditorGUILayout.TextField("Device Name: ", myTarget.deviceName);
        }
        else
        {
            myTarget.deviceIndex = EditorGUILayout.IntField("Device Index: ", myTarget.deviceIndex);
        }
        EditorGUILayout.Separator();
        myTarget.setRequestResolution = EditorGUILayout.Toggle("Manual Resolution: ", myTarget.setRequestResolution);
        if (myTarget.setRequestResolution)
        {
            myTarget.resolutionWidth  = EditorGUILayout.IntField("Width: ", myTarget.resolutionWidth);
            myTarget.resolutionHeight = EditorGUILayout.IntField("Height: ", myTarget.resolutionHeight);
        }
        EditorGUILayout.Separator();
        myTarget.setFPS = EditorGUILayout.Toggle("Manual FPS: ", myTarget.setFPS);
        if (myTarget.setFPS)
        {
            myTarget.requestedFPS = EditorGUILayout.IntField("Requested FPS: ", myTarget.requestedFPS);
        }
        EditorGUILayout.Separator();
        myTarget.mirrorHorizontal = EditorGUILayout.Toggle("Mirror Horizontal: ", myTarget.mirrorHorizontal);
    }
Exemplo n.º 3
0
		public CustomWebcam() {
			InitializeComponent();
			CreateDirectories();
			WebcamControl = new Webcam {ImageDirectory = ConfigData.TempDirectory, PictureFormat = ImageFormat.Png, VideoDevice = null};
			DataContext = WebcamControl;
			RedrawAsync();
		}
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            if (validarfoto())
            {
                auto datos = new auto();
                datos.marca        = txtMarca.Text;
                datos.modelo       = txtModelo.Text;
                datos.color        = txtColor.Text;
                datos.precio       = double.Parse(txtPrecio.Text);
                datos.nserie       = txtNoSerie.Text;
                datos.nacionalidad = txtNacionalidad.Text;
                datos.Observacion  = txtObservaciones.Text;
                clsManejoAutos.savenewauto(datos, idpropietario);

                galeria datosGla1 = new galeria();
                datosGla1.fotografia = Webcam.SaveImageCapture(pcbFoto1.Image);
                clsGaleria.saveGaleria(datosGla1, datos.idauto);

                galeria datosGla2 = new galeria();
                datosGla2.fotografia = Webcam.SaveImageCapture(pcbFoto2.Image);
                clsGaleria.saveGaleria(datosGla2, datos.idauto);

                galeria datosGla3 = new galeria();
                datosGla3.fotografia = Webcam.SaveImageCapture(pcbFoto3.Image);
                clsGaleria.saveGaleria(datosGla3, datos.idauto);
                this.Close();
            }
            else
            {
                MessageBox.Show("Faltan las imagenes");
            }
        }
Exemplo n.º 5
0
        private void recognizeButton_Click(object sender, EventArgs e)
        {
            Webcam.Retrieve(Frame);
            var imageFrame = Frame.ToImage <Gray, byte>();

            if (imageFrame != null)
            {
                var faces = FaceDetection.DetectMultiScale(imageFrame, 1.3, 5);
                Console.WriteLine($"Faces detected: {faces.Count()}");
                if (faces.Count() != 0)
                {
                    var processedImage = imageFrame.Copy(faces[0]).Resize(ProcessedImageWidth, ProcessedImageHeight, Emgu.CV.CvEnum.Inter.Cubic);
                    try
                    {
                        var result = FaceRecognition.Predict(processedImage);
                        Console.WriteLine(CheckRecognizeResults(result, _threshold));
                    }
                    catch (Exception ex)
                    {
                        //Console.WriteLine("No faces trained, can't recognize");
                    }
                }
                else
                {
                    //Console.WriteLine("No faces found");
                }
            }
        }
Exemplo n.º 6
0
        private void WebcamRecorder_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var webcam = new Webcam();
            Hide();

            var result = webcam.ShowDialog();

            if (result.HasValue && result.Value)
            {
                // If Close
                Environment.Exit(0);
            }
            else if (result.HasValue)
            {
                #region If Backbutton or Stop Clicked

                if (webcam.ExitArg == ExitAction.Recorded)
                {
                    var editor = new Editor { ListFrames = webcam.ListFrames };
                    GenericShowDialog(editor);
                    return;
                }

                Show();

                #endregion
            }
        }
Exemplo n.º 7
0
        private void Timer_Tick1(object sender, EventArgs e)
        {
            Webcam.Retrieve(Frame);
            var imageFrame = Frame.ToImage <Gray, byte>();


            if (imageFrame != null)
            {
                var faces = FaceDetection.DetectMultiScale(imageFrame, 1.3, 5);

                if (faces.Count() != 0)
                {
                    Image <Gray, byte> processedImage = imageFrame.Copy(faces[0]).Resize(ProcessedImageWidth, ProcessedImageHeight, Inter.Cubic);
                    result = FaceRecognition.Predict(processedImage);

                    foreach (var id in listOfIds)
                    {
                        if (result.Label == id)
                        {
                            isUnknown   = false;
                            isPredicted = true;
                        }
                        else
                        {
                            isUnknown = true;
                        }
                    }
                }
            }
        }
        private async Task RecognizeAndGreetViewer()
        {
            this.IsRecognizing = true;
            // let viewer know we're taking picture
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => InterruptText.Text = "Taking picture...");

            // take their photo
            StorageFile photoFile = await Webcam.TakePhoto();

            // let viewer know we're recognizing them
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => InterruptText.Text = "Recognizing...");

            // use Cognitive Services to identify them
            string name = await FaceAPI.GetViewerName(photoFile);

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                // clear waiting text
                InterruptText.Text = "";
                // greet viewer on screen
                GpioStatus.Text = "Greetings, " + name;
            });

            // clear the interrupt flag so that interrupt can occur again
            vncl4010Sensor.ClearInterruptFlag();

            // delete photo taken of viewer
            await photoFile.DeleteAsync();

            this.IsRecognizing = false;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LxWebcam"/> class.
        /// Must be public for COM registration.
        /// </summary>
        public Camera()
        {
            traceLogger = new TraceLogger("", "LxWebcam");
            ReadProfile(); // Read device configuration from the ASCOM Profile store

            traceLogger.LogMessage("Camera", "Starting initialisation");

            webcam  = null;
            comPort = null;

            cameraXSize      = 0;
            cameraYSize      = 0;
            numX             = 0;
            numY             = 0;
            startX           = 0;
            startY           = 0;
            exposureMin      = double.NaN;
            exposureMax      = double.NaN;
            exposureStart    = DateTime.MinValue;
            exposureAbort    = DateTime.MinValue;
            exposureDuration = double.NaN;
            imageReady       = false;
            imageArray       = null;
            cameraState      = CameraStates.cameraIdle;
            pulseGuideMin    = 0;
            pulseGuideMax    = 0;
            semaphore        = null;
            threadRunning    = false;
            thread           = null;

            traceLogger.LogMessage("Camera", "Completed initialisation");
        }
Exemplo n.º 10
0
        private async void BtnRecognize_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                txtStatus.Text = "Recognizing...";

                // take their photo
                StorageFile photoFile = await Webcam.TakePhoto();

                txtStatus.Text = "Recognizing...";

                // use Cognitive Services to identify them
                string name = await FaceAPI.GetViewerName(photoFile, txtGroupId.Text);

                txtStatus.Text = "Greetings " + name;

                // delete photo taken of viewer
                await photoFile.DeleteAsync();
            }
            catch (Exception ex)
            {
                // clear waiting text
                txtStatus.Text = ex.Message;
            }
        }
Exemplo n.º 11
0
        private async void BtnTrainPerson_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                txtStatus.Text = "Taking picture...";

                // take their photo
                StorageFile photoFile = await Webcam.TakePhoto();

                txtStatus.Text = "Adding face...";

                var persistedFace = await FaceAPI.AddFace(photoFile, txtGroupId.Text, new Guid(txtPersonId.Text));

                if (persistedFace == null)
                {
                    txtStatus.Text = "No face detected";
                }
                else
                {
                    // clear waiting text
                    txtStatus.Text = "";
                }

                // delete photo taken of viewer
                await photoFile.DeleteAsync();

                this.lstPeople.ItemsSource = await FaceAPI.GetPeopleByGroup(txtGroupId.Text);
            }
            catch (Exception ex)
            {
                // clear waiting text
                txtStatus.Text = ex.Message;
            }
        }
 public void Destroy()
 {
     if (Webcam.isPlaying)
     {
         Webcam.Stop();
     }
 }
Exemplo n.º 13
0
        public ChatRoomViewModel(MainViewModel mainVM, string ip, int remotePort, Server server)
        {
            this.mainVM = mainVM;
            this.server = server;
            uniqueID    = (int)(GetHashCode() & 0xFFFFFFFC);

            myModel = new UserModel(uniqueID, mainVM.Name);
            client  = new Client(ip, remotePort, uniqueID, this);
            client.SendData(ConvertClass.ObjectToByteArray(myModel), 0, uniqueID + 0);
            users            = new List <UserModel>();
            webcam           = new Webcam((new FilterInfoCollection(FilterCategory.VideoInputDevice))[0]);
            webcam.NewFrame += (sender, e) =>
            {
                if (myModel.IsScreenDemonstration != true)
                {
                    client.SendData(ConvertClass.ConvertBitmapToByte((Bitmap)e.Frame.Clone()), 0, uniqueID + 1);
                }
            };
            audioRecord = new AudioRecord(0);
            audioRecord.DataAvailable += (sender, e) =>
            {
                client.SendData(e.Buffer, 0, uniqueID + 2);
            };
            demonstration           = new ScreenDemonstration();
            demonstration.NewFrame += (sender, e) =>
            {
                client.SendData(ConvertClass.ConvertBitmapToByte((Bitmap)e.Frame.Clone()), 0, uniqueID + 1);
            };
        }
Exemplo n.º 14
0
    //Not used on encoder
    private void playVideo(string fileName)
    {
        //constructor for playpreview
        webcamPlay = new WebcamFfmpeg(Webcam.Action.PLAYFILE, UtilAll.GetOSEnum(), "", "", "");
        Webcam.Result result = webcamPlay.PlayFile(fileName);

        /*
         * TODO: reimplement this with ffmpeg
         *
         * if(File.Exists(fileName)) {
         *      LogB.Information("Play video starting...");
         *      PlayerBin player = new PlayerBin();
         *      player.Open(fileName);
         *
         *      //without these lines works also but has less functionalities (speed, go to ms)
         *      Gtk.Window d = new Gtk.Window(Catalog.GetString("Playing video"));
         *      d.Add(player);
         *      d.Modal = true;
         *      d.SetDefaultSize(500,400);
         *      d.ShowAll();
         *      d.DeleteEvent += delegate(object sender, DeleteEventArgs e) {player.Close(); player.Dispose();};
         *
         *      if(play) {
         *              LogB.Information("Play video playing...");
         *              player.Play();
         *      }
         *      return true;
         * }
         */
    }
 public Addpropietario()
 {
     InitializeComponent();
     webcam = new Webcam();
     webcam.InitializeWebCam(ref pcbFoto);
     cboNacionalidad.SelectedIndex = 1;
 }
Exemplo n.º 16
0
 /// <summary>
 /// 新增使用者
 /// </summary>
 /// <param name="user_name">使用者id</param>
 public static void AddUser(string user_name)
 {
     if (Webcam.IsOpened())
     {
         Face.AddUser(user_name);
     }
 }
Exemplo n.º 17
0
 public RecogniseFaceWindow()
 {
     InitializeComponent();
     webcam = new Webcam(facePictureBox);
     webcam.cameraStart();
     faceRecognition = new FaceRecognition();
 }
Exemplo n.º 18
0
        private void WebcamRecorder_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var webcam = new Webcam();

            webcam.Owner = this;

            Hide();

            var result = webcam.ShowDialog();

            if (result.HasValue && result.Value)
            {
                // If Close
                Environment.Exit(0);
            }
            else if (result.HasValue)
            {
                #region If Backbutton or Stop Clicked

                if (webcam.ExitArg == ExitAction.Recorded)
                {
                    var editor = new Editor {
                        ListFrames = webcam.ListFrames
                    };
                    GenericShowDialog(editor);
                    return;
                }

                Show();

                #endregion
            }
        }
Exemplo n.º 19
0
        public async Task GetWebcam([Remainder] String webcamName)
        {
            if (webcamName.Equals("help"))
            {
                await help();

                return;
            }

            WebcamStore webcams     = JsonConvert.DeserializeObject <WebcamStore>(File.ReadAllText(Environment.CurrentDirectory + "\\webcams.json"));
            Webcam      foundCamera = null;

            foreach (Webcam i in webcams.cameras)
            {
                if (i.command.Equals(webcamName))
                {
                    foundCamera = i;
                }
            }

            if (foundCamera == null)
            {
                await ReplyAsync("Webcam not in database.");

                return;
            }

            var image = await PictureService.GetPictureAsync(foundCamera.url);

            image.Seek(0, SeekOrigin.Begin);
            await Context.Channel.SendFileAsync(image, "camera.jpg");
        }
Exemplo n.º 20
0
 void Start()
 {
     webcam = GameObject.Find("CameraInterface").GetComponent <Webcam>();
     InitTexture();
     rend.material.mainTexture = tex;
     webcam.InitiateDevice();
     webcam.SetupCamera();
 }
 public Color32[] GetPixels(Color32[] data = null)
 {
     if (data == null || data.Length != Webcam.width * Webcam.height)
     {
         return(Webcam.GetPixels32());
     }
     return(Webcam.GetPixels32(data));
 }
Exemplo n.º 22
0
        public MainWindow()
        {
            InitializeComponent();

            myVM                = new ViewModel();
            myVM.cameras        = new List <WebCameraId>(Webcam.GetVideoCaptureDevices());
            myVM.SelectedCamera = myVM.cameras[0];
            this.DataContext    = myVM;
        }
Exemplo n.º 23
0
        public void Webcam_ImageGrabbed(object sender, EventArgs e)
        {
            Webcam.Retrieve(Frame);
            var ImageFrame = Frame.ToImage <Bgr, byte>();

            if (ImageFrame != null)
            {
                var grayFrame = ImageFrame.Convert <Gray, byte>();
                var faces     = FaceDetection.DetectMultiScale(grayFrame, 1.3, 5); // Et array af firkanter, som holder alle ansigter den finder.
                // var eyes = EyeDetection.DetectMultiScale(grayFrame, 1.3, 5); // Samme med øjne

                foreach (var face in faces)
                {
                    ImageFrame.Draw(face, new Bgr(Color.LimeGreen), 3);

                    if (result.Label != -1 || isPredicted && doneTraining)
                    {
                        try
                        {
                            Graphics graphicImage1 = Graphics.FromImage(ImageFrame.Bitmap);
                            graphicImage1.DrawString(listOfNames[result.Label - 1],
                                                     new Font("Arial",
                                                              15, FontStyle.Bold),
                                                     new SolidBrush(Color.LimeGreen),
                                                     new Point(face.X, face.Y));
                        }
                        catch (Exception exception)
                        {
                            //No action as the error is useless, it is simply an error in
                            //no data being there to process and this occurss sporadically
                        }
                    }

                    if (result.Label == 0 || result.Label == -1)
                    {
                        Graphics graphicImage2 = Graphics.FromImage(ImageFrame.Bitmap);
                        graphicImage2.DrawString("Unknown",
                                                 new Font("Arial",
                                                          15, FontStyle.Bold),
                                                 new SolidBrush(Color.Red),
                                                 new Point(face.X, face.Y));
                    }
                }

                // ID checker
                Graphics graphicImage = Graphics.FromImage(ImageFrame.Bitmap);
                graphicImage.DrawString($"Face ID: " + result.Label.ToString(),
                                        new Font("Arial",
                                                 15, FontStyle.Bold),
                                        new SolidBrush(Color.LimeGreen),
                                        new Point(0, 50));



                WebcamBox.Image = ImageFrame.ToBitmap(); // shows frames in the UI.
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (pcbFoto.Image != null)
            {
                if (validarPropietario())
                {
                    if (validarAuto())
                    {
                        var datos = new propietario();
                        datos.nombre     = txtNombre.Text;
                        datos.appaterno  = txtApPaterno.Text;
                        datos.apmaterno  = txtApMateno.Text;
                        datos.ine        = txtINE.Text;
                        datos.telefono   = txtTelefono.Text;
                        datos.correo     = txtCorreo.Text;
                        datos.calle      = txtCalle.Text;
                        datos.ncasa      = txtNoCasa.Text;
                        datos.avenida    = txtAvenida.Text;
                        datos.colonia    = txtColonia.Text;
                        datos.ciudad     = txtCiudad.Text;
                        datos.pais       = txtPais.Text;
                        datos.fotografia = Webcam.SaveImageCapture(pcbFoto.Image);
                        //clsManejoPropietarios.SavePropietario(datos);

                        //DataModel ctx = new DataModel();
                        //ctx.propietarios.Attach(datos);

                        var auto = new auto();
                        auto.marca        = txtMarca.Text;
                        auto.modelo       = txtModelo.Text;
                        auto.nserie       = txtNoSerie.Text;
                        auto.precio       = double.Parse(txtPrecio.Text);
                        auto.color        = txtColor.Text;
                        auto.nacionalidad = cboNacionalidad.Text;
                        auto.Observacion  = txtObservaciones.Text;
                        auto.propietarios = datos;
                        clsManejoAutos.SaveAuto(auto);
                        this.Close();
                    }
                    else
                    {
                        errorINE.Clear();
                        errorINE.SetError(txtNoSerie, "Numero de serie duplicado");
                    }
                }
                else
                {
                    errorINE.Clear();
                    errorINE.SetError(txtINE, "Codigo de INE duplicado");
                }
            }
            else
            {
                errorINE.Clear();
                errorINE.SetError(pcbFoto, "Introducir foto para continuar");
            }
        }
Exemplo n.º 25
0
        private void Init()
        {
            //啟用人臉偵測
            Face.Init();
            //載入所有鏡頭
            Cameras_ViewTab.ItemsSource = Webcam.GetAllWebcam();

            UI.SetUI(this);
        }
Exemplo n.º 26
0
        /// <summary>
        ///
        /// </summary>
        public WebCamsTravelRootObject GetBestWebCam(string country, string capital)
        {
            WebCamsTravelRootObject retour = new WebCamsTravelRootObject();
            var geonameClient = new RestClient(_connectGeoNamesURL);
            //geonameClient.Authenticator = new HttpBasicAuthenticator(_webcamsTravelLogin, _webcamsTravelPwd);
            GeonameRestRequestGenerator geonameGenerator = new GeonameRestRequestGenerator();

            IRestResponse <HRGeoNameRootObject> geonameResponse = geonameClient.Execute <HRGeoNameRootObject>(geonameGenerator.Generate(capital, country, "jean.ecard"));
            GeonameRestResponseAnalyser         analyser        = new GeonameRestResponseAnalyser();//!Structure Map
            //!Tester null
            Geoname pCode    = analyser.GetBestFittingPlaceName(capital, geonameResponse.Data.geonames);
            double  parisLat = 0;
            double  parisLon = 0;

            if (pCode != null)
            {
                Double.TryParse(pCode.lat.Replace('.', ','), out parisLat);
                Double.TryParse(pCode.lng.Replace('.', ','), out parisLon);
            }

            //WEBCAMSTRAVEL
            var webCamClient = new RestClient(_connectWebcamsTravelsURL);

            webCamClient.Authenticator = new HttpBasicAuthenticator(_webcamsTravelLogin, _webcamsTravelPwd);

            WebCamsTravelRestRequestGenerator webcamGenerator = new WebCamsTravelRestRequestGenerator();

            var webCamRequest = webcamGenerator.Generate(parisLat, parisLon, country);
            // execute the request
            IRestResponse <WebCamsTravelRootObject> webcamsTravelResponse = webCamClient.Execute <WebCamsTravelRootObject>(webCamRequest);

            if (webcamsTravelResponse != null && webcamsTravelResponse.Data != null && webcamsTravelResponse.Data.result != null)
            {
                WebCamsTravelRestResponseAnalyser webcamsTravelAnalyser = new WebCamsTravelRestResponseAnalyser();
                Webcam bestWebCam = webcamsTravelAnalyser.GetBestFittingWebCam(webcamsTravelResponse.Data.result.webcams);
                if (bestWebCam != null && bestWebCam.player != null)
                {
                    retour.status         = "OK";
                    retour.result         = new Result();
                    retour.result.limit   = 0;
                    retour.result.offset  = 0;
                    retour.result.total   = 1;
                    retour.result.webcams = new List <Webcam>();
                    retour.result.webcams.Add(bestWebCam);
                }
                else
                {
                    retour.status        = "OK";
                    retour.result        = new Result();
                    retour.result.limit  = 0;
                    retour.result.offset = 0;
                    retour.result.total  = 0;
                }
            }
            return(retour);
        }
Exemplo n.º 27
0
        private void InitWebcam()
        {
            if (Webcam == null)
            {
                Webcam = new VideoCapture();
            }

            Webcam.ImageGrabbed += Webcam_ImageGrabbed;
            Webcam.Start();
        }
Exemplo n.º 28
0
        private void BeginWebcam()
        {
            if (Webcam == null)
            {
                Webcam = new VideoCapture();
            }

            Webcam.ImageGrabbed += Webcam_ImageGrabbed; // will call this every time an image is grabbed from the webcam.
            Webcam.Start();
            OutputBox.AppendText($"Webcam Started...{Environment.NewLine}");
        }
 public StoreInstance()
 {
     App             = new App();
     Audio           = new Audio();
     Display         = new Display();
     Obs             = new Obs();
     Pipe            = new Pipe();
     Record          = new Record();
     SelectionWindow = new SelectionWindow();
     Webcam          = new Webcam();
 }
Exemplo n.º 30
0
 private void StartDisplay_Click(object sender, RoutedEventArgs e)
 {
     if (Webcam.GetWebCam() != -1)
     {
         Face.faceRecognition_Timer.Start();
         new Task(new Action(() => { Webcam.Start(); })).Start();
     }
     else
     {
         MessageBox.Show("Please Select Webcam!");
     }
 }
Exemplo n.º 31
0
 private void LoadCamerasBox()
 {
     lists = Webcam.GetCameras();
     foreach (var item in lists)
     {
         camerasBox.Items.Add(item.Value);
         if (item.Key == Webcam.Instance.CameraIndex)
         {
             camerasBox.SelectedIndex = Webcam.Instance.CameraIndex;
         }
     }
 }
Exemplo n.º 32
0
 public LostTicket(Login home)
 {
     InitializeComponent();
     this.home        = home;
     this.webcamImage = webcam;
     this.camera      = new Webcam(this);
     this.bni         = new BNI();
     this.database    = new DBConnect();
     restApi          = new RESTAPI();
     ipAddressServer  = Properties.Settings.Default.IPAddressServer;
     InitData();
 }
Exemplo n.º 33
0
 public PreviewVideoViewModel(Window current, EncoderDevice selectedAudio, EncoderDevice selectedVideo, Webcam cam)
 {
   
     SelectedAudio = selectedAudio;
     SelectedVideo = selectedVideo;
     CurrentWindow = current;
     WebcamCtrl = cam;
         var pathMarcaAgua = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
     pathMarcaAgua += "\\Content\\Images\\" + "MarcaDeAgua.jpg";
     WebcamCtrl.ImagenMarcaAgua = pathMarcaAgua;
   
     CargarVideo();
     
 }
Exemplo n.º 34
0
 /// <summary>
 /// Function to start showing video
 /// </summary>
 /// <param name="videoHandle">Video handle</param>
 /// <param name="videoRegion">Region where to show video</param>
 /// <param name="videoHorizontalResolution">Video horizontal resolution</param>
 /// <param name="videoVerticalResolution">Video vertical resolution</param>
 public void StartVideo(IntPtr videoHandle, SD.Rectangle videoRegion, int videoHorizontalResolution, int videoVerticalResolution)
 {
     //// Creates instance of Web cam class of DirectShow
     this.webCam = new Webcam(videoHandle);
     var selectedCamera = this.SelectCamera();
     if (selectedCamera >= 0)
     {
         var deviceName = this.webCam.StartVideo(videoHandle, videoRegion, videoHorizontalResolution, videoVerticalResolution, selectedCamera);
         CameraStatus.Status = string.IsNullOrEmpty(deviceName) ? CameraAvailability.Busy : CameraAvailability.Available;
     }
     else
     {
         CameraStatus.Status = CameraAvailability.NotAvailable;
     }
 }
Exemplo n.º 35
0
        public GrabacionVideoViewModel(Window currentWindow, EncoderDevice selectedAudio, EncoderDevice selectedVideo, Webcam cam, Grabacion selectedGrabacion)
        {

           
            
            CurrentWindow = currentWindow;
                    
            SelectedAudio = selectedAudio;
            SelectedVideo = selectedVideo;
            SelectedGrabacion = selectedGrabacion;
          
            WebcamCtrl = cam;
            InitializeVm();
            Config = new ConfigWaterMark();
            Config.VideoUrl = "C:\\Videos";
            Config.NombreVideo = WebcamCtrl.NombreVideo.ToString();
            CrearMarcaAgua();
            CargarVideo();

       
            
           // TextTimer = "30:00";

        }
Exemplo n.º 36
0
    void Start()
    {
        webcam = GameObject.FindObjectOfType<Webcam>();
        shouldDrawGrid = textMesh.GetComponent<Renderer>().enabled;

        Shader.SetGlobalFloat("_LightRatio", textMesh.GetComponent<Renderer>().enabled ? 0.5f : 1f);
        SetColor(Color.white);

        materialGrid = new Material(Shader.Find("Hidden/Line"));

        messageMeshSize = messageMesh.characterSize;
        messageMesh.characterSize = 0f;
        currentMessage = 0;
        currentScore = 0;

        watchOutScale = watchOutMesh.transform.localScale.x;
        watchOutMesh.transform.localScale = Vector3.zero;

        textSize = scoreMesh.characterSize;
        textColor = Color.white;
        textColorNext = ColorHSV.GetRandomColor();
        colorAlpha = new Color(1f,1f,1f,0f);
        UpdateText();
    }
Exemplo n.º 37
0
        private void IdentifyDevice(Messenger msgr)
        {
            try
            {
                MessageType type;
                msgr.TcpClient.ReceiveTimeout = 30000;
                byte[] buffer = msgr.ReceiveMessage(out type);
                msgr.TcpClient.ReceiveTimeout = 0;

                if (type == MessageType.Command)
                {
                    string id = Encoding.ASCII.GetString(buffer);
                    Device d = null;

                    if (id.StartsWith("WC:"))
                    {
                        Webcam w = new Webcam(msgr, id, _view.BasePath + @"\" + id.Substring(4));
                        w.Disconnected += OnDisconnect;
                        w.MotionDetected += OnMotionDetect;
                        w.Recorded += (source) => _view.Status = "Webcam " + source.Name + " started recording";
                        w.MotionStopped += (source) =>
                            {
                                ((Webcam)source).StopRecording();
                                _view.Status = "Webcam " + source.Name + " stopped recording";
                            };
                        w.AddClient(this);
                        _view.AddedWebcam = w.Name;
                        _view.Status = "Webcam " + w.Name + " is now connected";
                        d = w;
                    }
                    else if (id.StartsWith("CL:"))
                    {
                        Client c = new Client(msgr, this, id);
                        c.Disconnected += OnDisconnect;
                        c.WebcamChanged += (source) => _view.Status = ((Client)source).EventArg;
                        _view.AddedClient = c.Name;
                        _view.Status = "Client " + c.Name + " is now connected";
                        d = c;
                    }

                    if (d == null)
                        msgr.Dispose();
                    else
                    {
                        _devices.AddOrUpdate(id, d, (key, value) =>
                            {
                                value.Dispose();
                                return d;
                            });
                        d.Listen();
                    }
                }
            }
            catch { msgr.Dispose(); }
        }
Exemplo n.º 38
0
 private void ListenForWebcam()
 {
     try
     {
         do
         {
             TcpClient client = webcamListener.AcceptTcpClient();
             Webcam w = new Webcam(client, BasePath);
             webcamManager.AddWebcam(w);
             w.Connected += new ConnectionHandler(OnWebcamDetected);
             w.Disconnected += new ConnectionHandler(OnWebcamDisconnect);
             w.MotionAlarmed += new ConnectionHandler(OnMotionAlarm);
         }
         while (true);
     }
     catch (SocketException)
     {
     }
 }