/// <summary> /// 初始化视频捕捉器 /// </summary> private void iniVideoCapturer() { canvasBitmap = new Bitmap(VideoSize.Width, VideoSize.Height); using (Graphics g = Graphics.FromImage(canvasBitmap)) g.FillRectangle(Brushes.Bisque, 0, 0, canvasBitmap.Width, canvasBitmap.Height); gfx = cLocal.CreateGraphics(); gfx.DrawImage(canvasBitmap, 0, 0, canvasBitmap.Width, canvasBitmap.Height); cam = new CamCapture(); var deviceList = cam.GetDeviceList(); //获得驱动列表 selectedDeviceMetrics = cam.SelectDevice(deviceList[0]); //获得尺寸大小 cam.SelectMetrics(selectedDeviceMetrics[0]); bool res = cam.Start(); //开始捕捉视频 if (res == false) { //IMLibrary3.Global.MsgShow("没有可用的摄像头。"); } metrics = cam.Metrics;//获得尺寸 encoder = new StreamCoders.Encoder.H264Encoder(); encoder.Framerate = 11; encoder.SetInputResolution((uint)VideoSize.Width, (uint)VideoSize.Height); encoder.IFrameFrequency = 40; encoder.Bitrate = 128000; encoder.PayloadType = 103; res = encoder.Init(); if (res == false) { //IMLibrary3.Global.MsgShow("无法初始化视频编码器。"); return; } byte[] zeroBuffer = new byte[VideoSize.Width * VideoSize.Height * 3]; byte[] initData = encoder.EncodeToArray(zeroBuffer); decoder = new StreamCoders.Decoder.H264Decoder(); decoder.SetInputResolution((uint)VideoSize.Width, (uint)VideoSize.Height); decoder.SetInputFrameRate(11); res = ((StreamCoders.Decoder.H264Decoder)decoder).Init(initData); if (res == false) { //IMLibrary3.Global.MsgShow("无法初始化视频解码器。"); return; } timer1.Interval = (int)(1000.0 / 25); timer1.Start(); }
/// <summary> /// 关闭 /// </summary> public void Close() { if (frameTransmit != null) { frameTransmit.Dispose(); frameTransmit = null; } if (VC != null) { VC.Close(); VC = null; } if (VE != null) { VE.Close(); VE = null; } if (VD != null) { VD.Close(); VD = null; } if (VR != null) { VR = null; } if (AC != null) { AC.Close(); AC = null; } if (AE != null) { AE.Close(); AE = null; } if (AR != null) { AR.Close(); AE = null; } if (cam != null) { cam.Stop(); cam.Dispose(); cam = null; timer1.Stop(); } //cLocal.Dispose(); cLocal = null; //cRemote.Dispose(); cRemote = null; //trackBarIn.Dispose(); trackBarIn = null; //trackBarOut.Dispose(); trackBarOut = null; }
/// <summary> /// Singleton constructor, not sure if I will keep it this way /// </summary> private Processing() { m_camCapture = CamCapture.getInstance(); IsolationToPreprocess = new Semaphore(1, 1); PreprocessToPCA = new Semaphore(1, 1); PCAToGestures = new Semaphore(1, 1); GesturesToDrawing = new Semaphore(1, 1); feedBackData = new Mutex(); m_handIso = new HandIsolation(); m_preProc = new Preprocessing(); m_PCA = new PCA(); m_gesture = new Gesture(); m_drawing = new Drawing(); }
public void Pressed() { UIController.Instance.Get.ActiveWindow(WindowNames.CITY_CAPTURE); CityCapture.Instance.Get.UpdateWindow(ID); CamCapture.SetPos(transform); }
/// <summary> /// 初始化视频捕捉器 /// </summary> private void iniVideoCapturer() { canvasBitmap = new Bitmap(VideoSize.Width, VideoSize.Height); using (Graphics g = Graphics.FromImage(canvasBitmap)) g.FillRectangle(Brushes.Bisque, 0, 0, canvasBitmap.Width, canvasBitmap.Height); gfx = cLocal.CreateGraphics(); gfx.DrawImage(canvasBitmap, 0, 0, canvasBitmap.Width, canvasBitmap.Height); cam = new CamCapture(); var deviceList = cam.GetDeviceList();//获得驱动列表 selectedDeviceMetrics = cam.SelectDevice(deviceList[0]);//获得尺寸大小 cam.SelectMetrics(selectedDeviceMetrics[0]); bool res = cam.Start();//开始捕捉视频 if (res == false) { //IMLibrary3.Global.MsgShow("没有可用的摄像头。"); } metrics = cam.Metrics;//获得尺寸 encoder = new StreamCoders.Encoder.H264Encoder(); encoder.Framerate = 11; encoder.SetInputResolution((uint)VideoSize.Width, (uint)VideoSize.Height); encoder.IFrameFrequency = 40; encoder.Bitrate = 128000; encoder.PayloadType = 103; res = encoder.Init(); if (res == false) { //IMLibrary3.Global.MsgShow("无法初始化视频编码器。"); return; } byte[] zeroBuffer = new byte[VideoSize.Width * VideoSize.Height * 3]; byte[] initData = encoder.EncodeToArray(zeroBuffer); decoder = new StreamCoders.Decoder.H264Decoder(); decoder.SetInputResolution((uint)VideoSize.Width, (uint)VideoSize.Height); decoder.SetInputFrameRate(11); res = ((StreamCoders.Decoder.H264Decoder)decoder).Init(initData); if (res == false) { //IMLibrary3.Global.MsgShow("无法初始化视频解码器。"); return; } timer1.Interval = (int)(1000.0 / 25); timer1.Start(); }