Пример #1
0
 public bool registerFrameCB(Camera.getFrameCB cb)
 {
     if (cb == null)
     {
         return(false);
     }
     Camera.s_sendFrame = new Camera.getFrameCB(cb.Invoke);
     return(true);
 }
 public void camStart(int unit, int w, int h, int f)
 {
     if (this.camera != null || this.keyEnableCam != 1 || !this.cameraStoped)
     {
         return;
     }
     if (w > 0)
     {
         this.width = w;
     }
     if (h > 0)
     {
         this.height = h;
     }
     if (f > 0)
     {
         this.framerate = f;
     }
     Logger.Info("Starting Camera {0}. Frame width: {1}, height: {2}, framerate: {3}", (object)unit, (object)this.width, (object)this.height, (object)this.framerate);
     this.cameraStoped = false;
     this.cb           = new Camera.getFrameCB(this.getFrame);
     for (int index = 0; index < 2; ++index)
     {
         if (this.camera == null)
         {
             try
             {
                 this.m_color = (SupportedColorFormat)index;
                 this.camera  = new Camera(unit, this.width, this.height, this.framerate, this.jpegQuality, this.m_color);
             }
             catch (ColorFormatNotSupported ex)
             {
                 Logger.Info("Trying with other color." + ex.ToString());
             }
             catch (Exception ex)
             {
                 Logger.Error("Exception in to initialize the camera. Err : ", (object)ex.ToString());
             }
         }
         else
         {
             break;
         }
     }
     if (this.camera == null)
     {
         Logger.Error("Cannot start the host camera.");
     }
     else
     {
         this.camera.registerFrameCB(this.cb);
         this.camera.StartCamera();
     }
 }
Пример #3
0
 public void StopCamera()
 {
     if (this.previewThread != null)
     {
         this.m_bStop = true;
         this.previewThread.Join();
         if (this.VidCapture != null)
         {
             this.VidCapture.Dispose();
             this.VidCapture = (CaptureGraph)null;
         }
         if (Camera.s_sendFrame != null)
         {
             Camera.s_sendFrame = (Camera.getFrameCB)null;
         }
     }
     this.previewThread = (Thread)null;
 }