private void SaveFaceLandmarkData(PXCMFaceData.Face face) { FacialLandmarks flm = new FacialLandmarks(); flm.updateData(face); #if DEBUG //Console.WriteLine(flm.ToString()); #endif // dbhelper.saveEntity(flm); Console.WriteLine(flm.ToString()); }
/// <summary> /// 构造函数,将窗体传进来 /// </summary> /// <param name="form"></param> public TrackModule(MainForm form) { m_form = form; Expression = new FacialExpression(); Landmarks = new FacialLandmarks(); //dbhelper = new DBHelper(); //InteractionEvent ievent = new InteractionEvent(); //ievent.eventType = EventType.PauseEvent; //ievent.eventParams = new Dictionary<string, string>(); //ievent.eventParams.Add("key", "value"); //ievent.happenTS = new Data.CustomTime(); //ievent.happenTS.absTS = DateTime.Now; //ievent.happenTS.videoTS = 70; //dbhelper.saveEntity(ievent); }
/// <summary> /// 获取实时面部特征数据 /// </summary> /// <returns></returns> public FacialLandmarks GetFaceLandmarks() { int nFace = faceData.QueryNumberOfDetectedFaces(); if (nFace == 0) { #if DEBUG //Console.WriteLine("No face in current frame"); #endif return(null); } this.face = this.faceData.QueryFaceByIndex(0); FacialLandmarks flm = new FacialLandmarks(); flm.updateData(face); // string s = flm.ToString(); //string[] ss = s.Split(' '); // Console.WriteLine(ss.Length.ToString()); return(flm); }
private void DoStreaming_SaveData() { this.m_stopped = false; InitStreamState(); // 设置Playback模式 manager.captureManager.SetFileName(this.PlaybackFile, false); manager.captureManager.SetRealtime(false); int nOf = manager.captureManager.QueryNumberOfFrames(); switch (m_algoOption) { // 面部算法 case AlgoOption.Face: this.faceModule = manager.QueryFace(); if (faceModule == null) { MessageBox.Show("QueryFace failed"); return; } InitFaceState(); this.faceData = this.faceModule.CreateOutput(); if (faceData == null) { MessageBox.Show("CreateOutput failed"); return; } break; } if (manager.Init() < pxcmStatus.PXCM_STATUS_NO_ERROR) { #if DEBUG System.Windows.Forms.MessageBox.Show("init failed"); #endif return; } FacialLandmarks fl; FacialExpression fe; while (!m_stopped) { if (manager.AcquireFrame(false).IsError()) { break; } this.sample = manager.QuerySample(); //if (sample == null) { manager.ReleaseFrame(); continue; } if (sample.depth != null) { this.m_timestamp = (sample.depth.timeStamp); } else if (sample.color != null) { this.m_timestamp = sample.color.timeStamp; } else { continue; } // 仅当下一秒时调用检测算法 m_timestamp_sec = m_timestamp / 10000000; if (m_timestamp_sec_init != -1 && m_timestamp_sec - m_timestamp_sec_init >= nOf) { break; } Console.WriteLine("curframe:" + m_timestamp_sec); if (m_timestamp_sec_init == -1) { m_timestamp_sec_init = m_timestamp_sec; } if (m_timestamp_sec_last == -1) { m_timestamp_sec_last = m_timestamp_sec - 1; } long interval = m_timestamp_sec - m_timestamp_sec_last; if (interval > 0) { if (interval > 1) { for (int i = 1; i < interval; i++) { buffer += (m_timestamp_sec_last + i - m_timestamp_sec_init).ToString() + " "; buffer += "\n"; Console.WriteLine((m_timestamp_sec_last + i - m_timestamp_sec_init).ToString()); } } buffer += (m_timestamp_sec - m_timestamp_sec_init).ToString() + " "; // 原生算法调用处理,并缓存实时数据 faceData.Update(); fl = this.GetFaceLandmarks(); fe = this.GetExpression(); if (fl != null) { buffer += fl.ToString(); } else { buffer += FacialLandmarks.generateBlank(); } if (fe != null) { buffer += fe.ToString(); } else { buffer += FacialExpression.generateBlank(); } buffer += "\n"; m_timestamp_sec_last = m_timestamp_sec; //Console.WriteLine((m_timestamp_sec- m_timestamp_sec_init).ToString()); } //if(m_timestamp_sec>m_timestamp_sec_last) //{ // // 原生算法调用处理,并缓存实时数据 // faceData.Update(); // fl = this.GetFaceLandmarks(); // fe = this.GetExpression(); // if (fl != null) // buffer += fl.ToString(); // if (fe != null) // buffer += fe.ToString(); // buffer += "\n"; // m_timestamp_sec_last = m_timestamp_sec; // Console.WriteLine(m_timestamp_sec.ToString()); //} // 用于显示视频流功能 if (m_display) { this.DoRender(); } manager.ReleaseFrame(); } faceData.Dispose(); manager.Dispose(); Console.WriteLine("done!!!"); }
private void DoStreaming_SaveData_Do(string file) { manager.captureManager.SetRealtime(false); manager.captureManager.SetFileName(file, true); //manager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480, 30); //manager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 320, 240, 30); Console.WriteLine("handling file:\t" + file); Console.WriteLine(manager.captureManager.QueryNumberOfFrames().ToString()); FacialLandmarks fl; FacialExpression fe; while (!m_stopped) { if (manager.AcquireFrame(true).IsError()) { break; } //Console.WriteLine(sps.ToString()+"\t"+ manager.captureManager.QueryFrameIndex().ToString()); this.sample = manager.QuerySample(); //if (sample == null) { manager.ReleaseFrame(); continue; } /****************************************************** * * 1.获取当前Frame * 2.判断当前Frame是否有深度或者颜色信息 * 2.1 如果两者都有,判断时间是否为下一秒 * 2.1.1 如果是下一秒,处理当前Frame * 2.1.2 如果不是,结束本次循环 * 2.2 如果没有,则结束本次循环 * ****************************************************/ if (sample.color != null) { this.m_timestamp = sample.color.timeStamp; } else { continue; } //if (sample.depth != null) // this.m_timestamp = (sample.depth.timeStamp); //else if (sample.color != null) // this.m_timestamp = sample.color.timeStamp; //else // continue; Console.WriteLine(m_timestamp.ToString()); if (sample.depth != null || sample.color != null) { //if (m_timestamp == m_timestamp_last) //{ // break; //} m_timestamp_last = m_timestamp; } // 仅当下一秒时调用检测算法 m_timestamp_sec = m_timestamp / 10000000; Console.WriteLine("Curframe time :" + m_timestamp_sec); if (m_timestamp_sec_init == -1) { m_timestamp_sec_init = m_timestamp_sec; } if (m_timestamp_sec_last == -1) { m_timestamp_sec_last = m_timestamp_sec - 1; } long interval = m_timestamp_sec - m_timestamp_sec_last; //if(interval==0) //{ // break; //} if (interval > 0) { if (interval > 1) { for (int i = 1; i < interval; i++) { buffer += (m_timestamp_sec_last + i - m_timestamp_sec_init).ToString() + " "; buffer += "\n"; Console.WriteLine((m_timestamp_sec_last + i - m_timestamp_sec_init).ToString()); } } buffer += (m_timestamp_sec - m_timestamp_sec_init).ToString() + " "; // 原生算法调用处理,并缓存实时数据 faceData.Update(); fl = this.GetFaceLandmarks(); fe = this.GetExpression(); if (fl != null) { buffer += fl.ToString(); } else { buffer += FacialLandmarks.generateBlank(); } if (fe != null) { buffer += fe.ToString(); } else { buffer += FacialExpression.generateBlank(); } buffer += "\n"; m_timestamp_sec_last = m_timestamp_sec; //Console.WriteLine((m_timestamp_sec- m_timestamp_sec_init).ToString()); } //if(m_timestamp_sec>m_timestamp_sec_last) //{ // // 原生算法调用处理,并缓存实时数据 // faceData.Update(); // fl = this.GetFaceLandmarks(); // fe = this.GetExpression(); // if (fl != null) // buffer += fl.ToString(); // if (fe != null) // buffer += fe.ToString(); // buffer += "\n"; // m_timestamp_sec_last = m_timestamp_sec; // Console.WriteLine(m_timestamp_sec.ToString()); //} // 用于显示视频流功能 if (m_display) { this.DoRender(); } manager.ReleaseFrame(); } }
//*********************************私有函数******************************************************************* // 循环执行流的主体程序 private void DoStreaming() { this.m_stopped = false; InitStreamState(); switch (m_algoOption) { // 面部算法 case AlgoOption.Face: this.faceModule = manager.QueryFace(); if (faceModule == null) { MessageBox.Show("QueryFace failed"); return; } InitFaceState(); this.faceData = this.faceModule.CreateOutput(); if (faceData == null) { MessageBox.Show("CreateOutput failed"); return; } break; } if (manager.Init() < pxcmStatus.PXCM_STATUS_NO_ERROR) { #if DEBUG System.Windows.Forms.MessageBox.Show("init failed"); #endif return; } while (!m_stopped) { //if (m_pause) //{ // System.Threading.Thread.Sleep(10); // continue; //} if (manager.AcquireFrame(true).IsError()) { break; } this.sample = manager.QuerySample(); if (sample.depth != null) { this.m_timestamp = (sample.depth.timeStamp); } else if (sample.color != null) { this.m_timestamp = sample.color.timeStamp; } m_timestamp_sec = m_timestamp / 10000000; if (m_timestamp_sec_init == -1) { m_timestamp_sec_init = m_timestamp_sec; } if (this.m_label != null) { //updateLabel(this.m_timestamp.ToString()); System.Threading.Thread t1 = new System.Threading.Thread(updateLabel); t1.Start((m_timestamp_sec - m_timestamp_sec_init).ToString()); } //OnTimeStampChanged(this.m_timestamp.ToString()); // 原生算法调用处理,并缓存实时数据 faceData.Update(); FacialLandmarks fl = this.GetFaceLandmarks(); // 用于显示视频流功能 if (m_display) { this.DoRender(); } manager.ReleaseFrame(); } faceData.Dispose(); manager.Dispose(); }
public bool saveFacialLandmarks(FacialLandmarks facialLandmarks) { throw new NotImplementedException(); }