Skip to content
Snippets Groups Projects
Commit db587b29 authored by mhoeschle's avatar mhoeschle
Browse files

change some variable names to make them more readable

parent 99571528
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ import os ...@@ -12,7 +12,7 @@ import os
# #
# Max Number of cameras that should be used # Max Number of cameras that should be used
MAXCAMERASTOUSE = 2 MAX_CAMERAS_TO_USE = 2
# Get the transport layer factory. # Get the transport layer factory.
...@@ -24,7 +24,7 @@ if len(devices) == 0: ...@@ -24,7 +24,7 @@ if len(devices) == 0:
raise pylon.RuntimeException("No camera present.") raise pylon.RuntimeException("No camera present.")
# Create an array of instant cameras for the found devices and avoid exceeding a maximum number of devices. -> Output-> Pylon::CInstantCameraArray # Create an array of instant cameras for the found devices and avoid exceeding a maximum number of devices. -> Output-> Pylon::CInstantCameraArray
CAMERAS_ARRAY = pylon.InstantCameraArray(min(len(devices), MAXCAMERASTOUSE)) CAMERAS_ARRAY = pylon.InstantCameraArray(min(len(devices), MAX_CAMERAS_TO_USE))
print(f'cameras: {CAMERAS_ARRAY}') print(f'cameras: {CAMERAS_ARRAY}')
l = CAMERAS_ARRAY.GetSize() l = CAMERAS_ARRAY.GetSize()
...@@ -33,7 +33,9 @@ l = CAMERAS_ARRAY.GetSize() ...@@ -33,7 +33,9 @@ l = CAMERAS_ARRAY.GetSize()
# Funktions: # Funktions:
# #
#
# List all connected / founded cameras: # List all connected / founded cameras:
#
def listcams(): def listcams():
...@@ -51,20 +53,20 @@ def listcams(): ...@@ -51,20 +53,20 @@ def listcams():
# list all the connected cameras at the system: # list all the connected cameras at the system:
# #
# Print the model name of the camera. # Print the serial number of the model of the camera. - by replacing .GetSerialNumber() with .GetModelName() outputs the Modelname
cam_ids = camera_instantz.GetDeviceInfo().GetSerialNumber() cam_ids = camera_instantz.GetDeviceInfo().GetSerialNumber()
print("Using device ", cam_ids) print("Using device ", cam_ids)
return cam_ids, camera_instantz return cam_ids
# Open cameras: # Open cameras:
def opencams(): def opencams():
''' '''
open camera to read or write values open camera to access camera and read or write values
''' '''
CAMINSTANT.Open() CAM_INSTANT.Open()
print(f'Cam open: {CAM_ID}', '\n') print(f'Cam open: {CAM_ID}', '\n')
# Close cameras: # Close cameras:
...@@ -74,11 +76,11 @@ def closecams(): ...@@ -74,11 +76,11 @@ def closecams():
''' '''
close camera after read or write values close camera after read or write values
''' '''
CAMINSTANT.Close() CAM_INSTANT.Close()
print(f'Cam close: {CAM_ID}', '\n') print(f'Cam close: {CAM_ID}', '\n')
# read camera parameters to get an current overiew
# read camera parameters to get an current overiew
def readcams(): def readcams():
""" """
...@@ -88,23 +90,23 @@ def readcams(): ...@@ -88,23 +90,23 @@ def readcams():
# Read Gain value in Camera: # Read Gain value in Camera:
print("Gain in (dB):") print("Gain in (dB):")
# Gain value # Gain value
print(CAMINSTANT.Gain.GetValue(), "\n") print(CAM_INSTANT.Gain.GetValue(), "\n")
# Read Trigger Delay value in Camera: # Read Trigger Delay value in Camera:
print("Delay in (microseconds):") print("Delay in (microseconds):")
# TriggerDelay value # TriggerDelay value
print(CAMINSTANT.TriggerDelay.GetValue(), "\n") print(CAM_INSTANT.TriggerDelay.GetValue(), "\n")
# Exposure parameter # Exposure parameter
oldexposure = CAMINSTANT.ExposureTime.GetValue() oldexposure = CAM_INSTANT.ExposureTime.GetValue()
print(f'exposure: {oldexposure}', "\n") print(f'exposure: {oldexposure}', "\n")
oldfps = CAMINSTANT.AcquisitionFrameRate.GetValue() oldfps = CAM_INSTANT.AcquisitionFrameRate.GetValue()
print(f'fps: {oldfps}') print(f'fps: {oldfps}')
# Gamma value: # Gamma value:
print("Camera gamma value: ") print("Camera gamma value: ")
print(CAMINSTANT.Gamma.GetValue(), "\n") print(CAM_INSTANT.Gamma.GetValue(), "\n")
closecams() closecams()
...@@ -123,14 +125,14 @@ def gaincam(): ...@@ -123,14 +125,14 @@ def gaincam():
# Read Gain value in Camera: # Read Gain value in Camera:
print(" Gain in (dB):") print(" Gain in (dB):")
# Gain value # Gain value
print(CAMINSTANT.Gain.GetValue(), "\n") print(CAM_INSTANT.Gain.GetValue(), "\n")
# Input new gain value # Input new gain value
gainvalue = float(input("Please enter the new gain in (dB): ")) gainvalue = float(input("Please enter the new gain in (dB): "))
CAMINSTANT.Gain.SetValue(gainvalue) CAM_INSTANT.Gain.SetValue(gainvalue)
# Read Gain value in Camera: # Read Gain value in Camera:
print("New Gain in (dB):") print("New Gain in (dB):")
# Gain value # Gain value
print(CAMINSTANT.Gain.GetValue(), "\n") print(CAM_INSTANT.Gain.GetValue(), "\n")
# gaincam() # gaincam()
...@@ -144,17 +146,17 @@ def exposurecam(): ...@@ -144,17 +146,17 @@ def exposurecam():
changes the exposure time in microseconds (ms) changes the exposure time in microseconds (ms)
""" """
oldexposure = CAMINSTANT.ExposureTime.GetValue() old_exposure = CAM_INSTANT.ExposureTime.GetValue()
print(f'old exposure: {oldexposure}') print(f'old exposure: {old_exposure}')
newexposure = input("Please enter new exposure value (microseconds): ") new_exposure = input("Please enter new exposure value (microseconds): ")
newexposure = float(newexposure) new_exposure = float(new_exposure)
CAMINSTANT.ExposureTime.SetValue(newexposure) CAM_INSTANT.ExposureTime.SetValue(new_exposure)
# Read new exosure value in Camera: # Read new exosure value in Camera:
print("New exposure in (ms):") print("New exposure in (ms):")
# print new exposure value # print new exposure value
print(CAMINSTANT.ExposureTime.GetValue(), "\n") print(CAM_INSTANT.ExposureTime.GetValue(), "\n")
# exposurecam() # exposurecam()
...@@ -169,29 +171,30 @@ def aquisationfps(): ...@@ -169,29 +171,30 @@ def aquisationfps():
changes the fps (frame per seconds) changes the fps (frame per seconds)
""" """
status = CAMINSTANT.AcquisitionFrameRateEnable.GetValue() status = CAM_INSTANT.AcquisitionFrameRateEnable.GetValue()
print(f'fps enable? {status}') print(f'fps enable? {status}')
statusenable = str(input("Do you want to change fps, (y/n)? ")) statusenable = str(input("Do you want to change fps, (y/n)? "))
if statusenable.lower() == 'y': if statusenable.lower() == 'y':
CAMINSTANT.AcquisitionFrameRateEnable.SetValue(True) CAM_INSTANT.AcquisitionFrameRateEnable.SetValue(True)
oldfps = CAMINSTANT.AcquisitionFrameRate.GetValue() oldfps = CAM_INSTANT.AcquisitionFrameRate.GetValue()
print(f'Old fps: {oldfps}') print(f'Old fps: {oldfps}')
newfps = input("Choose your fps: ") newfps = input("Choose your fps: ")
CAMINSTANT.AcquisitionFrameRate.SetValue(float(newfps)) CAM_INSTANT.AcquisitionFrameRate.SetValue(float(newfps))
print(f"New fps is: {newfps}", '\n') print(f"New fps is: {newfps}", '\n')
else: else:
print("disabled Aquisation Frame rate!") print("disabled Aquisation Frame rate!")
CAMINSTANT.AcquisitionFrameRateEnable.SetValue(False) CAM_INSTANT.AcquisitionFrameRateEnable.SetValue(False)
# aquisationfps() # aquisationfps()
# #
# Funktion for changing the trigger delay in microseconds (e.g. 2000 ms ): # Funktion for changing the trigger delay in microseconds (e.g. 2000 ms ):
# For e.g. Useful for running 2 different cameras and a delay needs to be added due to using same trigger signal.
# #
...@@ -200,14 +203,14 @@ def triggerdelaycam(): ...@@ -200,14 +203,14 @@ def triggerdelaycam():
changes the trigger delay in microseconds (ms) changes the trigger delay in microseconds (ms)
""" """
print(f'trigger delay is: {CAMINSTANT.TriggerDelay.GetValue()}') print(f'trigger delay is: {CAM_INSTANT.TriggerDelay.GetValue()}')
newtriggerdelay = input( newtriggerdelay = input(
"Please enter new trigger delay in (microseconds): ") "Please enter new trigger delay in (microseconds): ")
CAMINSTANT.TriggerDelay.SetValue(float(newtriggerdelay)) CAM_INSTANT.TriggerDelay.SetValue(float(newtriggerdelay))
print(f'New trigger delay is: {CAMINSTANT.TriggerDelay.GetValue()}') print(f'New trigger delay is: {CAM_INSTANT.TriggerDelay.GetValue()}')
# triggerdelaycam() # triggerdelaycam()
...@@ -222,17 +225,17 @@ def freeruncam(): ...@@ -222,17 +225,17 @@ def freeruncam():
''' '''
# camera start free run mode: VIDEO 37:32 # camera start free run mode: VIDEO 37:32
CAMINSTANT.StartGrabbing(pylon.GrabStrategy_OneByOne) CAM_INSTANT.StartGrabbing(pylon.GrabStrategy_OneByOne)
i = 0 i = 0
print('Starting to acquire') print('Starting to acquire')
t0 = time.time() t0 = time.time()
while CAMINSTANT.IsGrabbing(): while CAM_INSTANT.IsGrabbing():
grab = CAMINSTANT.RetrieveResult( grab = CAM_INSTANT.RetrieveResult(
100, pylon.TimeoutHandling_ThrowException) 100, pylon.TimeoutHandling_ThrowException)
if grab.GrabSucceeded(): if grab.GrabSucceeded():
i += 1 i += 1
if i == 100: if i == 100:
CAMINSTANT.StopGrabbing() CAM_INSTANT.StopGrabbing()
break break
print(f'Acquired {i} frames in {time.time()-t0:.0f} seconds') print(f'Acquired {i} frames in {time.time()-t0:.0f} seconds')
...@@ -241,5 +244,5 @@ def freeruncam(): ...@@ -241,5 +244,5 @@ def freeruncam():
# ---> ongoing, not yet in usage. # ---> ongoing, not yet in usage.
if __name__ == '__main__': if __name__ == '__main__':
CAM_ID, CAMINSTANT = listcams() CAM_ID, CAM_INSTANT = listcams()
readcams() readcams()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment