Skip to content

Commit 3c8a8c5

Browse files
committed
Minor camera bugfixes
1 parent 61b5ae3 commit 3c8a8c5

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

pylablib/devices/Andor/AndorSDK2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ def close(self):
243243
"""Close connection to the camera"""
244244
if self.handle is not None:
245245
try:
246-
self.clear_acquisition()
246+
if self._opid is not None:
247+
self.clear_acquisition()
247248
try:
248249
self._select_camera()
249250
except AndorError:

pylablib/devices/BitFlow/BitFlow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def setup_acquisition(self, mode="sequence", nframes=100, frame_merge=1): # pyl
269269
"""
270270
self.clear_acquisition()
271271
self._set_frame_merge(frame_merge)
272-
nframes=max(nframes,2)
272+
nframes=max(nframes,2*self._frame_merge)
273273
nframes=(((nframes-1)//self._frame_merge)+1)*self._frame_merge
274274
super().setup_acquisition(mode=mode,nframes=nframes,frame_merge=frame_merge)
275275
self._acq.BufferSetup(nframes//self._frame_merge)

pylablib/devices/PCO/SC2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ def _read_frames(self, rng, return_info=False):
734734
chunks=[(rng[0],start,l0),(rng[0]+l0,0,stop-start-l0)]
735735
frames=[self._parse_frames_data(self._buffer_mgr.get_buffer_ptr(s),l,shape) for (_,s,l) in chunks]
736736
if self._status_line_enabled and frames and len(frames[-1]):
737-
self._buffer_overruns=max(self._buffer_overruns,get_status_line(frames[-1][-1,:,:]).framestamp-rng[-1]-1)
737+
self._buffer_overruns=max(self._buffer_overruns,get_status_lines(frames[-1][-1,:,:])[0]-rng[-1]-1)
738738
return frames,None
739739

740740
def _get_grab_acquisition_parameters(self, nframes, buff_size):
@@ -800,7 +800,7 @@ def get_status_line(frame):
800800
801801
Assume that the status line is present; if it isn't, the returned frame info will be a random noise.
802802
"""
803-
warnings.warn(DeprecationWarning("PCO.get_status_line will be removed soon; use PCO.get_status_lines instead"))
803+
warnings.warn(DeprecationWarning("PCO.get_status_line is deprecated and will be removed in a future version. Use PCO.get_status_lines instead"))
804804
if frame.ndim==3:
805805
return [get_status_line(f) for f in frame]
806806
sline=frame[0,:14]

pylablib/devices/PCO/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from . import SC2
22
from .SC2 import list_cameras, get_cameras_number, PCOSC2Camera
33
from .SC2 import PCOSC2Error, PCOSC2TimeoutError, PCOSC2NotSupportedError
4-
from .SC2 import get_status_line, StatusLineChecker
4+
from .SC2 import get_status_line, get_status_lines, StatusLineChecker

pylablib/devices/PhotonFocus/PhotonFocus.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,11 @@ def get_roi_limits(self, hbin=1, vbin=1): # pylint: disable=unused-argument
435435

436436
def _get_buffer_bpp(self):
437437
bpp=self.GrabberClass._get_buffer_bpp(self) if self.GrabberClass else 1
438-
ppbpp=self._get_camera_bytepp()
438+
ppbpp=self._get_camera_bitpp()
439439
if ppbpp is not None:
440440
bpp=(ppbpp-1)//8+1
441441
return bpp
442-
def _get_camera_bytepp(self):
442+
def _get_camera_bitpp(self):
443443
fmt=self.get_attribute_value("DataResolution",error_on_missing=False)
444444
if fmt is None:
445445
return None
@@ -552,7 +552,7 @@ def open(self):
552552

553553
def _ensure_pixel_format(self):
554554
fgbpp=self.get_grabber_attribute_value("BITSPERPIXEL")
555-
ppbpp=self._get_camera_bytepp()
555+
ppbpp=self._get_camera_bitpp()
556556
if ppbpp is not None and ppbpp!=fgbpp:
557557
msg=( "PhotonFocus pixel format {} does not agree with the frame grabber {} bits per pixel; "
558558
"changing PhotonFocus pixel format accordingly; to use the original format, alter the camera file".format(self.cav["DataResolution"],fgbpp))
@@ -584,7 +584,7 @@ def open(self):
584584
self._ensure_pixel_format()
585585

586586
def _ensure_pixel_format(self):
587-
ppbpp=self._get_camera_bytepp()
587+
ppbpp=self._get_camera_bitpp()
588588
if ppbpp is not None:
589589
self.setup_camlink_pixel_format(ppbpp,2)
590590

@@ -622,12 +622,9 @@ def setup_acquisition(self, mode="sequence", nframes=100, frame_merge=None):
622622

623623
def _ensure_pixel_format(self):
624624
fgbpp=self._get_board_info("bpp")
625-
ppbpp=self._get_camera_bytepp()
625+
ppbpp=self._get_camera_bitpp()
626626
if ppbpp is not None and ppbpp!=fgbpp:
627-
msg=( "PhotonFocus pixel format {} does not agree with the frame grabber {} bits per pixel; "
628-
"changing PhotonFocus pixel format accordingly; to use the original format, alter the camera file".format(self.cav["DataResolution"],fgbpp))
629-
warnings.warn(msg)
630-
self._set_camera_bytepp(fgbpp)
627+
self._change_board_parameters(bpp=ppbpp)
631628

632629

633630

pylablib/devices/Thorlabs/TLCamera.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,9 @@ def acquisition_in_progress(self):
300300

301301
### Image settings and transfer controls ###
302302
def get_detector_size(self):
303-
width=lib.tl_camera_get_image_width_range(self.handle)[1]
304-
height=lib.tl_camera_get_image_height_range(self.handle)[1]
303+
roi_range=lib.tl_camera_get_roi_range(self.handle)
304+
width=roi_range[6]+1
305+
height=roi_range[7]+1
305306
return width,height
306307
def get_roi(self):
307308
roi=lib.tl_camera_get_roi(self.handle)
@@ -328,8 +329,9 @@ def set_roi(self, hstart=0, hend=None, vstart=0, vend=None, hbin=1, vbin=1):
328329
return self.get_roi()
329330
def get_roi_limits(self, hbin=1, vbin=1):
330331
wdet,hdet=self.get_detector_size()
331-
hmin=lib.tl_camera_get_image_width_range(self.handle)[0]
332-
vmin=lib.tl_camera_get_image_height_range(self.handle)[0]
332+
roi_range=lib.tl_camera_get_roi_range(self.handle)
333+
hmin=roi_range[2]+1
334+
vmin=roi_range[3]+1
333335
mhbin=lib.tl_camera_get_binx_range(self.handle)[1]
334336
mvbin=lib.tl_camera_get_biny_range(self.handle)[1]
335337
hlim=camera.TAxisROILimit(hmin*hbin,wdet,1,hbin,mhbin)

pylablib/devices/utils/load_lib.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ def close(self, opid):
238238
Return tuple ``(close_result, uninit_result)`` with the results of the closing and the shutdown.
239239
If library does not need to be shut down yet, set ``uninit_result=None``
240240
"""
241+
if opid is None:
242+
return
241243
with self.lock:
242244
if opid in self.opened:
243245
self.opened.remove(opid)
@@ -261,8 +263,7 @@ def temp_open(self):
261263
init_result,open_result,opid=self.open()
262264
yield init_result,open_result
263265
finally:
264-
if opid is not None:
265-
self.close(opid)
266+
self.close(opid)
266267
def shutdown(self):
267268
"""Close all opened connections and shutdown the library"""
268269
for opid in list(self.opened):

0 commit comments

Comments
 (0)