示例#1
0
    def grab(self, numpics=0):
        if numpics == 0:
            self.numpics = SISO.GRAB_INFINITE
        else:
            self.numpics = numpics

        err = SISO.Fg_AcquireEx(self.fg, 0, self.numpics, SISO.ACQ_STANDARD,
                                self.memHandle)

        if (err != 0):
            print('Fg_AcquireEx() failed:',
                  SISO.Fg_getLastErrorDescription(self.fg))
            self.resource_cleanup()

        self.display_timer = DisplayTimer(0.03, self.display_img)
        self.display_timer.start()
        if self.numpics != SISO.GRAB_INFINITE:
            while self.display_timer.is_running:
                time.sleep(0.1)
            #self.stop()
            if self.autosave:
                print(self.numpics)
                self.save_vid(startframe=1, stopframe=self.numpics)
                self.resource_cleanup()
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)
    s.Fg_FreeGrabber(fg)
    exit(err)

print(s.FG_BITALIGNMENT)
print(s.FG_LEFT_ALIGNED)
print(camPort)