Camera View

class experimentor.views.camera.CameraViewerWidget(parent=None)[source]

The Camera Viewer Widget is a wrapper around PyQtGraph ImageView. It adds some common methods for getting extra mouse interactions, such as performing an auto-range through right-clicking, it allows to drag and drop horizontal and vertical lines to define a ROI, and it allows to draw on top of the image. The core idea is to make these options explicit, in order to systematize them in one place.

clicked_on_image: Emits [float, float] with the coordinates where the mouse was clicked on the image. Does not
distinguish between left/right clicks. Any further processing must be done downstream.
layout
Type:QHBoxLayout, in case extra elements must be added
viewport
Type:GraphicsLayoutWidget
view
Type:ViewBox
img
Type:ImageItem
imv
Type:ImageView
auto_levels
Type:Whether to actualize the levels of the image every time they are refreshed
add_actions_to_menu()[source]

Adds actions to the contextual menu. If you want to have control on which actions appear, consider subclassing this widget and overriding this method.

clicked_on_image
classmethod connect_to_camera(camera, refresh_time=50, parent=None)[source]

Instantiate the viewer using connect_to_camera in order to get some functionality out of the box. It will create a timer to automatically update the image

do_auto_range()[source]

Sets the levels of the image based on the maximum and minimum. This is useful when auto-levels are off (the default behavior), and one needs to quickly adapt the histogram.

draw_target_pointer(locations)[source]

gets an image and draws a circle around the target locations.

Parameters:locations (DataFrame) – DataFrame generated by trackpy’s locate method. It only requires columns x and y with coordinates.
get_roi_values()[source]

Get’s the ROI values in camera-space. It keeps track of the top left corner in order to update the values before returning. :return: Position of the corners of the ROI region assuming 0-indexed cameras.

keyPressEvent(key)[source]

Triggered when there is a key press with some modifier. Shift+C: Removes the cross hair from the screen These last two events have to be handeled in the mainWindow that implemented this widget.

mouseMoved(arg)[source]

Updates the position of the cross hair. The mouse has to be moved while pressing down the Ctrl button.

mouse_clicked(evnt)[source]
scene()[source]

Shortcut to getting the image scene

set_roi_lines(X, Y)[source]
setup_cross_cut(max_size)[source]

Set ups the horizontal line for the cross cut.

setup_cross_hair(max_size)[source]

Sets up a cross hair.

setup_mouse_tracking()[source]
setup_roi_lines(max_size=None)[source]

Sets up the ROI lines surrounding the image.

Parameters:max_size (list) – List containing the maximum size of the image to avoid ROIs bigger than the CCD.
update_image(image, auto_range=False, auto_histogram_range=False)[source]

Updates the image being displayed with some sensitive defaults, which can be over written if needed.

Camera Viewer Widget

Wrapper around PyQtGraph ImageView.

class experimentor.views.camera.camera_viewer_widget.CameraViewerWidget(parent=None)[source]

The Camera Viewer Widget is a wrapper around PyQtGraph ImageView. It adds some common methods for getting extra mouse interactions, such as performing an auto-range through right-clicking, it allows to drag and drop horizontal and vertical lines to define a ROI, and it allows to draw on top of the image. The core idea is to make these options explicit, in order to systematize them in one place.

clicked_on_image: Emits [float, float] with the coordinates where the mouse was clicked on the image. Does not
distinguish between left/right clicks. Any further processing must be done downstream.
layout
Type:QHBoxLayout, in case extra elements must be added
viewport
Type:GraphicsLayoutWidget
view
Type:ViewBox
img
Type:ImageItem
imv
Type:ImageView
auto_levels
Type:Whether to actualize the levels of the image every time they are refreshed
add_actions_to_menu()[source]

Adds actions to the contextual menu. If you want to have control on which actions appear, consider subclassing this widget and overriding this method.

clicked_on_image
classmethod connect_to_camera(camera, refresh_time=50, parent=None)[source]

Instantiate the viewer using connect_to_camera in order to get some functionality out of the box. It will create a timer to automatically update the image

do_auto_range()[source]

Sets the levels of the image based on the maximum and minimum. This is useful when auto-levels are off (the default behavior), and one needs to quickly adapt the histogram.

draw_target_pointer(locations)[source]

gets an image and draws a circle around the target locations.

Parameters:locations (DataFrame) – DataFrame generated by trackpy’s locate method. It only requires columns x and y with coordinates.
get_roi_values()[source]

Get’s the ROI values in camera-space. It keeps track of the top left corner in order to update the values before returning. :return: Position of the corners of the ROI region assuming 0-indexed cameras.

keyPressEvent(key)[source]

Triggered when there is a key press with some modifier. Shift+C: Removes the cross hair from the screen These last two events have to be handeled in the mainWindow that implemented this widget.

mouseMoved(arg)[source]

Updates the position of the cross hair. The mouse has to be moved while pressing down the Ctrl button.

mouse_clicked(evnt)[source]
scene()[source]

Shortcut to getting the image scene

set_roi_lines(X, Y)[source]
setup_cross_cut(max_size)[source]

Set ups the horizontal line for the cross cut.

setup_cross_hair(max_size)[source]

Sets up a cross hair.

setup_mouse_tracking()[source]
setup_roi_lines(max_size=None)[source]

Sets up the ROI lines surrounding the image.

Parameters:max_size (list) – List containing the maximum size of the image to avoid ROIs bigger than the CCD.
update_image(image, auto_range=False, auto_histogram_range=False)[source]

Updates the image being displayed with some sensitive defaults, which can be over written if needed.