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 getNodeList(cls): ''' Get available node list. ''' maxCnt = 16 nodeList = fg.new_FGNodeInfoArray(maxCnt) ret, cnt = fg.FGGetNodeList(nodeList, maxCnt) if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) return tuple( fg.FGNodeInfoArray_getitem(nodeList, i) for i in xrange(cnt))
def __init__(self, node): ''' Constructor. node is returned by getNodeList ''' self.__node = node self.isConnected = False self.__thread = None self.deinterlace = None self.__imageCache = Queue.Queue(64) self.__stopFlag = False self.__imageMode = 0 frame = fg.FGFRAME() frame.RxTime.Low = 5 logging.debug(frame.RxTime.Low) logging.debug(fg.test(frame, 31) / 1e7) logging.debug(frame.RxTime.Low)
def setImageMode(self, mode): ret = self.__cam.SetParameter( fg.FGP_IMAGEFORMAT, fg.MakeImageFormat(fg.RES_SCALABLE, fg.CM_Y8, mode)) if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) self.__imageMode = mode
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 getNodeList(cls): """ Get available node list. """ maxCnt = 16 nodeList = fg.new_FGNodeInfoArray(maxCnt) ret, cnt = fg.FGGetNodeList(nodeList, maxCnt) if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) return tuple(fg.FGNodeInfoArray_getitem(nodeList, i) for i in xrange(cnt))
def __init__(self, node): ''' Constructor. node is returned by getNodeList ''' self.__node = node self.__cam = fg.CFGCamera() self.isConnected = False self.__thread = None self.deinterlace = None self.__imageCache = Queue.Queue(64) self.__stopFlag = False self.__imageMode = 0
def getParameter(self, para): pinfo = fg.FGPINFO() ret = self.__cam.GetParameterInfo(para, pinfo) if ret != fg.FCE_NOERROR: raise AVTCameraError(ret) if pinfo.IsValue == fg.PVAL.PVAL_OFF: val = 'OFF' elif pinfo.IsValue == fg.PVAL.PVAL_ONESHOT: val = 'ONESHOT' elif pinfo.IsValue == fg.PVAL.PVAL_AUTO: val = 'Auto' else: val = pinfo.IsValue return {'Value': val, 'Min': pinfo.MinValue, 'Max': pinfo.MaxValue}
def __init__(self, node): """ Constructor. node is returned by getNodeList """ self.__node = node self.isConnected = False self.__thread = None self.deinterlace = None self.__imageCache = Queue.Queue(64) self.__stopFlag = False self.__imageMode = 0 frame = fg.FGFRAME() frame.RxTime.Low = 5 logging.debug(frame.RxTime.Low) logging.debug(fg.test(frame, 31) / 1e7) logging.debug(frame.RxTime.Low)
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 getNodeList(cls): ''' Get available node list. ''' return (fg.FGNODEINFO(), )
def releaseLibrary(): fg.FGExitModule()
def initLibrary(): ret = fg.FGInitModule() if ret != fg.FCE_NOERROR: raise AVTCameraError(ret)