public void database_add_new_activation(Image <Bgr, byte> frame) { string[] lines = File.ReadAllLines(activations_path + "DatabaseFile.txt"); int next_img_ix = lines.Length + 1; File.AppendAllLines(activations_path + "DatabaseFile.txt", IEnumerableExt.FromSingleItem(DateTime.Now.ToString(CultureInfo.GetCultureInfo("en-us")))); frame.Save(activations_path + "Activation" + next_img_ix.ToString("D3") + ".png"); }
public override void Initialize(Table table, Skin skin, float leftCellWidth) { // add a header var label = table.Add(CreateNameLabel(table, skin)).SetColspan(2).GetElement <Label>(); label.SetStyle(label.GetStyle().Clone()).SetFontColor(new Color(228, 228, 76)); table.Row().SetPadLeft(15); // figure out which fiedls and properties are useful to add to the inspector var fields = ReflectionUtils.GetFields(_valueType); foreach (var field in fields) { if (!field.IsPublic && IEnumerableExt.Count(field.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } var inspector = GetInspectorForType(field.FieldType, _target, field); if (inspector != null) { inspector.SetStructTarget(_target, this, field); inspector.Initialize(table, skin, leftCellWidth); _inspectors.Add(inspector); table.Row().SetPadLeft(15); } } var properties = ReflectionUtils.GetProperties(_valueType); foreach (var prop in properties) { if (!prop.CanRead || !prop.CanWrite) { continue; } if ((!prop.GetMethod.IsPublic || !prop.SetMethod.IsPublic) && IEnumerableExt.Count(prop.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } var inspector = GetInspectorForType(prop.PropertyType, _target, prop); if (inspector != null) { inspector.SetStructTarget(_target, this, prop); inspector.Initialize(table, skin, leftCellWidth); _inspectors.Add(inspector); table.Row().SetPadLeft(15); } } }
public override void Initialize(Table table, Skin skin, float leftCellWidth) { // we either have a getter that gets a Material or an Effedt var effect = _valueType == typeof(Material) ? GetValue <Material>().Effect : GetValue <Effect>(); if (effect == null) { return; } // add a header and indent our cells table.Add(effect.GetType().Name).SetColspan(2).GetElement <Label>().SetFontColor(new Color(228, 228, 76)); table.Row().SetPadLeft(15); // figure out which properties are useful to add to the inspector var effectProps = ReflectionUtils.GetProperties(effect.GetType()); foreach (var prop in effectProps) { if (prop.DeclaringType == typeof(Effect)) { continue; } if (!prop.CanRead || !prop.CanWrite || prop.Name == "Name") { continue; } if ((!prop.GetMethod.IsPublic || !prop.SetMethod.IsPublic) && IEnumerableExt.Count(prop.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } var inspector = GetInspectorForType(prop.PropertyType, effect, prop); if (inspector != null) { inspector.SetTarget(effect, prop); inspector.Initialize(table, skin, leftCellWidth); _inspectors.Add(inspector); table.Row().SetPadLeft(15); } } table.Row(); }
public void database_add_new_person(string name, Image <Bgr, byte> frame, Image <Gray, byte> face) { // update systemData Debug.WriteLine($"adding {name} to outgoingData peopleNames"); this.commHelper.outgoingData.people = this.systemData.kinectData.people; this.commHelper.outgoingData.people.Add(name, label_to_int[name]); // add name to database file, create a new directory for this person, main image = frame, face = new facialrectraining image File.AppendAllLines(people_path + "DatabaseFile.txt", IEnumerableExt.FromSingleItem(name)); // save image Directory.CreateDirectory(pathToPeopleFolder + name); File.WriteAllText(pathToPeopleFolder + name + "/Info.txt", DateTime.Now.ToString(CultureInfo.GetCultureInfo("en-us"))); frame.Save(pathToPeopleFolder + name + "/MainImage.png"); face.Convert <Bgr, byte>().Save(pathToPeopleFolder + name + "/FacialRecTraining01.png"); Debug.WriteLine("saved png!"); }
public override void initialize( ) { // add a header // figure out which fiedls and properties are useful to add to the inspector var fields = ReflectionUtils.getFields(_valueType); foreach (var field in fields) { if (!field.IsPublic && IEnumerableExt.count(field.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } var inspector = getInspectorForType(field.FieldType, _target, field); if (inspector != null) { inspector.setStructTarget(_target, this, field); inspector.initialize(); _inspectors.Add(inspector); } } var properties = ReflectionUtils.getProperties(_valueType); foreach (var prop in properties) { if (!prop.CanRead || !prop.CanWrite) { continue; } if ((!prop.GetMethod.IsPublic || !prop.SetMethod.IsPublic) && IEnumerableExt.count(prop.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } var inspector = getInspectorForType(prop.PropertyType, _target, prop); if (inspector != null) { inspector.setStructTarget(_target, this, prop); inspector.initialize(); _inspectors.Add(inspector); } } }
public override void initialize() { base.initialize(); // we either have a getter that gets a Material or an Effect var effect = _valueType == typeof(Material) ? getValue <Material>().effect : getValue <Effect>(); if (effect == null) { return; } Debug.log($"name was {_name}"); _name = effect.GetType().Name; // figure out which properties are useful to add to the inspector var effectProps = ReflectionUtils.getProperties(effect.GetType()); foreach (var prop in effectProps) { if (prop.DeclaringType == typeof(Effect)) { continue; } if (!prop.CanRead || !prop.CanWrite || prop.Name == "Name") { continue; } if ((!prop.GetMethod.IsPublic || !prop.SetMethod.IsPublic) && IEnumerableExt.count(prop.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } var inspector = TypeInspectorUtils.getInspectorForType(prop.PropertyType, effect, prop); if (inspector != null) { inspector.setTarget(effect, prop); inspector.initialize(); _inspectors.Add(inspector); } } }
void ProcessAssembly(Assembly assembly) { foreach (var type in assembly.DefinedTypes) { foreach (var method in type.DeclaredMethods) { CommandAttribute attr = null; var attrs = method.GetCustomAttributes(typeof(CommandAttribute), false) .Where(a => a is CommandAttribute); if (IEnumerableExt.Count(attrs) > 0) { attr = attrs.First() as CommandAttribute; } if (attr != null) { ProcessMethod(method, attr); } } } }
/// <summary> /// fetches all the relevant AbstractTypeInspectors for target including fields, properties and methods. /// </summary> /// <param name="target"></param> /// <returns></returns> public static List <AbstractTypeInspector> getInspectableProperties(object target) { var props = new List <AbstractTypeInspector>(); var targetType = target.GetType(); var fields = ReflectionUtils.getFields(targetType); foreach (var field in fields) { if (!field.IsPublic && IEnumerableExt.count(field.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } if (field.IsInitOnly) { continue; } // skip enabled which is handled elsewhere if (field.Name == "enabled" || field.Name == "entity") { continue; } var inspector = getInspectorForType(field.FieldType, target, field); if (inspector != null) { inspector.setTarget(target, field); inspector.initialize(); props.Add(inspector); } } var properties = ReflectionUtils.getProperties(targetType); foreach (var prop in properties) { if (!prop.CanRead || !prop.CanWrite) { continue; } if ((!prop.GetMethod.IsPublic || !prop.SetMethod.IsPublic) && IEnumerableExt.count(prop.GetCustomAttributes <InspectableAttribute>()) == 0) { continue; } // skip Component.enabled which is handled elsewhere if (prop.Name == "enabled" || prop.Name == "entity") { continue; } var inspector = getInspectorForType(prop.PropertyType, target, prop); if (inspector != null) { inspector.setTarget(target, prop); inspector.initialize(); props.Add(inspector); } } var methods = ReflectionUtils.getMethods(targetType); foreach (var method in methods) { var attr = method.GetCustomAttribute <InspectorCallableAttribute>(); if (attr == null) { continue; } if (!MethodInspector.areParametersValid(method.GetParameters())) { continue; } var inspector = new MethodInspector(); inspector.setTarget(target, method); inspector.initialize(); props.Add(inspector); } return(props); }
public void update_single(Image <Gray, byte> face, int label) { face_recognizer.Update(IEnumerableExt.FromSingleItem(face).ToArray(), IEnumerableExt.FromSingleItem(label).ToArray()); }