I connected to Matrix Vision BVS0036 industrial camera with Python using mvImpact library. I can use the camera now, but I don't know how to change the exposure time or other settings of the camera. Or rather, I couldn't. The code you see is the thread class of a program I wrote using PyQt5 to view the video in a GUI. Can you help me with this?
class VideoThread(QThread, QMainWindow):
_signal_change_pixmap_signal = pyqtSignal(np.ndarray)
def __init__(self):
super().__init__()
self._run_flag = True
# The starting point for the thread. After calling start(), the newly created thread calls this function.
# The default implementation simply calls exec(). You can reimplement this function to facilitate
# advanced thread management. Returning from this method will end the execution of the thread.
def run(self):
try:
devMgr = acquire.DeviceManager()
pDev = devMgr.getDevice(0) # exampleHelper.getDeviceFromUserInput()
pDev.open()
isDisplayModuleAvailable = platform.system() == "Windows"
fi = acquire.FunctionInterface(pDev)
fi.createSetting("ExposureTime")
exp = acquire.FullSettingsBase(pDev, "ExposureTime")
while fi.imageRequestSingle() == acquire.DMR_NO_ERROR:
print("Buffer queued - Kamera Başlatılıyor...")
pPreviousRequest = None
while True:
requestNr = fi.imageRequestWaitFor(10000)
if fi.isRequestNrValid(requestNr):
pRequest = fi.getRequest(requestNr)
if pRequest.isOK:
cbuf = (ctypes.c_char * pRequest.imageSize.read()).from_address(int(pRequest.imageData.read()))
channelType = np.uint16 if pRequest.imageChannelBitDepth.read() > 8 else np.uint8
self.cv_img = np.frombuffer(cbuf, dtype= channelType)
self.cv_img.shape = (pRequest.imageHeight.read(), pRequest.imageWidth.read(), pRequest.imageChannelCount.read())
self._signal_change_pixmap_signal.emit(self.cv_img)
global snapshot
snapshot = self.cv_img
if pPreviousRequest != None:
pPreviousRequest.unlock()
pPreviousRequest = pRequest
fi.imageRequestSingle()
else:
print("imageRequestWaitFor failed (" + str(requestNr) + ", " + acquire.ImpactAcquireException.getErrorCodeAsString(requestNr) + ")")
except:
pass
#list = run()
def stop(self):
self._run_flag = False
self.wait()