RodTracker.backend.img_data

TBD

class ImageData(cam_number: int, *args, **kwargs)[source]

Bases: QObject

Object for image data management for associated with a RodImageWidget.

An ImageData object handles the loading and selection of images that are meant to be displayed using a RodImageWidget. One ImageData object is supposed to be responsible for the image dataset of one RodImageWidget.

Parameters

cam_number (int) – The ‘index’ of the camera in the GUI this object is associated with.

folder

The path to the loaded image dataset folder. By default None.

Type

Path

frames

List of loaded frames in the image dataset. By default [].

Type

List[int]

files

List of paths to the images in the loaded image dataset. By default [].

Type

List[Path]

data_id

ID of the loaded image dataset. For this the selected folder’s name is used. This is can also be used for identification of position data. Example value: “gp1”. By default “”.

Type

str

frame_idx

Index of the currently displayed frame/image. By default None.

Type

int

data_loaded

A new image containing folder has been loaded successfully.

Is emitted after successful loading of an image containing folder. It sends

  • the number of loaded frames,

  • the ‘ID’ of the loaded folder, and

  • the absolute path of the loaded folder.

Type

pyqtSignal(int, str, Path)

image(frame: int) None[source]

Open an image by its frame number.

Parameters

frame (int) – Frame number of the image, that is supposed to be opened.

image_at(index: int) None[source]

Open an image by its index in the loaded image dataset.

Parameters

index (int) – Index of the image, that is supposed to be opened.

next_image(direction: int) None[source]

Attempts to open the next image.

Attempts to open the next image in the direction provided relative to the currently opened image.

Parameters

direction (int) –

Direction of the image to open next. Its the index relative to the currently opened image.

a) direction = 3 -> opens the image three positions further
b) direction = -1 -> opens the previous image
c) direction = 0 -> keeps the current image open

Returns

None

Hint

Emits

next_img

Loading of the next image file has been successful.

Is emitted after successful loading of an image file. Two different variants are sent. The first carries the loaded image as a QImage. The second variant carries the frame number and the index of the loaded frame.

Type

pyqtSignal([QImage], [int, int])

open_image_folder(chosen_file: Path)[source]

Tries to open an image folder to show the given image.

All images of the folder from the chosen file’s folder are marked for later display. The selected image is opened immediately. It tries to extract a camera id from the selected folder and logs the opening action.

Parameters

chosen_file (Path) – Path to image file chosen for immediate display.

Returns

None

Hint

Emits

select_images(pre_selection: str = '')[source]

Lets the user select an image folder to show images from.

Lets the user select an image from folder out of which all images are marked for later display. The selected image is opened immediately.

Parameters

pre_selection (str) – String representation of a folder that is supposed to be used as the initial directory for the image selection dialog. By default “”.

Returns

None

get_images(read_dir: Path) Tuple[List[Path], List[int]][source]

Reads image files from a directory.

Checks all files for naming convention according to the selected file and generates the frame IDs from them.

Parameters

read_dir (Path) – Path to the directory to read image files from.

Returns

Tuple[List[Path], List[int]] – Full paths to the found image files and frame numbers extracted from the file names.