public FaceEditorDialog(Face face, Widget parent, bool newFace) : base("FaceEditorDialog", "FaceSpot.ui.FaceSpot.glade") { this.face =face; this.newFace = newFace; Dialog.Parent = parent; Dialog.Modal = true; //Dialog.TransientFor = parent; Gdk.Pixbuf pix = null; if(face.iconPixbuf != null){ pix = face.iconPixbuf; //TODO Determine Resize Method faceImage.Pixbuf = pix.ScaleSimple (100, 100, FaceSpot.IconResizeInterpType); }else { //TODO What's here??? } ok_button.Clicked += OkButtonClicked; cancel_button.Clicked += CancelButtonClicked; this.Dialog.Destroyed += DialoghandleDestroyed; PopulateCategoryComboBoxEntry(); InitializeEntryCompletion (); PersonErrorLabel.Text = ""; if(face.Tag != null){ Log.Debug("Set Entry's text to Tag "+face.Tag.Name); peopleComboBoxEntry.Entry.Text = face.Tag.Name; }else Log.Debug("No Tag for this face yet"+face.Id); Dialog.ShowAll (); OnFinished += HandleOnFinished; }
/// <summary> /// Process PCA and save a serialized recognizer in specified savepath /// </summary> /// <param name="faces"> /// A <see cref="List<FaceTag>"/> /// </param> /// <param name="savepath"> /// A <see cref="System.String"/> /// </param> /// <param name="filename"> /// A <see cref="System.String"/> /// </param> //private void ProcessPCA(List<FaceTag> faces){ public EigenValueTags ProcessPCA(Face[] faces) { Log.Debug("ProcessPCA Started..."); int MINFACES = 3; int numsFaces = faces.Length; List<Image<Gray, Byte>> train_imagesList = new List<Image<Gray, byte>>(); List<string> train_labelsList = new List<string>(); // load faces from detected data List<int> banList = new List<int>(); // filter too small number of faces for(int i=0;i<faces.Length;i++){ uint cnt = 0; for(int j=0;j<faces.Length;j++){ if(i==j || faces[i].Tag.Name.Equals(faces[j].Tag.Name)){ cnt++; } } if(cnt < MINFACES) banList.Add(i); } for(int k=0;k<faces.Length;k++){ if(faces[k].Tag == null || banList.Contains(k)){ //Log.Debug("null Tag :: id = {0}, name = {0}",faces[k].Id,faces[k].Name); continue; } train_labelsList.Add(faces[k].Tag.Name); train_imagesList.Add(ImageTypeConverter.ConvertPixbufToGrayCVImage(faces[k].iconPixbuf)); } //FIXME for(int k=0; k<train_imagesList.Count;k++){ train_imagesList[k] = train_imagesList[k].Resize(100,100); } string[] train_labels = train_labelsList.ToArray(); Image<Gray, Byte>[] train_images = train_imagesList.ToArray(); MCvTermCriteria crit = new MCvTermCriteria(0.0001); EigenObjectRecognizer eigenRec = new EigenObjectRecognizer(train_images,train_labels,5000,ref crit); string path = Path.Combine (FSpot.Global.BaseDirectory, "eigen.dat"); // Serialize SerializeUtil.Serialize(path, eigenRec); // save recognized data into file of eigen value and into EigenValueTags class EigenValueTags eigenVtags = RecordEigenValue(eigenRec); Log.Debug("ProcessPCA ended..."); return eigenVtags; }
public static RecognitionJob Create(Face face,JobPriority priority) { Log.Debug("RecognitionJob .Create "+face.Id); uint id = 0; RecognitionJob job = new RecognitionJob(id,face.Id.ToString(), DateTime.Now, priority, persistent); Scheduler.Schedule(job,priority); job.Status = FSpot.Jobs.JobStatus.Scheduled; return job; }
public FaceTag(Face f) { this.tag = f.Tag.Name; this.faceImage = ImageTypeConverter.ConvertPixbufToCVImage(f.iconPixbuf).Convert<Gray, byte>(); }
internal void Classify(Face face) { if(!isReady){ //Log.Debug(">>> Classify() not ready"); return; } Log.Debug(">>> Classify() called - {0}", face.Id); //System.Threading.Thread.Sleep(10); Emgu.CV.Image<Gray, byte> emFace = ImageTypeConverter.ConvertPixbufToGrayCVImage(face.iconPixbuf); //emFace.Save("/home/hyperjump/out/"+face.Id + "a.png"); //emFace.Save(face.Tag.Name+".jpg"); float[] eigenValue = EigenObjectRecognizer.EigenDecomposite(emFace,eigenRec.EigenImages,eigenRec.AverageImage); //float[] eigenValue = eigenRec.GetEigenDistances(emFace); Log.Debug("eigenValue.Length = {0}", eigenValue.Length); if(bpnet == null){ Log.Debug("bpnet == null"); LoadTrainedNetwork(); } int inputNodes = bpnet.InputLayer.NeuronCount; Log.Debug("bpnet.InputLayer.NeuronCount = {0}", bpnet.InputLayer.NeuronCount); double[] v = new double[inputNodes]; //fixme - this is slow EigenValueTags eigenVTags = EigenRecognizer.Instance.RecordEigenValue(eigenRec); for(int j=0;j<inputNodes;j++){ v[j] = (double)eigenValue[j]; } //Log.Debug("mean sqr error = {0}",bpnet.MeanSquaredError); double[] output = bpnet.Run(v); for(int j=0;j<output.Length;j++) Console.Write("{0},",output[j]); Console.WriteLine(); // suggestedname from neural network string suggestedName = AnalyseNetworkOutput(eigenVTags, output); // suggestedname from nearest neighbor string sss = eigenRec.Recognize(ImageTypeConverter.ConvertPixbufToGrayCVImage(face.iconPixbuf)); if( sss == null || sss.Length == 0){ suggestedName = null; } else{ // suggestedName = sss; } Log.Debug("no suggestion - id = {0}, name = {0}",face.Id, face.Name); if(suggestedName != null && suggestedName.Length != 0){ Tag tag = MainWindow.Toplevel.Database.Tags.GetTagByName(suggestedName); if(tag ==null ) Log.Debug("Error: Doesn't Found Tag Name"+suggestedName); else Log.Debug("Found Tag"+tag.Name); if(!face.HasRejected(tag)){ Log.Debug("Classify Face#"+face.Id+" Finished : ="+suggestedName+"?"); face.Tag = tag; } else { Log.Debug("Unfortunately Face#"+face.Id+" has already rejected ="+suggestedName+"!"); } }else { Log.Debug("Classify Face#"+face.Id+" Finished - No suggestions"); // this will removed the previous suggested tag //FaceSpotDb.Instance.Faces.RemoveTagbyId(face.Id); } FaceSpotDb.Instance.Faces.Commit(face); face.autoRecognized = true; Log.Debug(">>> Classify() ended - {0}", face.Id); }
public static void Train(Face[] faces) { TrainNetwork(EigenRecognizer.Instance.ProcessPCA(faces)); FaceClassifier.Instance.LoadResource(); }
void SetListStoreFaces(Face[] faces) { try { //Log.Debug(">>> SetListStoreFaces Called"); //if(listStore != null) // listStore.Clear (); InitListStore(); if(faces!=null && faces.Length > 0){ this.faces = faces; int i=0; foreach (Face face in faces) { //Log.Debug ("SetListStoreFaces Append Face#" + (i) + " "); if (face != null && listStore != null) { string name = face.Name == null ? "?" /*+" : #"+face.Id.ToString ()*/ : face.Name; string nameWithIdIfUnknown = face.Name == null ? "?" +" : #"+face.Id.ToString () : face.Name; //Log.Debug("Scaling #"+i); Pixbuf facePixbuf = face.iconPixbuf != null ? face.iconPixbuf.ScaleSimple (FaceSpot.THUMBNAIL_SIZE, FaceSpot.THUMBNAIL_SIZE, FaceSpot.IconResizeInterpType) : null; //Pixbuf facePixbuf = null; //int thmSize = FaceSpot.THUMBNAIL_SIZE; //Pixbuf facePixbuf = face.iconPixbuf != null ? ImageTypeConverter.ConvertCVImageToPixbuf(ImageTypeConverter.ConvertPixbufToCVImage(face.iconPixbuf).Resize(thmSize,thmSize)) : null; if (facePixbuf == null) Log.Exception (new Exception ("Allowed null Face Pixbuf to the faceiconview")); if(IsBrowserType){ if(IsShowFullImage){ //Log.Debug("BroswerIsShowFullImage #"+i); Pixbuf fullPixbuf = ThumbnailCache.Default.GetThumbnailForUri(face.photo.DefaultVersionUri); if(fullPixbuf == null){ fullPixbuf = ThumbnailGenerator.Create(face.photo.DefaultVersionUri); ThumbnailCache.Default.AddThumbnail(face.photo.DefaultVersionUri,fullPixbuf); } try { listStore.AppendValues (name, facePixbuf, face,nameWithIdIfUnknown,fullPixbuf); } catch (Exception e) { Log.Exception("Exception in List Store appendvalue",e); } } else { //Log.Debug("BroswerIsNotShowFullImage #"+i); try { listStore.AppendValues (name, facePixbuf, face,nameWithIdIfUnknown,facePixbuf); } catch (Exception e) { Log.Exception("Exception in List Store appendvalue",e); } } } else { //Log.Debug("Sidebar IsNotShowFullImage #"+i+" " + (facePixbuf == null) ); try { listStore.AppendValues (name, facePixbuf, face,nameWithIdIfUnknown); } catch (Exception e) { Log.Exception("Exception in List Store appendvalue",e); } } Log.Debug("Finish Append Face Value #"+i); i++; } else Log.Exception (new Exception ("Allowed null Face input to the faceiconview")); } //Log.Debug(">>> SetListStoreFaces Ended"); } this.Model = listStore; } catch (Exception e) { Log.Exception("Exception in List Store Faces!!!",e); } }
public static RecognitionJob Create(Face face) { return Create(face,JobPriority.Lowest); }
public RecognitionJob(uint id, string job_options, DateTime run_at, JobPriority job_priority, bool persistent) : base(id, job_options, job_priority, run_at, persistent) { this.priority = job_priority; this.face = FaceSpotDb.Instance.Faces.Get(Convert.ToUInt32(job_options)); }