public void StartClick(string realFileName) { RealFileName = realFileName; FaceTracking.m_frame = 0; //创建存储视频和照片的文件夹 videoPath = Environment.CurrentDirectory + "\\data\\" + RealFileName; try { Directory.CreateDirectory(videoPath); } catch (Exception ex) { WriteLog.WriteError(ex.ToString()); throw; } //在启动摄像头的时候打开文件 fs_less = new FileStream(string.Format("{0}{1}", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "\\study_" + RealFileName + "Less.txt"), FileMode.Append); sw_less = new StreamWriter(fs_less); sw_less.BaseStream.Seek(0, SeekOrigin.End); //新增保存特征点功能 fileFeature = new FileStream(string.Format("{0}{1}", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "\\study_" + RealFileName + ".txt"), FileMode.Append); sw_feature = new StreamWriter(fileFeature); sw_feature.BaseStream.Seek(0, SeekOrigin.End); SaveUserSettings(); Stopped = false; //此处开始做人脸识别跟踪 expressionNumber++; isStart = true; var thread = new Thread(DoTracking); thread.Start(); }
//save image public void SavePicture(int frameCount) { StringBuilder sb = new StringBuilder("\\"); sb.Append(frameCount.ToString()); sb.Append(".jpg"); String fileName = videoPath + sb.ToString(); try { m_bitmap.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg); } catch (Exception e) { WriteLog.WriteError(e.ToString()); throw; } }
static void Main() { //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); //PXCMSession session = PXCMSession.CreateInstance(); //if (session != null) //{ // Application.Run(new MainForm(session,"feature")); // session.Dispose(); //} ExampleServer server = new ExampleServer(ipAddress, portAddress); server.Logger = new ConsoleLogger(); try { server.Start(); } catch (Exception e) { WriteLog.WriteError(e.ToString()); } }
private void CreateResolutionMap() { ColorResolutions = new Dictionary <string, IEnumerable <Tuple <PXCMImage.ImageInfo, PXCMRangeF32> > >(); var desc = new PXCMSession.ImplDesc { group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR, subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE }; for (int i = 0; ; i++) { PXCMSession.ImplDesc desc1; if (Session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR) { break; } PXCMCapture capture; if (Session.CreateImpl(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR) { continue; } for (int j = 0; ; j++) { PXCMCapture.DeviceInfo info; if (capture.QueryDeviceInfo(j, out info) < pxcmStatus.PXCM_STATUS_NO_ERROR) { break; } PXCMCapture.Device device = capture.CreateDevice(j); if (device == null) { throw new Exception("PXCMCapture.Device null"); } var deviceResolutions = new List <Tuple <PXCMImage.ImageInfo, PXCMRangeF32> >(); for (int k = 0; k < device.QueryStreamProfileSetNum(PXCMCapture.StreamType.STREAM_TYPE_COLOR); k++) { PXCMCapture.Device.StreamProfileSet profileSet; device.QueryStreamProfileSet(PXCMCapture.StreamType.STREAM_TYPE_COLOR, k, out profileSet); PXCMCapture.DeviceInfo dinfo; device.QueryDeviceInfo(out dinfo); var currentRes = new Tuple <PXCMImage.ImageInfo, PXCMRangeF32>(profileSet.color.imageInfo, profileSet.color.frameRate); if (IsProfileSupported(profileSet, dinfo)) { continue; } if (SupportedColorResolutions.Contains(new Tuple <int, int>(currentRes.Item1.width, currentRes.Item1.height))) { deviceResolutions.Add(currentRes); } } try { ColorResolutions.Add(info.name, deviceResolutions); } catch (Exception e) { WriteLog.WriteError(e.ToString()); throw; } device.Dispose(); } capture.Dispose(); } }