The function interface class provides access to most of the devices executable functions, while most of the settings (e.g. the exposure time or the trigger mode) are implemented as properties (see e.g. mvIMPACT.acquire.Property for details).
This is how a continuous acquisition from a user selected device can be achieved:
import os, platform, sys
from mvIMPACT import acquire
devMgr = acquire.DeviceManager()
pDev = exampleHelper.getDeviceFromUserInput(devMgr)
if pDev == None:
exampleHelper.requestENTERFromUser()
sys.exit(-1)
pDev.open()
print("Please enter the number of buffers to capture followed by [ENTER]: ", end='')
framesToCapture = exampleHelper.getNumberFromUser()
if framesToCapture < 1:
print("Invalid input! Please capture at least one image")
sys.exit(-1)
isDisplayModuleAvailable = platform.system() == "Windows"
if isDisplayModuleAvailable:
display = acquire.ImageDisplayWindow("A window created from Python")
else:
print("The display library of this SDK is not available on this('" + platform.system() + "') system. Consider using the PIL(Python Image Library) and numpy(Numerical Python) packages instead. Have a look at the source code of this application to get an idea how.")
fi = acquire.FunctionInterface(pDev)
statistics = acquire.Statistics(pDev)
while fi.imageRequestSingle() == acquire.DMR_NO_ERROR:
print("Buffer queued")
pPreviousRequest = None
exampleHelper.manuallyStartAcquisitionIfNeeded(pDev, fi)
for i in range(framesToCapture):
requestNr = fi.imageRequestWaitFor(10000)
if fi.isRequestNrValid(requestNr):
pRequest = fi.getRequest(requestNr)
if pRequest.isOK:
if i%100 == 0:
print("Info from " + pDev.serial.read() +
": " + statistics.framesPerSecond.name() + ": " + statistics.framesPerSecond.readS() +
", " + statistics.errorCount.name() + ": " + statistics.errorCount.readS() +
", " + statistics.captureTime_s.name() + ": " + statistics.captureTime_s.readS())
if isDisplayModuleAvailable:
display.GetImageDisplay().SetImage(pRequest)
display.GetImageDisplay().Update()
if pPreviousRequest != None:
pPreviousRequest.unlock()
pPreviousRequest = pRequest
fi.imageRequestSingle()
else:
print("imageRequestWaitFor failed (" + str(requestNr) + ", " + acquire.ImpactAcquireException.getErrorCodeAsString(requestNr) + ")")
exampleHelper.manuallyStopAcquisitionIfNeeded(pDev, fi)
exampleHelper.requestENTERFromUser()
Definition Common/__init__.py:1
This sample contains everything the user needs to do to continuously capture images including all initialization work and error handling for every source of error one can think of.