public AlgorithmModel(AlgorithmModel malgorithm, bool type) { this.Number = malgorithm.Number; this.Name = malgorithm.Name; this.Path = malgorithm.Path; this.Source = malgorithm.Source; this._type = type; // RealTime Detection type = true if (this._type) { if (this.Source.Equals("code")) { // Face Detection RT if (this.Number.Equals("1")) { _detection = new FaceDetection(true); } // EyesDetection RT if (this.Number.Equals("2")) { _detection = new EyesDetection(true); } } //else if (this.Source.Equals("exe")) //{ //} //else if (this.Source.Equals("dll")) //{ //} } }
/// <summary> /// Apply algorithm to a image and return the algorithm images processes /// </summary> public IImage[] ApplyAlgorithm(string imageFromPath) { if(this.Source.Equals("code")) { // FaceDetection if (this.Number.Equals("1")) { _detection = new FaceDetection(); _detection.DoNormalDetection(imageFromPath); return _detection.getImages(); // escribe la salida de la imagen modificada (con la cara detectada) //string fileNameDraw = @currentDirectory + @"\Temp\webcamM" + ".jpg"; //FileStream fileStreamDraw = new FileStream(fileNameDraw, FileMode.Create); //BitmapSource c = ToBitmapSource(image); //JpegBitmapEncoder encoderDraw = new JpegBitmapEncoder(); //encoderDraw.Frames.Add(BitmapFrame.Create(c)); //encoderDraw.QualityLevel = 100; //encoderDraw.Save(fileStreamDraw); //fileStreamDraw.Close(); //return image; } // EyesDetection if (this.Number.Equals("2")) { _detection = new EyesDetection(); _detection.DoNormalDetection(imageFromPath); return _detection.getImages(); } } //else if (this.Source.Equals("exe")) //{ //} //else if (this.Source.Equals("dll")) //{ //} return null; }