public async Task <object> AddUserFaceAsync(string Username, string personId, string uri, string persistedFaceID) { //Get reference to face table var table = await GetFaceTableAsync(); //Create face entity FaceEntity face = new FaceEntity(); face.UserName = Username; face.ImageUrl = uri; face.Id = persistedFaceID; face.PersonId = personId; face.RowKey = face.Id; face.PartitionKey = face.UserName; //Create the TableOperation object that inserts the login entity. TableOperation insertOperation = TableOperation.Insert(face); //Execute the insert operation. try { await table.ExecuteAsync(insertOperation); } catch (Exception ex) { return(ex); } return(true); }
/// <summary> /// 将临时人员信息上传到海康平台 /// </summary> /// <param name="entity"></param> /// <param name="list"></param> public AddJurisdictionEntity InsertTempUserHiK(TemporaryUserEntity entity, List <TemporaryUserEntity> list) { DataItemDetailService data = new DataItemDetailService(); var pitem = data.GetItemValue("Hikappkey"); //密钥 var baseurl = data.GetItemValue("HikBaseUrl"); //海康地址 string Key = string.Empty; string Signature = string.Empty; string no = new Random().Next(10, 888888).ToString(); if (!string.IsNullOrEmpty(pitem)) { Key = pitem.Split('|')[0]; Signature = pitem.Split('|')[1]; } string Url = "/artemis/api/resource/v1/person/single/add"; foreach (var item in list) { //人脸信息(base64必须为jpg格式) List <FaceEntity> faces = new List <FaceEntity>(); FaceEntity face = new FaceEntity(); face.faceData = item.ImgData; faces.Add(face); string orgcode = "root000000"; if (item.Istemporary == 0) { orgcode = item.Groupsid; } var model = new { personId = item.USERID, personName = item.UserName, gender = "1", orgIndexCode = orgcode, birthday = "1990-01-01", phoneNo = item.Tel, email = "*****@*****.**", certificateType = "990", certificateNo = no, jobNo = item.Tel, faces }; //string msg = SocketHelper.LoadCameraList(model, baseurl, Url, Key, Signature); HttpUtillibKbs.SetPlatformInfo(Key, Signature, baseurl, 443, true); byte[] result = HttpUtillibKbs.HttpPost(Url, JsonConvert.SerializeObject(model), 20); if (result != null) { string msg = System.Text.Encoding.UTF8.GetString(result); parkList1 pl = JsonConvert.DeserializeObject <parkList1>(msg); if (pl != null && pl.code == "0") { SetLoadUserCarNo(item, baseurl, Key, Signature); } } } //添加权限 return(UploadUserlimits(list, baseurl, Key, Signature)); }
/// <inheritdoc/> public async Task <FaceEntity> UpdateFaceIdentificationAsync(FaceEntity entity) { await this._table .WithTable(this._settings.Table.Name) .UpdateEntityAsync(entity) .ConfigureAwait(false); return(entity); }
public void AddFaceByID(string id, FaceEntity face) { // Check Data Quality //... // send to the addFaceByIDfunction In PatientDataAccess PatientDataAccess dataAccess = new PatientDataAccess(); dataAccess.AddFaceByID(id, face); }
public override string ToString() { int nFaces = FaceEntity.GetCellFaceCount(); int nCells = FaceEntity.GetCellCount(); int nEdges = FaceEntity.GetEdgeCount(); int nVertices = FaceEntity.GetVertexCount(); return(string.Format("Face(Vertices = {0}, Edges = {1}, AdjacentCells = {2}, CellFaces = {3}, FaceType = {4})", nVertices, nEdges, nCells, nFaces, FaceType)); }
private async Task AssociateFaceToTenant(string tenantGroupId, Guid faceId, string name, IEnumerable <string> imageNames) { var tableClient = storageAccount.CreateCloudTableClient(); var table = tableClient.GetTableReference("Faces"); var faceEntity = new FaceEntity(tenantGroupId) { Name = name, FaceId = faceId, TrainingImageFiles = JsonConvert.SerializeObject(imageNames) }; var insertOperation = TableOperation.Insert(faceEntity); await Task.Run(() => table.Execute(insertOperation)); }
/// <summary> /// 将拜访人员信息上传到海康平台 /// </summary> /// <param name="entity"></param> /// <param name="list"></param> public void UploadUserHiK(VisitcarEntity entity, List <CarUserFileImgEntity> list) { DataItemDetailService data = new DataItemDetailService(); var pitem = data.GetItemValue("Hikappkey"); var baseurl = data.GetItemValue("HikBaseUrl"); string Key = string.Empty; string Signature = string.Empty; //string no = new Random().Next(10, 888888).ToString(); if (!string.IsNullOrEmpty(pitem)) { Key = pitem.Split('|')[0]; Signature = pitem.Split('|')[1]; } string Url = "/artemis/api/resource/v1/person/single/add"; foreach (var item in list) { string time = DateTime.Now.ToString("yyyyMMddHHmmss"); var no = Str.PinYin(item.Username).ToUpper() + time;//卡号唯一 //人脸信息(base64必须为jpg格式) List <FaceEntity> faces = new List <FaceEntity>(); FaceEntity face = new FaceEntity(); face.faceData = item.Imgdata; faces.Add(face); var model = new { personId = item.ID, personName = item.Username, gender = "1", orgIndexCode = "root000000", birthday = "1990-01-01", phoneNo = entity.Phone, email = "*****@*****.**", certificateType = "990", certificateNo = no, faces }; string msg = SocketHelper.LoadCameraList(model, baseurl, Url, Key, Signature); parkList1 pl = JsonConvert.DeserializeObject <parkList1>(msg); if (pl != null && pl.code == "0") { SetLoadUserCarNo(item, baseurl, Key, Signature); } } }
public Face Anylize(string imgPath) { //Analize the face with the Algoriuthma API FaceEntity faceEntity = new FaceEntity(); var input = "{" + " \"image\": \"" + imgPath + "\"," + " \"numResults\": 7" + "}"; var client = new Client("simafd3ZGca0t3jUV8FvJelbN881"); var algorithm = client.algo("deeplearning/EmotionRecognitionCNNMBP/1.0.1"); algorithm.setOptions(timeout: 300); var response = algorithm.pipeJson <object>(input); return(JsonSerializer.Deserialize <Face>(response.result.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true })); }
public void AddFaceByID(string id, FaceEntity face) { // loop through people until ID is found PatientEntity[] list = this.Pull(); foreach (PatientEntity patientEntity in list) { if (patientEntity.UserId == id) { // Add the face to the list patientEntity.Face = face; } } // serialize to back to Jason File.WriteAllText(JsonFileName, JsonSerializer.Serialize(list)); }
/// <summary> /// Gets the <see cref="FaceEntity"/> instance. /// </summary> /// <param name="value"><see cref="Task{CloudTable}"/> instance.</param> /// <param name="personGroupName">Name of the person group.</param> /// <returns>Returns the <see cref="FaceEntity"/> instance.</returns> public static async Task <FaceEntity> GetEntityAsync(this Task <CloudTable> value, string personGroupName) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (string.IsNullOrWhiteSpace(personGroupName)) { throw new ArgumentNullException(nameof(personGroupName)); } var instance = await value.ConfigureAwait(false); var entity = new FaceEntity(personGroupName, Guid.NewGuid().ToString()); var operation = TableOperation.InsertOrReplace(entity); var result = await instance.ExecuteAsync(operation).ConfigureAwait(false); return(entity); }
/// <inheritdoc/> public async Task <FaceEntity> IdentifyFaceAsync(FaceEntity entity, CloudBlockBlob face) { var faces = await this.DetectFacesAsync(face) .ConfigureAwait(false); if (faces.Count != 1) { entity.TooManyOrNoFacesDetected = true; return(entity); } var detected = faces.Select(p => p.FaceId).ToList(); var identified = await this._client .Face .IdentifyAsync(detected, entity.PersonGroupId) .ConfigureAwait(false); var confidence = identified.First().Candidates.First().Confidence; entity.Confidence = confidence; return(entity); }
/// <inheritdoc/> public async Task <FaceEntity> TrainFacesAsync(FaceEntity entity) { await this._client .PersonGroup .TrainAsync(entity.PersonGroupId) .ConfigureAwait(false); while (true) { await Task.Delay(1000); var trainingStatus = await this._client .PersonGroup .GetTrainingStatusAsync(entity.PersonGroupId) .ConfigureAwait(false); if (trainingStatus.Status == TrainingStatusType.Succeeded) { break; } } return(entity); }
/// <inheritdoc/> public async Task <FaceEntity> WithPerson(FaceEntity entity, List <CloudBlockBlob> blobs) { var person = await this._client .PersonGroupPerson .CreateAsync(entity.PersonGroupId, entity.PersonGroup) .ConfigureAwait(false); entity.PersonId = person.PersonId.ToString(); var faceIds = new List <string>(); foreach (var blob in blobs) { try { var url = $"{blob.Uri.AbsoluteUri}{this._settings.Blob.SasToken}"; var face = await this._client .PersonGroupPerson .AddFaceFromUrlAsync(entity.PersonGroupId, person.PersonId, url, blob.Name) .ConfigureAwait(false); var filename = blob.Name .Replace($"{entity.PersonGroup}/", string.Empty) .Replace(".png", string.Empty); faceIds.Add(filename); } catch (Exception ex) { var message = ex.Message; } } entity.FaceIds = string.Join(",", faceIds); return(entity); }
private bool IsLessConfident(FaceEntity identified) { return(identified.Confidence < this._settings.Face.Confidence); }
public void updateFacePanel(FaceEntity hbObjEntity) { var face = hbObjEntity.HBObject; var layout = new DynamicLayout { }; layout.Spacing = new Size(5, 5); layout.Padding = new Padding(10); layout.DefaultSpacing = new Size(2, 2); layout.AddSeparateRow(new Label { Text = $"ID: {face.Name}" }); layout.AddSeparateRow(new Label { Text = "Name:" }); var nameTBox = new TextBox() { }; face.DisplayName = face.DisplayName ?? string.Empty; nameTBox.TextBinding.Bind(face, m => m.DisplayName); layout.AddSeparateRow(nameTBox); layout.AddSeparateRow(new Label { Text = "Face Type:" }); var terrainTypeDP = new EnumDropDown <Face.FaceTypeEnum>(); terrainTypeDP.SelectedValueBinding.Bind(Binding.Delegate(() => face.FaceType, v => face.FaceType = v)); layout.AddSeparateRow(terrainTypeDP); layout.AddSeparateRow(new Label { Text = "Boundary Condition: (WIP)" }); var bcTBox = new TextBox() { }; bcTBox.Enabled = false; bcTBox.TextBinding.Bind(face, m => m.BoundaryCondition.Obj.GetType().Name); layout.AddSeparateRow(bcTBox); layout.AddSeparateRow(new Label { Text = "Properties:" }); var faceRadPropBtn = new Button { Text = "Radiance Properties (WIP)" }; faceRadPropBtn.Click += (s, e) => Dialogs.ShowMessage("Work in progress", "Honeybee"); layout.AddSeparateRow(faceRadPropBtn); var faceEngPropBtn = new Button { Text = "Energy Properties" }; faceEngPropBtn.Click += (s, e) => FacePropBtn_Click(hbObjEntity); layout.AddSeparateRow(faceEngPropBtn); var apertureLBox = new ListBox(); apertureLBox.Height = 100; var apertures = hbObjEntity.ApertureObjRefsWithoutHistory; var faceCount = 0; if (apertures.Any()) { var validApertures = apertures; faceCount = validApertures.Count(); //Check if displace name is null, in case this hb object is not created from rhino. var faceItems = validApertures.Select(_ => _.TryGetApertureEntity().HBObject).Select(_ => new ListItem() { Text = _.DisplayName ?? _.Name, Tag = _ }); apertureLBox.Items.AddRange(faceItems); } layout.AddSeparateRow(new Label { Text = $"Apertures: (total: {faceCount})" }); layout.AddSeparateRow(apertureLBox); var doorLBox = new ListBox(); doorLBox.Height = 50; var doors = hbObjEntity.DoorObjRefsWithoutHistory; if (doors.Any()) { //Check if displace name is null, in case this hb object is not created from rhino. var faceItems = doors.Select(_ => _.TryGetDoorEntity().HBObject).Select(_ => new ListItem() { Text = _.DisplayName ?? _.Name, Tag = _ }); doorLBox.Items.AddRange(faceItems); } layout.AddSeparateRow(new Label { Text = $"Doors:" }); layout.AddSeparateRow(doorLBox); layout.AddSeparateRow(new Label { Text = "IndoorShades:" }); var inShadesListBox = new ListBox(); inShadesListBox.Height = 50; var inShds = face.IndoorShades; if (inShds != null) { var idShds = inShds.Select(_ => new ListItem() { Text = _.DisplayName ?? _.Name, Tag = _ }); inShadesListBox.Items.AddRange(idShds); } layout.AddSeparateRow(inShadesListBox); layout.AddSeparateRow(new Label { Text = "OutdoorShades:" }); var outShadesListBox = new ListBox(); outShadesListBox.Height = 50; var outShds = face.OutdoorShades; if (outShds != null) { var outShdItems = outShds.Select(_ => new ListItem() { Text = _.DisplayName ?? _.Name, Tag = _ }); outShadesListBox.Items.AddRange(outShdItems); } layout.AddSeparateRow(outShadesListBox); layout.Add(null); var data_button = new Button { Text = "Honeybee Data" }; data_button.Click += (sender, e) => Dialogs.ShowEditBox("Honeybee Data", "Honeybee Data can be shared across all platforms.", face.ToJson(), true, out string outJson); layout.AddSeparateRow(data_button, null); this.Content = layout; //layout.up void FacePropBtn_Click(Entities.FaceEntity ent) { var energyProp = ent.HBObject.Properties.Energy ?? new FaceEnergyPropertiesAbridged(); energyProp = FaceEnergyPropertiesAbridged.FromJson(energyProp.ToJson()); var dialog = new UI.Dialog_FaceEnergyProperty(energyProp); dialog.RestorePosition(); var dialog_rc = dialog.ShowModal(RhinoEtoApp.MainWindow); dialog.SavePosition(); if (dialog_rc != null) { //replace brep in order to add an undo history var undo = Rhino.RhinoDoc.ActiveDoc.BeginUndoRecord("Set Honeybee face energy properties"); //Dup entire room for replacement var dupRoomHost = ent.RoomHostObjRef.Brep().DuplicateBrep(); //get face entity with subsurface component index var dupEnt = dupRoomHost.Faces[ent.ComponentIndex.Index].TryGetFaceEntity(); //update properties dupEnt.HBObject.Properties.Energy = dialog_rc; Rhino.RhinoDoc.ActiveDoc.Objects.Replace(ent.RoomHostObjRef.ObjectId, dupRoomHost); Rhino.RhinoDoc.ActiveDoc.EndUndoRecord(undo); } } }
/// <summary> /// Updates the entity. /// </summary> /// <param name="value"><see cref="Task{CloudTable}"/> instance.</param> /// <param name="entity"><see cref="FaceEntity"/> to be updated.</param> /// <returns>Returns the <see cref="FaceEntity"/> instance.</returns> public static async Task <FaceEntity> UpdateEntityAsync(this Task <CloudTable> value, FaceEntity entity) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (entity == null) { throw new ArgumentNullException(nameof(entity)); } var instance = await value.ConfigureAwait(false); var operation = TableOperation.InsertOrReplace(entity); var result = await instance.ExecuteAsync(operation).ConfigureAwait(false); return(entity); }