***
Wartungsfenster jeden ersten Mittwoch vormittag im Monat
***
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
leolab_devices
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Quantuminfo
Experiment Control
labscript-suite
leolab_devices
Commits
2825dd60
Commit
2825dd60
authored
2 years ago
by
mh1020
Browse files
Options
Downloads
Patches
Plain Diff
Fixed all the bugs in DCAM Camera
parent
3fba66b3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DCAMCamera/blacs_workers.py
+18
-18
18 additions, 18 deletions
DCAMCamera/blacs_workers.py
DCAMCamera/dcam.py
+1
-1
1 addition, 1 deletion
DCAMCamera/dcam.py
with
19 additions
and
19 deletions
DCAMCamera/blacs_workers.py
+
18
−
18
View file @
2825dd60
...
...
@@ -40,7 +40,7 @@ class DCAM_Camera(object):
_abort_acquisition (bool): Abort flag that is polled during buffered
acquisitions.
"""
def
__init__
(
self
,
serial_number
,
timeout
):
def
__init__
(
self
,
serial_number
):
"""
Initialize DCAM API camera.
Searches all cameras reachable by the host using the provided serial
...
...
@@ -51,18 +51,18 @@ class DCAM_Camera(object):
Args:
serial_number (str): serial number of camera to connect to
"""
self
.
timeout
=
timeout
self
.
timeout
=
60000
global
dcamAPI
import
dcam
as
dcamAPI
import
user_devices.DCAMCamera.
dcam
as
dcamAPI
print
(
'
Initialize DCAM API ...
'
)
if
dcamAPI
.
Dcamapi
.
init
()
is
False
:
dcamAPI
.
Dcamapi
.
uninit
()
msg
=
'
Dcamapi.init() fails with error {}
'
.
format
(
dcamAPI
.
DCAMERR
(
dcamAPI
.
Dcamapi
.
lasterr
()).
name
)
dcamAPI
.
Dcamapi
.
uninit
()
raise
RuntimeError
(
msg
)
print
(
'
Connecting to S/N: %
d
...
'
%
serial_number
)
print
(
'
Connecting to S/N: %
s
...
'
%
serial_number
)
#Iterate Trough Cameras
for
camID
in
range
(
dcamAPI
.
Dcamapi
.
get_devicecount
()):
self
.
camera
=
dcamAPI
.
Dcam
(
camID
)
...
...
@@ -70,25 +70,22 @@ class DCAM_Camera(object):
print
(
'
Dcam.open() fails with error {}
'
.
format
(
dcamAPI
.
DCAMERR
(
dcamAPI
.
Dcamapi
.
lasterr
()).
name
))
self
.
camera
.
dev_close
()
else
:
if
serial_number
==
(
self
.
camera
.
dev_getstring
(
dcamAPI
.
DCAM_IDSTR
.
CAMERAID
)).
split
(
'
'
)[
1
]:
if
serial_number
==
int
(
(
self
.
camera
.
dev_getstring
(
dcamAPI
.
DCAM_IDSTR
.
CAMERAID
)).
split
(
'
'
)[
1
]
,
16
)
:
print
(
"
Correct camera found!
"
)
break
else
:
#Not the camera we are looking for. Continue searching.
self
.
camera
.
dev_close
()
if
serial_number
!=
(
self
.
camera
.
dev_getstring
(
dcamAPI
.
DCAM_IDSTR
.
CAMERAID
)).
split
(
'
'
)[
1
]:
if
serial_number
!=
int
((
self
.
camera
.
dev_getstring
(
dcamAPI
.
DCAM_IDSTR
.
CAMERAID
)).
split
(
'
'
)[
1
],
16
):
msg
=
"""
ERROR: Camera with the selected serial number could not be found.
"""
self
.
camera
.
dev_close
()
raise
RuntimeError
(
msg
)
print
(
"
Connected to Camera:
"
,
end
=
'
\t
'
)
print
(
self
.
camera
.
dev_getstring
(
dcamAPI
.
DCAM_IDSTR
.
MODEL
),
end
=
'
\t
'
)
print
(
self
.
camera
.
dev_getstring
(
dcamAPI
.
DCAM_IDSTR
.
CAMERAID
))
#Get Pixel Formats
attr
=
self
.
camera
.
prop_getattr
(
dcamAPI
.
DCAM_IDPROP
.
IMAGE_PIXELTYPE
)
fmts
=
{
self
.
camera
.
prop_getvaluetext
(
dcamAPI
.
DCAM_IDPROP
.
IMAGE_PIXELTYPE
,
value
)
for
value
in
range
(
attr
.
valuemin
,
attr
.
valuemax
+
attr
.
valuestep
,
attr
.
valuestep
)
}
self
.
pixel_formats
=
IntEnum
(
'
pixel_formats
'
,
fmts
)
self
.
_abort_acquisition
=
False
self
.
exception_on_failed_shot
=
True
...
...
@@ -100,6 +97,7 @@ class DCAM_Camera(object):
for
attr
,
value
in
attr_dict
.
items
():
propID
=
dcamAPI
.
DCAM_IDPROP
.
__getattr__
(
attr
).
value
self
.
camera
.
prop_setvalue
(
propID
,
value
)
print
(
"
Set Attribute ID
"
,
propID
,
"
to value:
"
,
value
)
def
get_attributes
(
self
,
visibility_level
,
writeable_only
=
True
):
"""
Return a nested dict of all readable attributes.
...
...
@@ -116,9 +114,9 @@ class DCAM_Camera(object):
while
propID
is
not
False
:
propAttr
=
self
.
camera
.
prop_getattr
(
propID
)
if
propAttr
.
is_readable
():
props
[
dcamAPI
.
DCAM_IDPROP
(
propID
).
name
]
=
self
.
camera
.
prop_getvalue
(
propID
)
name
=
self
.
camera
.
prop_getname
(
propID
)
props
[
name
]
=
self
.
camera
.
prop_getvalue
(
propID
)
propID
=
self
.
camera
.
prop_getnextid
(
propID
)
return
props
def
get_attribute
(
self
,
name
):
...
...
@@ -180,15 +178,16 @@ class DCAM_Camera(object):
bufferCount (:obj:`int`, optional): Number of memory buffers to use
in the acquistion. Default is 10.
"""
print
(
"
Configuring acquisition of
"
,
bufferCount
,
"
images.
"
)
if
self
.
camera
.
buf_alloc
(
bufferCount
)
is
False
:
msg
=
'
Dcam.buf_alloc() fails with error {}
'
.
format
(
dcamAPI
.
DCAMERR
(
dcamAPI
.
Dcamapi
.
lasterr
()).
name
)
raise
RuntimeError
(
msg
)
self
.
width
=
self
.
camera
.
prop_getvalue
(
dcamAPI
.
DCAM_IDPROP
.
IMAGE_WIDTH
)
self
.
height
=
self
.
camera
.
prop_getvalue
(
dcamAPI
.
DCAM_IDPROP
.
IMAGE_HEIGHT
)
self
.
pixelFormat
=
self
.
pixel_formats
(
self
.
camera
.
prop_getvalue
(
dcamAPI
.
DCAM_IDPROP
.
IMAGE_PIXELTYPE
))
self
.
pixelFormat
=
self
.
camera
.
prop_getvaluetext
(
dcamAPI
.
DCAM_IDPROP
.
IMAGE_PIXELTYPE
,
self
.
camera
.
prop_getvalue
(
dcamAPI
.
DCAM_IDPROP
.
IMAGE_PIXELTYPE
))
if
continuous
:
self
.
camera
.
cap_start
self
.
camera
.
cap_start
(
True
)
def
grab
(
self
):
"""
Grab and return single image during pre-configured acquisition.
...
...
@@ -196,7 +195,6 @@ class DCAM_Camera(object):
Returns:
numpy.array: Returns formatted image
"""
if
self
.
camera
.
wait_capevent_frameready
(
self
.
timeout
)
is
not
False
:
image
=
self
.
camera
.
buf_getlastframedata
()
else
:
...
...
@@ -233,7 +231,8 @@ class DCAM_Camera(object):
def
stop_acquisition
(
self
):
"""
Tells camera to stop current acquistion.
"""
self
.
camera
.
cap_stop
self
.
camera
.
cap_stop
()
self
.
camera
.
buf_release
()
def
abort_acquisition
(
self
):
"""
Sets :obj:`_abort_acquisition` flag to break buffered acquisition loop.
"""
...
...
@@ -242,6 +241,7 @@ class DCAM_Camera(object):
def
close
(
self
):
"""
Closes :obj:`camera` handle to the camera.
"""
self
.
camera
.
dev_close
()
dcamAPI
.
Dcamapi
.
uninit
()
class
DCAMCameraWorker
(
IMAQdxCameraWorker
):
"""
FlyCapture2 API Camera Worker.
...
...
This diff is collapsed.
Click to expand it.
DCAMCamera/dcam.py
+
1
−
1
View file @
2825dd60
...
...
@@ -4,7 +4,7 @@
#
# The declarations of classes and functions in this file are subject to change without notice.
from
dcamapi4
import
*
from
user_devices.DCAMCamera.
dcamapi4
import
*
import
numpy
as
np
...
...
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