Esempio n. 1
0
        private void button1_ClickAsync(object sender, EventArgs e)
        {
            ConvertSetting form = new ConvertSetting();

            form.FormClosing += new FormClosingEventHandler((s, e1) => {
                if (form.confirmed)
                {
                    VideoHandler.CatchImg(vFileNameTextBox.Text, ImgSavePath);
                }
            });
            form.Show();
        }
Esempio n. 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            AnalyseSetting form = new AnalyseSetting();

            form.FormClosing += new FormClosingEventHandler(async(s, e1) =>
            {
                if (form.confirmed == true)
                {
                    if (new DirectoryInfo(ImgSavePath).GetFiles().Length == 0)
                    {
                        MessageBox.Show("未转换");
                        return;
                    }
                    File.Delete("temporary.dat");
                    VideoHandler.ReduceImg(ImgSavePath);
                    while (File.Exists("temporary.dat") == false)
                    {
                        Thread.Sleep(1000);
                    }
                    string data = File.ReadAllText("temporary.dat");
                    File.Delete("temporary.dat");
                    List <string> list = TextHandler.BreakIntoCodes(data);
                    LoadList_Box1(list);
                    bool prev_exists     = false;
                    List <Data> datalist = new List <Data>();
                    if (DetectFace)
                    {
                        foreach (string code in list)
                        {
                            string filename = code + ".jpg";
                            string path     = ImgSavePath + "/" + filename;
                            string json     = await APIRequest.MakeRequest(path);
                            Console.WriteLine(json);
                            Data result = TextHandler.ParseJson(json, Convert.ToInt32(code));
                            if (result.Age != "" && prev_exists == false)
                            {
                                datalist.Add(result);
                                prev_exists = true;
                            }
                            else if (result.Age == "")
                            {
                                prev_exists = false;
                            }
                        }
                    }
                    LoadList_Box2(TextHandler.Flatten(datalist));
                    if (SaveFace)
                    {
                        foreach (Data d in datalist)
                        {
                            string frompath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + Form1.ImgSavePath + "\\" + d.FrameId.ToString().PadLeft(6, '0') + ".jpg";
                            string topath   = SaveFacePath + "\\" + d.Gender + "age" + d.Age + "f" + d.FrameId + ".jpg";
                            Console.WriteLine("from:" + frompath);
                            Console.WriteLine("to:" + topath);
                            File.Copy(frompath, topath, true);
                        }
                    }
                    MessageBox.Show("分析完成");
                }
            });
            form.Show();
        }