ct_Cells Module

class ct_Cells.Cell(movie, center_rect, size, angle)

Class that represents a cell. Each cells contains a reference to the ct_Movies.Movie instance

Note

For the moment, a cell is represented in a fixed rectangle. Thus, this is a very limited approximation, and this class will evolve in the future.

Parameters:
  • movie (ct_Movies.Movie) – The ct_Movies.Movie instance
  • center_rect ((int, int)) – Coordinates of the center of the rectangle containing the cell. Input format is a tuple of integer
  • size ((int, int)) – The size of the rectangle, as a tuple of two integers, the first one representing the size following the x axis, the second one following the y axis.
  • angle (int) – The inclinaison of the defined rectangle. Angles are counted positively in the trigonometric convention (anti-clockwise). Angles must be expressed in degrees.

Note

This function only accept integers as angles, but this should change in the future

Warning

This class is not suitable to perform any tracking

change_select(widget=None, data=None)

Function that switches between two states of the cell : selected and not selected The selected flag will be used when performing batch processing of the cell.

Note

This function is called when the select button is clicked, and the ‘widget’ and ‘data’ parameters are not required to run the function.

Note

For the moment, the selected flag has no effect.

draw_rect(cv, image)

Draws the limits of the cell and the limits of the reference image on the image This requires a cv instance. Colors can be managed by editing the code

Parameters:
  • cv (cv) – A cv instance. OpenCV must be in version > 2.0 (but I don’t know which version exactly.
  • image (cv.CvArr) – cv.CvArr (or a cv.IplImage can be required, I don’t know, please convert as appropriate

Warning

The type of the ‘image’ parameter is not well defined. Be careful!

export_cell(folder)

This function saves the cell in a specified folder. It performs the extraction of the cell from the image, and its rotation to save it in a specified format.

Parameters:folder (str) – The path to the folder where the images will be saved. This folder must exist and be empty.

Warning

This function contains a lot of warnings.

Warning

The code of this function is stil under development, it may not work properly.

Warning

The givent ‘folder’ must exist, else errors will be raised. Furthermore, this folder should be empty since the saving of the images will replace any file that has the same name as a saved image. Be careful.

Warning

This function locks the control panel since it requires to use the playback.

Warning

The ct_Cells.Cell instancemust contain a reference to an instance of the cv module.

get_index()

Returns the index of the cell

Returns:Cell index
Return type:int
get_rect()

Returns the coordinates of the rectangle surrounding the cell as defined by when instanciating the ct_Cells.Cell class.

Returns:A tuple containing the coordinates of the four points defining the rectangle. The first point is the top-left one, when displayed with a null inclination (angle=0). Then the points are in clockwise order.
Return type:(int, int, int, int)
is_all_in_screen()

Returns ‘True’ if the cell is totally contained in the image

Returns:Returns ‘True’ if the cell (and its reference) is totally contained in the image
Return type:bool
new_frame(gtk)

Creates and returns a panel containing all the controls for the management of the cell object It also initializes all the required mouse/button bindings.

Parameters:gtk (gtk) – A gtk instance
Returns:A frame object that can be attached to a window.
Return type:gtk.Frame
set_frame(i)

Saves the given index as the index of the current frame.

Warning

At that time, no verification is performed, and you must check that the input index is a valid index

Parameters:i (int) – The index of the frame
set_index(i)

Sets the index of the cell. This is used by the :class:ct_Cells.Cells instance to give unique identifiers to the cells, which allows to display those indices

Parameters:i (int) – The index of the cell to be set

Note

No type/unicity is performed by the function, this should be handled before setting the index

set_ref(p)

This function is supposed to be initializing a reference polygon in order to perform background subtraction/correction.

Note

In this version, the reference polygon is defined as the border of the defined cell (and is included in it, which means that the size of the cell includes in this version the size of the reference polygon.

Parameters:p (int) – The width, in pixel of the border that will act as a reference zone.
update_panel()

Function that updates the Cell Panel with the last data coming from the OpenCv player.

Note

For the moment, only the phase label is updated based on the _get_phase() function

class ct_Cells.Cells(movie)

This is the class managing cells, it provides various methods to add or delete cells. This class is instanciated by ct_Movies.Movie, and contains a reference to it.

Parameters:movie (ct_Movies.Movie) – The ct_Movies.Movie instance
add_cell(center_rect, size, angle)

Methods create and returns a ct_Cells instance. This class contains a ct_Movies.Movie instance

Note

For the moment, the cell is defined by a rectangle : its center and its size, but since we want to handle non-square cells, this will change in the future

Parameters:
  • center_rect ((int, int)) – Coordinates of the center of the rectangle containing the cell. Input format is a tuple of integer
  • size ((int, int)) – The size of the rectangle, as a tuple of two integers, the first one representing the size following the x axis, the second one following the y axis.
  • angle (int) – The inclinaison of the defined rectangle. Angles are counted positively in the trigonometric convention (anti-clockwise). Angles must be expressed in degrees.

Note

This function only accept integers as angles, but this should change in the future

Returns:ct_Cells.Cell instance
Return type:ct_Cells.Cell
clear_cells_list()

Clears the list of cells

get_cells_list()

Returns a list of the ct_Cells instances

Returns:list of ct_Cells.Cell instances
Return type:list
set_cells_list(list)

Replace the list of cells by another list

Parameters:list (list) – list of ct_Cells.Cell

Previous topic

CellTracking Module

Next topic

ct_Movies Module

This Page