Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BaslerPypylonTools
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Markus Höschle
BaslerPypylonTools
Commits
db587b29
Commit
db587b29
authored
1 year ago
by
mhoeschle
Browse files
Options
Downloads
Patches
Plain Diff
change some variable names to make them more readable
parent
99571528
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
BaslerChangeParameter.py
+38
-35
38 additions, 35 deletions
BaslerChangeParameter.py
with
38 additions
and
35 deletions
BaslerChangeParameter.py
+
38
−
35
View file @
db587b29
...
@@ -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
:
.
0
f
}
seconds
'
)
print
(
f
'
Acquired
{
i
}
frames in
{
time
.
time
()
-
t0
:
.
0
f
}
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
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment