Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
ttlmk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Christian Schrader
ttlmk
Commits
fe9a280f
Commit
fe9a280f
authored
4 months ago
by
Christian Schrader
Browse files
Options
Downloads
Patches
Plain Diff
Functions added to lmk.py.
- added exception for license warning - minor reformatting
parent
f890bc54
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
pyproject.toml
+1
-1
1 addition, 1 deletion
pyproject.toml
ttlmk/lmk.py
+107
-49
107 additions, 49 deletions
ttlmk/lmk.py
with
109 additions
and
51 deletions
README.md
+
1
−
1
View file @
fe9a280f
...
...
@@ -8,7 +8,7 @@ Import of TechnoTeam LMK images. Supports binary and text formats but actually o
binary formats are tested.
-
camera images (
*
.pus)
-
luminance images
)
*
.pf)
-
luminance images
(
*
.pf)
-
color images (?)
Format determined by internal file header, not by file name.
...
...
This diff is collapsed.
Click to expand it.
pyproject.toml
+
1
−
1
View file @
fe9a280f
...
...
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name
=
"ttlmk"
version
=
"0.1.
1
"
version
=
"0.1.
2
"
authors
=
[
{
name
=
"Christian Schrader"
,
email
=
"christian.schrader@ptb.de"
}
,
]
...
...
This diff is collapsed.
Click to expand it.
ttlmk/lmk.py
+
107
−
49
View file @
fe9a280f
...
...
@@ -11,15 +11,17 @@ See /TechnoTeam/LabSoft/doc/activexserver/class_l_m_k_ax_server.html
import
win32com.client
import
numpy
as
np
class
LMK_Error
(
Exception
):
def
__init__
(
self
,
code
,
message
,
function
=
""
):
self
.
code
=
code
self
.
message
=
message
self
.
function
=
function
class
LMK
(
object
):
_handle
=
None
def
__init__
(
self
):
self
.
_handle
=
win32com
.
client
.
Dispatch
(
"
lmk4.LMKAxServer.1
"
)
...
...
@@ -28,21 +30,21 @@ class LMK(object):
err
=
None
err_res
=
func
(
*
args
)
if
type
(
err_res
)
==
int
:
res
=
None
err
=
err_res
res
=
None
err
=
err_res
else
:
err
=
err_res
[
0
]
res
=
err_res
[
1
:]
err
=
err_res
[
0
]
res
=
err_res
[
1
:]
if
len
(
res
)
==
1
:
res
=
res
[
0
]
if
err
==
0
or
err
==
None
:
res
=
res
[
0
]
if
err
==
0
or
err
==
None
or
err
==
137363456
:
return
res
else
:
msg
=
self
.
_handle
.
iGetErrorInformation
()[
1
]
msg
=
self
.
_handle
.
iGetErrorInformation
()[
1
]
raise
LMK_Error
(
err
,
msg
,
function
=
func_name
)
def
SetNewCamera2
(
self
,
_qNameCamera
,
_qNameLens
):
'''
"""
Set new camera calibration data.
Parameters
...
...
@@ -56,14 +58,14 @@ class LMK(object):
Returns
______
0=ok, !=0 Error code
'''
func_name
=
'
iSetNewCamera2
'
"""
func_name
=
"
iSetNewCamera2
"
func
=
self
.
_handle
.
iSetNewCamera2
args
=
[
_qNameCamera
,
_qNameLens
]
return
self
.
_cmd
(
func_name
,
func
,
args
)
def
Camera_GetParameter
(
self
,
_qname
):
'''
"""
Read some additional camera properties.
\n
Parameter
________
...
...
@@ -79,14 +81,14 @@ class LMK(object):
the string depends on the parameter itself. For example the gain
is an integer value, the temperature is a floating point.
'''
func_name
=
'
iCamera_GetParameter
'
"""
func_name
=
"
iCamera_GetParameter
"
func
=
self
.
_handle
.
iCamera_GetParameter
args
=
[
_qname
]
return
self
.
_cmd
(
func_name
,
func
,
args
)
def
GetIntegrationTime
(
self
):
'''
"""
Return
________
double &_drCurrentTime,
...
...
@@ -94,23 +96,23 @@ class LMK(object):
double &_drNextTime,
double &_drMinTime,
double &_drMaxTime
'''
func_name
=
'
iGetIntegrationTime
'
"""
func_name
=
"
iGetIntegrationTime
"
func
=
self
.
_handle
.
iGetIntegrationTime
args
=
[]
return
self
.
_cmd
(
func_name
,
func
,
args
)
def
AutoScanTime
(
self
):
'''
"""
autoset exposure time
'''
func_name
=
'
iAutoScanTime
'
"""
func_name
=
"
iAutoScanTime
"
func
=
self
.
_handle
.
iAutoScanTime
args
=
[]
return
self
.
_cmd
(
func_name
,
func
,
args
)
def
SetIntegrationTime
(
self
,
_dWishedTime
):
'''
"""
Set new exposure time.
Parameters
...
...
@@ -119,15 +121,16 @@ class LMK(object):
_dWishedTime Wished integration time
_drRealizedTime Realized integration time
'''
func_name
=
'
iSetIntegrationTime
'
"""
func_name
=
"
iSetIntegrationTime
"
func
=
self
.
_handle
.
iSetIntegrationTime
args
=
[
_dWishedTime
]
return
self
.
_cmd
(
func_name
,
func
,
args
)
def
Camera_GetSaturation
(
self
,
_iWholeImage
=
1
,
_iTop
=
0
,
_iLeft
=
0
,
_iBottom
=
0
,
_iRight
=
0
,
_drSaturation
=
0
):
'''
def
Camera_GetSaturation
(
self
,
_iWholeImage
=
1
,
_iTop
=
0
,
_iLeft
=
0
,
_iBottom
=
0
,
_iRight
=
0
,
_drSaturation
=
0
):
"""
Parameters
__________
_iWholeImage - 1: Use whole image (_iTop, _iLeft,
...
...
@@ -141,36 +144,80 @@ class LMK(object):
____
_drSaturation Saturation of image or region in percent
(values between 0.0 and 100.0, 100.0 = overdriven image or region)
'''
func_name
=
'
iCamera_GetSaturation
'
"""
func_name
=
"
iCamera_GetSaturation
"
func
=
self
.
_handle
.
iCamera_GetSaturation
args
=
[
_iWholeImage
,
_iTop
,
_iLeft
,
_iBottom
,
_iRight
]
return
self
.
_cmd
(
func_name
,
func
,
*
args
)
def
Grab
(
self
):
'''
"""
Capturing a camera image
'''
func_name
=
'
iGrab
'
"""
func_name
=
"
iGrab
"
func
=
self
.
_handle
.
iGrab
args
=
[]
return
self
.
_cmd
(
func_name
,
func
,
args
)
def
SinglePic2
(
self
,
_dExposureTime
):
'''
"""
Capturing a luminance image with SinglePic algorithm
Parameters
____
dExposureTime Exposure time to use
'''
func_name
=
'
iSinglePic2
'
"""
func_name
=
"
iSinglePic2
"
func
=
self
.
_handle
.
iSinglePic2
args
=
[
_dExposureTime
]
return
self
.
_cmd
(
func_name
,
func
,
args
)
def
MultiPic2
(
self
,
_dExposureTime
,
n
):
"""
Capturing a luminance image with SinglePic algorithm
Parameters
____
dExposureTime Exposure time to use
"""
func_name
=
"
iMultiPic2
"
func
=
self
.
_handle
.
iMultiPic2
args
=
[
_dExposureTime
,
int
(
n
)]
return
self
.
_cmd
(
func_name
,
func
,
args
)
def
HighDynPic3
(
self
,
_dExposureTime
,
_dStartRatio
=
10
,
_dFactor
=
3
,
_iCountPic
=
1
):
"""
Capturing a luminance image with HiDynPic3 algorithm
Parameters
double _dExposureTime,
double _dStartRatio,
double _dFactor,
int _iCountPic
"""
func_name
=
"
iHighDynPic3
"
func
=
self
.
_handle
.
iHighDynPic3
args
=
[
_dExposureTime
,
_dStartRatio
,
_dFactor
,
int
(
_iCountPic
)]
return
self
.
_cmd
(
func_name
,
func
,
args
)
def
HighDynPic2
(
self
,
_dMaxTime
,
_dMinTime
,
_dFactor
=
3
,
_iCountPic
=
1
):
"""
Capturing a luminance image with HiDynPic3 algorithm
Parameters
double _dMaxTime,
double _dMinTime,
double _dFactor,
int _iPicCount --> wird hier wie HighDynPic3 beibehalten
"""
func_name
=
"
iHighDynPic2
"
func
=
self
.
_handle
.
iHighDynPic2
args
=
[
_dMaxTime
,
_dMinTime
,
_dFactor
,
int
(
_iCountPic
)]
return
self
.
_cmd
(
func_name
,
func
,
args
)
def
SaveImage
(
self
,
_iNumber
,
_qFileName
):
'''
"""
Save Image
Parameters
...
...
@@ -182,24 +229,33 @@ class LMK(object):
-1 Color image
0 or larger eval image
_qFileName Destination file name
'''
func_name
=
'
iSaveImage
'
"""
func_name
=
"
iSaveImage
"
func
=
self
.
_handle
.
iSaveImage
args
=
[
_iNumber
,
_qFileName
]
return
self
.
_cmd
(
func_name
,
func
,
args
)
def
Open
(
self
):
'''
"""
öffnet LabSoft
'''
func_name
=
'
iOpen
'
"""
func_name
=
"
iOpen
"
func
=
self
.
_handle
.
iOpen
args
=
[]
print
(
func_name
)
return
self
.
_cmd
(
func_name
,
func
,
args
)
def
isOpen
(
self
):
"""
testet, ob Labsoft schon geöffnet ost
"""
func_name
=
"
iIsOpen
"
func
=
self
.
_handle
.
iIsOpen
args
=
[]
# bricht die API!
return
bool
(
self
.
_handle
.
iIsOpen
())
def
Close
(
self
,
_iQuestion
=
0
):
'''
"""
Closes the Lmk4 application.
Parameters
...
...
@@ -213,26 +269,28 @@ class LMK(object):
____
0=ok, 1=User do not want to close the application, >1 Error code
'''
func_name
=
'
iClose
'
"""
func_name
=
"
iClose
"
func
=
self
.
_handle
.
iClose
args
=
[
_iQuestion
]
return
self
.
_cmd
(
func_name
,
func
,
args
)
def
ImageGetDumpToMemory
(
self
,
nr
,
rowstart
,
rowend
,
colstart
,
colend
):
# very slow! Better use SaveImage() to temporary file and
# very slow! Better use SaveImage() to temporary file and
# open it with lmk_image
func_name
=
'
iImageGetDumpToMemory
'
func_name
=
"
iImageGetDumpToMemory
"
func
=
self
.
_handle
.
iImageGetDumpToMemory
args
=
[
nr
,
rowstart
,
rowend
,
colstart
,
colend
]
# FIXME: color images?
buff
=
self
.
_cmd
(
func_name
,
func
,
args
)
img
=
np
.
frombuffer
(
buff
,
dtype
=
np
.
float32
).
reshape
(
rowend
-
rowstart
+
1
,
colend
-
colstart
+
1
)
buff
=
self
.
_cmd
(
func_name
,
func
,
args
)
img
=
np
.
frombuffer
(
buff
,
dtype
=
np
.
float32
).
reshape
(
rowend
-
rowstart
+
1
,
colend
-
colstart
+
1
)
return
img
def
SetFilterWheel
(
self
,
nr
):
func_name
=
'
iSetFilterWheel
'
func_name
=
"
iSetFilterWheel
"
func
=
self
.
_handle
.
iSetFilterWheel
args
=
[
nr
]
return
self
.
_cmd
(
func_name
,
func
,
args
)
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