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
#
# Max Number of cameras that should be used
MAXCAMERASTOUSE = 2
MAX_CAMERAS_TO_USE = 2
# Get the transport layer factory.
......@@ -24,7 +24,7 @@ if len(devices) == 0:
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
CAMERAS_ARRAY = pylon.InstantCameraArray(min(len(devices), MAXCAMERASTOUSE))
CAMERAS_ARRAY = pylon.InstantCameraArray(min(len(devices), MAX_CAMERAS_TO_USE))
print(f'cameras: {CAMERAS_ARRAY}')
l = CAMERAS_ARRAY.GetSize()
......@@ -33,7 +33,9 @@ l = CAMERAS_ARRAY.GetSize()
# Funktions:
#
#
# List all connected / founded cameras:
#
def listcams():
......@@ -51,20 +53,20 @@ def listcams():
# 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()
print("Using device ", cam_ids)
return cam_ids, camera_instantz
return cam_ids
# Open cameras:
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')
# Close cameras:
......@@ -74,11 +76,11 @@ def closecams():
'''
close camera after read or write values
'''
CAMINSTANT.Close()
CAM_INSTANT.Close()
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():
"""
......@@ -88,23 +90,23 @@ def readcams():
# Read Gain value in Camera:
print("Gain in (dB):")
# Gain value
print(CAMINSTANT.Gain.GetValue(), "\n")
print(CAM_INSTANT.Gain.GetValue(), "\n")
# Read Trigger Delay value in Camera:
print("Delay in (microseconds):")
# TriggerDelay value
print(CAMINSTANT.TriggerDelay.GetValue(), "\n")
print(CAM_INSTANT.TriggerDelay.GetValue(), "\n")
# Exposure parameter
oldexposure = CAMINSTANT.ExposureTime.GetValue()
oldexposure = CAM_INSTANT.ExposureTime.GetValue()
print(f'exposure: {oldexposure}', "\n")
oldfps = CAMINSTANT.AcquisitionFrameRate.GetValue()
oldfps = CAM_INSTANT.AcquisitionFrameRate.GetValue()
print(f'fps: {oldfps}')
# Gamma value:
print("Camera gamma value: ")
print(CAMINSTANT.Gamma.GetValue(), "\n")
print(CAM_INSTANT.Gamma.GetValue(), "\n")
closecams()
......@@ -123,14 +125,14 @@ def gaincam():
# Read Gain value in Camera:
print(" Gain in (dB):")
# Gain value
print(CAMINSTANT.Gain.GetValue(), "\n")
print(CAM_INSTANT.Gain.GetValue(), "\n")
# Input new gain value
gainvalue = float(input("Please enter the new gain in (dB): "))
CAMINSTANT.Gain.SetValue(gainvalue)
CAM_INSTANT.Gain.SetValue(gainvalue)
# Read Gain value in Camera:
print("New Gain in (dB):")
# Gain value
print(CAMINSTANT.Gain.GetValue(), "\n")
print(CAM_INSTANT.Gain.GetValue(), "\n")
# gaincam()
......@@ -144,17 +146,17 @@ def exposurecam():
changes the exposure time in microseconds (ms)
"""
oldexposure = CAMINSTANT.ExposureTime.GetValue()
print(f'old exposure: {oldexposure}')
old_exposure = CAM_INSTANT.ExposureTime.GetValue()
print(f'old exposure: {old_exposure}')
newexposure = input("Please enter new exposure value (microseconds): ")
newexposure = float(newexposure)
CAMINSTANT.ExposureTime.SetValue(newexposure)
new_exposure = input("Please enter new exposure value (microseconds): ")
new_exposure = float(new_exposure)
CAM_INSTANT.ExposureTime.SetValue(new_exposure)
# Read new exosure value in Camera:
print("New exposure in (ms):")
# print new exposure value
print(CAMINSTANT.ExposureTime.GetValue(), "\n")
print(CAM_INSTANT.ExposureTime.GetValue(), "\n")
# exposurecam()
......@@ -169,29 +171,30 @@ def aquisationfps():
changes the fps (frame per seconds)
"""
status = CAMINSTANT.AcquisitionFrameRateEnable.GetValue()
status = CAM_INSTANT.AcquisitionFrameRateEnable.GetValue()
print(f'fps enable? {status}')
statusenable = str(input("Do you want to change fps, (y/n)? "))
if statusenable.lower() == 'y':
CAMINSTANT.AcquisitionFrameRateEnable.SetValue(True)
oldfps = CAMINSTANT.AcquisitionFrameRate.GetValue()
CAM_INSTANT.AcquisitionFrameRateEnable.SetValue(True)
oldfps = CAM_INSTANT.AcquisitionFrameRate.GetValue()
print(f'Old fps: {oldfps}')
newfps = input("Choose your fps: ")
CAMINSTANT.AcquisitionFrameRate.SetValue(float(newfps))
CAM_INSTANT.AcquisitionFrameRate.SetValue(float(newfps))
print(f"New fps is: {newfps}", '\n')
else:
print("disabled Aquisation Frame rate!")
CAMINSTANT.AcquisitionFrameRateEnable.SetValue(False)
CAM_INSTANT.AcquisitionFrameRateEnable.SetValue(False)
# aquisationfps()
#
# 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():
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(
"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()
......@@ -222,17 +225,17 @@ def freeruncam():
'''
# camera start free run mode: VIDEO 37:32
CAMINSTANT.StartGrabbing(pylon.GrabStrategy_OneByOne)
CAM_INSTANT.StartGrabbing(pylon.GrabStrategy_OneByOne)
i = 0
print('Starting to acquire')
t0 = time.time()
while CAMINSTANT.IsGrabbing():
grab = CAMINSTANT.RetrieveResult(
while CAM_INSTANT.IsGrabbing():
grab = CAM_INSTANT.RetrieveResult(
100, pylon.TimeoutHandling_ThrowException)
if grab.GrabSucceeded():
i += 1
if i == 100:
CAMINSTANT.StopGrabbing()
CAM_INSTANT.StopGrabbing()
break
print(f'Acquired {i} frames in {time.time()-t0:.0f} seconds')
......@@ -241,5 +244,5 @@ def freeruncam():
# ---> ongoing, not yet in usage.
if __name__ == '__main__':
CAM_ID, CAMINSTANT = listcams()
CAM_ID, CAM_INSTANT = listcams()
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