Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将Kairos配置为仅每5分钟运行一次_C#_Loops_While Loop - Fatal编程技术网

C# 将Kairos配置为仅每5分钟运行一次

C# 将Kairos配置为仅每5分钟运行一次,c#,loops,while-loop,C#,Loops,While Loop,我目前正在使用Kairos分析视频 我尝试过使用计时器(之前是而(true)),但它的配置方式是cmd提示符每2秒显示一行(Kairos仍然每秒分析视频)。我想让Kairos每5分钟分析一次视频。我想配置Kairos,而不是cmd提示符 这是我的代码,我感谢所有能得到的帮助 string[] files1 = Directory.GetFiles("C:/Users/sit/Videos/9/"); foreach (string file1 i

我目前正在使用Kairos分析视频

我尝试过使用计时器(之前是而(true)),但它的配置方式是cmd提示符每2秒显示一行(Kairos仍然每秒分析视频)。我想让Kairos每5分钟分析一次视频。我想配置Kairos,而不是cmd提示符

这是我的代码,我感谢所有能得到的帮助

             string[] files1 = Directory.GetFiles("C:/Users/sit/Videos/9/");
            foreach (string file1 in files1) {
                 var timer = new System.Timers.Timer()
                 timer.Interval = 2000;
                 timer.Elapsed += (_s, _e) =>{

                HumanAnalysisService has = null;

                try {

                    has = new HumanAnalysisService("license.xml", "", 20, 4);


                } catch (ApplicationException lie) {
                    Console.WriteLine(lie.Message);
                    return;
                }

                // has = new HumanAnalysisService("license.xml", "", 20, 4);

                /* attach to camera device */
                // has.initUsingCameraSource(0);
                has.initUsingImageSource(file1);

                /* *loop thru the capture feed */

                while(true) {
                    /* pull pull out the next frame */
                    has.pullFrame();

                    /* does the device have more frames */
                    if (has.isFrameEmpty())
                        break;

                    /* process the pulled frame */
                    has.processFrame();

                    /* get the people that are in the current frame*/
                    People people = has.getPeople();

                    System.Console.Write("Media Height: " + has.getMediaSourceHeight());
                    System.Console.Write("Media Width: " + has.getMediaSourceWidth());
                    System.Console.Write("Media Type: " + has.getMediaType());
                    System.Console.Write("Mime Type: " + has.getMediaContentType() + "\n\n");

                    /* print out the info from every person in te frame*/
                    // foreach ( Person person in people )
                    for (int i = 0; i < people.size(); i++) {
                        System.Console.Write("Person id" + people.get(i).id + " , face x coordinate: " + people.get(i).face.x + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , face y coordinate: " + people.get(i).face.x + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , face width coordinate: " + people.get(i).face.width + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , face height coordinate: " + people.get(i).face.height + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , Emotion - Joy: " + people.get(i).impression.emotion_response.joy_score + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , Emotion - Surprise: " + people.get(i).impression.emotion_response.surprise_score + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , Emotion - Anger: " + people.get(i).impression.emotion_response.anger_score + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , Emotion - Fear: " + people.get(i).impression.emotion_response.fear_score + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , Emotion - Sadness: " + people.get(i).impression.emotion_response.sadness_score + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , Emotion - Disgust: " + people.get(i).impression.emotion_response.disgust_score + "\n");

                        using (SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\sit\Desktop\(NEW) LEA WINFORMS\28June_LessonEffectivenessAnalysis\LessonEffectivenessAnalysis\LessonEffectivenessAnalysis\LessonEffectivenessAnalysis\LessonAnalysis.mdf;Integrated Security=True")) {
                            conn.Open();

                            using (SqlCommand cmd1 = new SqlCommand("INSERT INTO TBL_VIDEO(JOY_SCORE,SURPRISE_SCORE,ANGER_SCORE,FEAR_SCORE,SADNESS_SCORE,DISGUST_SCORE) VALUES('" + people.get(i).impression.emotion_response.joy_score.ToString() + "','" + people.get(i).impression.emotion_response.surprise_score.ToString() + "','" + people.get(i).impression.emotion_response.anger_score.ToString() + "','" + people.get(i).impression.emotion_response.fear_score.ToString() + "','" + people.get(i).impression.emotion_response.sadness_score.ToString() + "','" + people.get(i).impression.emotion_response.disgust_score.ToString() + "')", conn)) {

                                using (SqlDataReader dr = cmd1.ExecuteReader()) {

                                }
                            }
                        }
                    }

                };timer.Enabled = true;
            }
string[]files1=Directory.GetFiles(“C:/Users/sit/Videos/9/”;
foreach(files1中的字符串file1){
var timer=new System.Timers.timer()
时间间隔=2000;
计时器已用+=(\u s,\u e)=>{
HumanAnalysisService has=null;
试一试{
has=新的HumanAnalysisService(“license.xml”,20,4);
}捕获(应用程序异常){
控制台写入线(谎言消息);
返回;
}
//has=新的HumanAnalysisService(“license.xml”,20,4);
/*连接到相机设备*/
//has.initUsingCameraSource(0);
has.initUsingImageSource(文件1);
/**循环通过捕获馈送*/
while(true){
/*拉出下一帧*/
has.pullFrame();
/*设备是否有更多帧*/
if(has.isFrameEmpty())
打破
/*处理被拉动的框架*/
has.processFrame();
/*获取当前帧中的人员*/
People=has.getPeople();
System.Console.Write(“媒体高度:+has.getMediaSourceHeight());
System.Console.Write(“媒体宽度:+has.getMediaSourceWidth());
System.Console.Write(“媒体类型:+has.getMediaType());
System.Console.Write(“Mime类型:+has.getMediaContentType()+”\n\n”);
/*打印出te框架中每个人的信息*/
//foreach(人对人)
for(inti=0;i
只要在
计时器中调用代码时删除
循环就可以完成这项工作。如果已使用
方法,请将计时器的间隔更改为5000,并持续5秒

            timer.Interval = 5000;
            timer.Elapsed += (_s, _e) =>{

                HumanAnalysisService has = null;

                try {

                    has = new HumanAnalysisService("license.xml", "", 20, 4);


                } catch (ApplicationException lie) {
                    Console.WriteLine(lie.Message);
                    return;
                }

                // has = new HumanAnalysisService("license.xml", "", 20, 4);

                /* attach to camera device */
                // has.initUsingCameraSource(0);
                has.initUsingImageSource(file1);

                /* *loop thru the capture feed */


                    /* pull pull out the next frame */
                    has.pullFrame();

                    /* does the device have more frames */
                    if (has.isFrameEmpty())
                        break;

                    /* process the pulled frame */
                    has.processFrame();

                    /* get the people that are in the current frame*/
                    People people = has.getPeople();

                    System.Console.Write("Media Height: " + has.getMediaSourceHeight());
                    System.Console.Write("Media Width: " + has.getMediaSourceWidth());
                    System.Console.Write("Media Type: " + has.getMediaType());
                    System.Console.Write("Mime Type: " + has.getMediaContentType() + "\n\n");

                    /* print out the info from every person in te frame*/
                    // foreach ( Person person in people )
                    for (int i = 0; i < people.size(); i++) {
                        System.Console.Write("Person id" + people.get(i).id + " , face x coordinate: " + people.get(i).face.x + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , face y coordinate: " + people.get(i).face.x + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , face width coordinate: " + people.get(i).face.width + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , face height coordinate: " + people.get(i).face.height + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , Emotion - Joy: " + people.get(i).impression.emotion_response.joy_score + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , Emotion - Surprise: " + people.get(i).impression.emotion_response.surprise_score + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , Emotion - Anger: " + people.get(i).impression.emotion_response.anger_score + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , Emotion - Fear: " + people.get(i).impression.emotion_response.fear_score + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , Emotion - Sadness: " + people.get(i).impression.emotion_response.sadness_score + "\n");
                        System.Console.Write("Person id" + people.get(i).id + " , Emotion - Disgust: " + people.get(i).impression.emotion_response.disgust_score + "\n");

                        using (SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\sit\Desktop\(NEW) LEA WINFORMS\28June_LessonEffectivenessAnalysis\LessonEffectivenessAnalysis\LessonEffectivenessAnalysis\LessonEffectivenessAnalysis\LessonAnalysis.mdf;Integrated Security=True")) {
                            conn.Open();

                            using (SqlCommand cmd1 = new SqlCommand("INSERT INTO TBL_VIDEO(JOY_SCORE,SURPRISE_SCORE,ANGER_SCORE,FEAR_SCORE,SADNESS_SCORE,DISGUST_SCORE) VALUES('" + people.get(i).impression.emotion_response.joy_score.ToString() + "','" + people.get(i).impression.emotion_response.surprise_score.ToString() + "','" + people.get(i).impression.emotion_response.anger_score.ToString() + "','" + people.get(i).impression.emotion_response.fear_score.ToString() + "','" + people.get(i).impression.emotion_response.sadness_score.ToString() + "','" + people.get(i).impression.emotion_response.disgust_score.ToString() + "')", conn)) {

                                using (SqlDataReader dr = cmd1.ExecuteReader()) {

                                }
                            }
                        }

                };timer.Enabled = true;
timer.Interval=5000;
计时器已用+=(\u s,\u e)=>{
HumanAnalysisService has=null;
试一试{
has=新的HumanAnalysisService(“license.xml”,20,4);
}捕获(应用程序异常){
控制台写入线(谎言消息);
返回;
}
//has=新的HumanAnalysisService(“license.xml”,20,4);
/*连接到相机设备*/
//has.initUsingCameraSource(0);
has.initUsingImageSource(文件1);