def snapshot(self, timeout=1): self.__imageCache = Queue.Queue(64) self.burstCount = 2 self.openCapture() ret = self.__cam.StartDevice() if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) frame = fg.FGFRAME() for i in xrange(2): ret = self.__cam.GetFrame(frame) if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) if i != 1: ret = self.__cam.PutFrame(frame) if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) continue try: rc = self.roi w = rc[2] h = rc[3] flagInvalid = frame.Flags & fg.FGF_INVALID flagLast = frame.Flags & fg.FGF_LAST flagDMAHalted = frame.Flags & fg.FGF_DMAHALTED flagForcePost = frame.Flags & fg.FGF_FORCEPOST tsl = frame.RxTime.Low tsh = frame.RxTime.High if self.deinterlace is None: # No deinterlace rawData = fg.cdata(frame.pData, frame.Length) else: rawData = fg.Deinterlace(frame, self.deinterlace, w, h, w, w * h) snapshotData = { 'RawData': rawData, 'ROI': rc, 'FrameId': frame.Id, 'Invalid': bool(flagInvalid), 'Last': bool(flagLast), 'DMAHalted': bool(flagDMAHalted), 'ForcePost': bool(flagForcePost), 'TimeStamp': tsl, 'BufferLength': frame.Length, 'Depth': 8 } except Queue.Full: logging.debug('Queue full') pass finally: ret = self.__cam.PutFrame(frame) if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) self.__cam.StopDevice() self.__cam.CloseCapture() return snapshotData
def snapshot(self, timeout=1): self.__imageCache = Queue.Queue(64) self.burstCount = 2 self.openCapture() ret = self.__cam.StartDevice() if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) frame = fg.FGFRAME() for i in xrange(2): ret = self.__cam.GetFrame(frame) if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) if i != 1: ret = self.__cam.PutFrame(frame) if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) continue try: rc = self.roi w = rc[2] h = rc[3] flagInvalid = frame.Flags & fg.FGF_INVALID flagLast = frame.Flags & fg.FGF_LAST flagDMAHalted = frame.Flags & fg.FGF_DMAHALTED flagForcePost = frame.Flags & fg.FGF_FORCEPOST tsl = frame.RxTime.Low tsh = frame.RxTime.High if self.deinterlace is None: # No deinterlace rawData = fg.cdata(frame.pData, frame.Length) else: rawData = fg.Deinterlace(frame, self.deinterlace, w, h, w, w * h) snapshotData = { "RawData": rawData, "ROI": rc, "FrameId": frame.Id, "Invalid": bool(flagInvalid), "Last": bool(flagLast), "DMAHalted": bool(flagDMAHalted), "ForcePost": bool(flagForcePost), "TimeStamp": tsl, "BufferLength": frame.Length, "Depth": 8, } except Queue.Full: logging.debug("Queue full") pass finally: ret = self.__cam.PutFrame(frame) if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) self.__cam.StopDevice() self.__cam.CloseCapture() return snapshotData
def frameMonitor(): for cnt in xrange(frameCnt): if self.__stopFlag: break frame = fg.FGFRAME() timeout = 1000 ret = self.__cam.GetFrame(frame, timeout) if ret == fg.FCE_NOERROR: try: w = rc[2] h = rc[3] flagInvalid = frame.Flags & fg.FGF_INVALID flagLast = frame.Flags & fg.FGF_LAST flagDMAHalted = frame.Flags & fg.FGF_DMAHALTED flagForcePost = frame.Flags & fg.FGF_FORCEPOST tsh = frame.RxTime.High tsl = frame.RxTime.Low if self.deinterlace is None: # No deinterlace rawData = fg.cdata(frame.pData, frame.Length) else: rawData = fg.Deinterlace(frame, self.deinterlace, w, h, w, w * h) self.__imageCache.put_nowait({ 'RawData': rawData, 'ROI': rc, 'FrameId': frame.Id, 'Invalid': bool(flagInvalid), 'Last': bool(flagLast), 'DMAHalted': bool(flagDMAHalted), 'ForcePost': bool(flagForcePost), 'TimeStamp': tsh * 2**32 + tsl, 'BufferLength': frame.Length, 'Depth': 8 }) except Queue.Full: # logging.debug('Queue full') pass finally: ret = self.__cam.PutFrame(frame) if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) else: raise AVTCameraError(ret)
def frameMonitor(): for cnt in xrange(frameCnt): if self.__stopFlag: break frame = fg.FGFRAME() timeout = 1000 ret = self.__cam.GetFrame(frame, timeout) if ret == fg.FCE_NOERROR: try: w = rc[2] h = rc[3] flagInvalid = frame.Flags & fg.FGF_INVALID flagLast = frame.Flags & fg.FGF_LAST flagDMAHalted = frame.Flags & fg.FGF_DMAHALTED flagForcePost = frame.Flags & fg.FGF_FORCEPOST tsh = frame.RxTime.High tsl = frame.RxTime.Low if self.deinterlace is None: # No deinterlace rawData = fg.cdata(frame.pData, frame.Length) else: rawData = fg.Deinterlace(frame, self.deinterlace, w, h, w, w * h) self.__imageCache.put_nowait( { "RawData": rawData, "ROI": rc, "FrameId": frame.Id, "Invalid": bool(flagInvalid), "Last": bool(flagLast), "DMAHalted": bool(flagDMAHalted), "ForcePost": bool(flagForcePost), "TimeStamp": tsh * 2 ** 32 + tsl, "BufferLength": frame.Length, "Depth": 8, } ) except Queue.Full: # logging.debug('Queue full') pass finally: ret = self.__cam.PutFrame(frame) if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) else: raise AVTCameraError(ret)