Skip to content

Commit

Permalink
Merge pull request #24 from yupidevs/fix/example-links-on-documentation
Browse files Browse the repository at this point in the history
Fix examples links
  • Loading branch information
jmorgadov committed Jun 12, 2021
2 parents 3a7d857 + 8903d6b commit 93e220d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 36 deletions.
20 changes: 10 additions & 10 deletions docs/source/examples/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ In this table you can easily find the examples that better suits you.
| of a lysozyme molecule in water. Several molecule
| trajectories are generated and later analyzed.
- * Generation:
* :py:class:`~generators.LangevinGenerator`
* :py:class:`~generating.LangevinGenerator`
* Statistics:
* :py:func:`~statistics.estimate_velocity_samples`
* :py:func:`~statistics.estimate_turning_angles`
Expand All @@ -50,15 +50,15 @@ In this table you can easily find the examples that better suits you.
- * Visualization:
* :py:func:`~visualization.plot_trajectories`
* Tracking:
* :py:func:`~tracking.ROI`
* :py:func:`~tracking.ObjectTracker`
* :py:func:`~tracking.TrackingScenario`
* :py:func:`~tracking.ColorMatching`
* :py:func:`~tracking.FrameDifferencing`
* :py:func:`~tracking.BackgroundEstimator`
* :py:func:`~tracking.BackgroundSubtraction`
* :py:func:`~tracking.TemplateMatching`
* :py:func:`~tracking.OpticalFlow`
* :py:func:`~tracking.trackers.ROI`
* :py:func:`~tracking.trackers.ObjectTracker`
* :py:func:`~tracking.trackers.TrackingScenario`
* :py:func:`~tracking.algorithms.ColorMatching`
* :py:func:`~tracking.algorithms.FrameDifferencing`
* :py:func:`~tracking.algorithms.BackgroundEstimator`
* :py:func:`~tracking.algorithms.BackgroundSubtraction`
* :py:func:`~tracking.algorithms.TemplateMatching`
* :py:func:`~tracking.algorithms.OpticalFlow`


.. toctree::
Expand Down
49 changes: 23 additions & 26 deletions yupi/tracking/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ class BackgroundEstimator():
This class provides static methods to determine the background in image
sequences. It estimates the temporal median of the sequence.
"""

def __init__(self):
pass

def from_video(video_path, samples, start_in=0):
"""
This method takes a video indicated by ``video_path`` and uniformely
This method takes a video indicated by ``video_path`` and uniformely
take a number of image samples according to the parameter ``samples``.
Then, it computes the temporal median of the images in order to
Then, it computes the temporal median of the images in order to
determine de background.
Parameters
Expand All @@ -43,7 +44,8 @@ def from_video(video_path, samples, start_in=0):
start_in : int, optional
If passed, the method will start sampling after the frame indicated
by this value, by default 0
"""
"""

# Create a cv2 Video Capture Object
cap = cv2.VideoCapture(video_path)

Expand Down Expand Up @@ -84,6 +86,7 @@ def get_centroid(self, bin_img):
tuple
x, y coordinates of the centroid
"""

# Calculate moments
M = cv2.moments(bin_img)

Expand All @@ -96,7 +99,7 @@ def get_centroid(self, bin_img):
else:
print('[ERROR] Nothing was over threshold')
return None

def preprocess(self, frame, roi_bound, preprocessing):
frame = frame.copy()
if roi_bound:
Expand Down Expand Up @@ -151,9 +154,9 @@ class IntensityMatching(TrackingAlgorithm):
If this parameter is passed, the algoritm will stop searching for
candidate pixels after reaching a count equal to this value,
by default None.
"""
def __init__(self, min_val=0, max_val=255, max_pixels=None):
"""

def __init__(self, min_val=0, max_val=255, max_pixels=None):
super(IntensityMatching, self).__init__()
self.min_val = min_val
self.max_val = max_val
Expand Down Expand Up @@ -189,8 +192,8 @@ def detect(self, frame, roi_bound=None, preprocessing=None):
the precense of the object.
* centroid: tuple (x, y coordinates of the centroid of the object
in the image)
"""

# Make a preprocessed (and copied) version of the frame
frame = self.preprocess(frame, roi_bound, preprocessing)

Expand Down Expand Up @@ -281,8 +284,8 @@ def detect(self, frame, roi_bound=None, preprocessing=None):
the precense of the object.
* centroid: tuple (x, y coordinates of the centroid of the object
in the image)
"""

# Make a preprocessed (and copied) version of the frame
frame = self.preprocess(frame, roi_bound, preprocessing)

Expand All @@ -297,13 +300,13 @@ def detect(self, frame, roi_bound=None, preprocessing=None):

class FrameDifferencing(TrackingAlgorithm):
"""
Identifies the position of an object by comparison between consecutive
Identifies the position of an object by comparison between consecutive
frames
Parameters
----------
Minimum difference (in terms of pixel intensity) among current and
previous image to consider that pixel as part of a moving object,
Minimum difference (in terms of pixel intensity) among current and
previous image to consider that pixel as part of a moving object,
by default 1.
"""

Expand Down Expand Up @@ -342,8 +345,8 @@ def detect(self, frame, roi_bound=None, preprocessing=None):
``1`` the precense of the object.
* centroid: tuple (x, y coordinates of the centroid of the object
in the image)
"""

if self.prev_frame is None:
self.prev_frame = frame.copy()

Expand Down Expand Up @@ -420,7 +423,6 @@ def detect(self, frame, roi_bound=None, preprocessing=None):
``1`` the precense of the object.
* centroid: tuple (x, y coordinates of the centroid of the object
in the image)
"""

# Make a preprocessed (and copied) version of the frame
Expand All @@ -442,16 +444,15 @@ def detect(self, frame, roi_bound=None, preprocessing=None):
return mask, centroid



class TemplateMatching(TrackingAlgorithm):
"""
Identifies the position of an object by correlating with a template.
Parameters
----------
template : np.ndarray
Image containing a template of a tipical image of the object being
tracked. This algorithm will detect as an object of interest
Image containing a template of a tipical image of the object being
tracked. This algorithm will detect as an object of interest
the point with higher correlation between the template and the image.
threshold : float, optional
Minimum value of correlation to be considered as a match, by default
Expand Down Expand Up @@ -490,11 +491,10 @@ def detect(self, frame, roi_bound=None, preprocessing=None):
-------
tuple
* mask: np.ndarray (a binary version of ``frame`` where
elements with value ``0`` indicate the absence of object and
elements with value ``0`` indicate the absence of object and
``1`` the precense of the object.
* centroid: tuple (x, y coordinates of the centroid of the object
in the image)
"""

# Make a preprocessed (and copied) version of the frame
Expand Down Expand Up @@ -547,7 +547,6 @@ def __init__(self, threshold, buffer_size=1):

self.buffer_size = buffer_size



def detect(self, frame, roi_bound=None, preprocessing=None):
"""
Expand All @@ -572,12 +571,11 @@ def detect(self, frame, roi_bound=None, preprocessing=None):
Returns
-------
tuple
* mask: np.ndarray (a binary version of ``frame`` where
elements with value ``0`` indicate the absence of object and
``1`` the precense of the object.
* centroid: tuple (x, y coordinates of the centroid of the object
in the image)
* mask: np.ndarray (a binary version of ``frame`` where
elements with value ``0`` indicate the absence of object and
``1`` the precense of the object.
* centroid: tuple (x, y coordinates of the centroid of the object
in the image)
"""

if len(self.previous_frames) == self.buffer_size:
Expand Down Expand Up @@ -605,4 +603,3 @@ def detect(self, frame, roi_bound=None, preprocessing=None):
self.previous_frames.append(frame.copy())

return mask, centroid

0 comments on commit 93e220d

Please sign in to comment.