Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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))
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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
Ejemplo n.º 6
0
    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
Ejemplo n.º 7
0
 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))
Ejemplo n.º 8
0
 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
Ejemplo n.º 9
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}
Ejemplo n.º 10
0
 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)
Ejemplo n.º 11
0
 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)
Ejemplo n.º 12
0
 def getNodeList(cls):
     '''
     Get available node list.
     '''
     return (fg.FGNODEINFO(), )
Ejemplo n.º 13
0
 def releaseLibrary():
     fg.FGExitModule()
Ejemplo n.º 14
0
 def initLibrary():
     ret = fg.FGInitModule()
     if ret != fg.FCE_NOERROR:
         raise AVTCameraError(ret)