private void AddItem_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(idText.Text.Trim())) { string id = idText.Text.Trim(); if (facedata.Count != 0) { foreach (FaceData fd in facedata) { if (fd.name == id) { MessageBox.Show("加入人脸数据失败: 重复的ID"); return; } } } if (addIDThread == null || addIDThread.ThreadState == ThreadState.Stopped) { if (userBox.SelectedIndex == 0) { if (videoSourcePlayer.IsRunning) { FeatureData feature = new FeatureData(id); addIDThread = new Thread(new ParameterizedThreadStart(GetFeatureVec)); addIDThread.Start(feature); idText.Text = ""; } else { MessageBox.Show("摄像头未运行!"); } } else if (userBox.SelectedIndex == 1) { string fileName = FileTools.GetImagePath(); if (fileName != null) { FeatureData feature = new FeatureData(id, fileName); addIDThread = new Thread(new ParameterizedThreadStart(GetFeatureVec)); addIDThread.Start(feature); idText.Text = ""; } } } else { MessageBox.Show("正在添加数据中, 请等待!"); } } else { MessageBox.Show("error: ID 为空!"); } }
private void InsertItem_Click(object sender, EventArgs e) { try { if (treeView1.SelectedNode != null) { if (treeView1.SelectedNode.GetNodeCount(true) != 0) { if (addIDThread == null || addIDThread.ThreadState == ThreadState.Stopped) { if (userBox.SelectedIndex == 0) { if (videoSourcePlayer.IsRunning) { FeatureData feature = new FeatureData(treeView1.SelectedNode.Text); addIDThread = new Thread(new ParameterizedThreadStart(GetFeatureVec)); addIDThread.Start(feature); idText.Text = ""; } else { MessageBox.Show("摄像头未运行!"); } } else if (userBox.SelectedIndex == 1) { string fileName = FileTools.GetImagePath(); if (fileName != null) { FeatureData feature = new FeatureData(treeView1.SelectedNode.Text, fileName); addIDThread = new Thread(new ParameterizedThreadStart(GetFeatureVec)); addIDThread.Start(feature); idText.Text = ""; } } } else { MessageBox.Show("正在添加数据中, 请等待!"); } } else { MessageBox.Show("error: 请选择父节点!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { string imagePath = FileTools.GetImagePath(); try { if (imagePath != null) { image = new Bitmap(BitmapHelper.ReadImageFile(imagePath)); pictureBox1.BackgroundImage = image.Clone(new Rectangle(0, 0, image.Width, image.Height), PixelFormat.Format24bppRgb); } else { pictureBox1.BackgroundImage = null; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button2_Click(object sender, EventArgs e) { label2.Text = FileTools.GetImagePath(); }