Ejemplo n.º 1
0
    def _prepareImageBuffer(self, numImages=1):
        """
        Prepares a bigger buffer for e.g. more than 1 triggered image.

        Notes: This function uses a sleep function to guarantee allocated memory.

        Parameters
        ----------
        numImages : int
            Number of expected images.

        Returns
        -------
            buffer: memory_handle
                Memory handle which adresses the allocated buffer memory
        """
        # Calculate buffer size
        # TODO: bytePerSample may have to be changed when using different pixel formats
        samplePerPixel = 1
        bytePerSample = 1
        nbBuffers = numImages
        totalBufferSize = self._width * self._height * samplePerPixel * \
                          bytePerSample * nbBuffers
        buffer = s.Fg_AllocMemEx(self.device, totalBufferSize, nbBuffers)
        # Give time to allocate buffer -
        # tests without sleep/too short sleep failed
        time.sleep(.5)

        return buffer
Ejemplo n.º 2
0
 def initialise(self):
     totalBufferSize = self.camset.cam_dict['frameformat'][2][
         2] * self.camset.cam_dict['frameformat'][2][
             3] * self.camset.cam_dict['numpicsbuffer'][2]
     self.memHandle = SISO.Fg_AllocMemEx(
         self.fg, totalBufferSize, self.camset.cam_dict['numpicsbuffer'][2])
     self.display = SISO.CreateDisplay(
         8, self.camset.cam_dict['frameformat'][2][2],
         self.camset.cam_dict['frameformat'][2][3])
     SISO.SetBufferWidth(self.display,
                         self.camset.cam_dict['frameformat'][2][2],
                         self.camset.cam_dict['frameformat'][2][3])
    fg = s.Fg_InitEx(applet, boardId, 1)
else:
    fg = s.Fg_InitEx(applet, boardId, 0)

# error handling
err = s.Fg_getLastErrorNumber(fg)
mes = s.Fg_getErrorDescription(err)

if err < 0:
    print("Error", err, ":", mes)
    sys.exit()
else:
    print("ok")

# allocating memory
memHandle = s.Fg_AllocMemEx(fg, totalBufferSize, nbBuffers)

# Set Applet Parameters
err = s.Fg_setParameterWithInt(fg, s.FG_WIDTH, width, camPort)
if (err < 0):
    print("Fg_setParameter(FG_WIDTH) failed: ",
          s.Fg_getLastErrorDescription(fg))
    s.Fg_FreeMemEx(fg, memHandle)
    s.Fg_FreeGrabber(fg)
    exit(err)

err = s.Fg_setParameterWithInt(fg, s.FG_HEIGHT, height, camPort)
if (err < 0):
    print("Fg_setParameter(FG_HEIGHT) failed: ",
          s.Fg_getLastErrorDescription(fg))
    s.Fg_FreeMemEx(fg, memHandle)