text
stringlengths
0
828
**Parameters:**
``shape`` : (int, int) or (int, int, int)
The (current) shape of the (scaled) image
**Yields:**
``bounding_box`` : :py:class:`BoundingBox`
An iterator iterating over all bounding boxes that are valid for the given shape
""""""
for y in range(0, shape[-2]-self.m_patch_box.bottomright[0], self.m_distance):
for x in range(0, shape[-1]-self.m_patch_box.bottomright[1], self.m_distance):
# create bounding box for the current shift
yield self.m_patch_box.shift((y,x))"
1204,"def sample(self, image):
""""""sample(image) -> bounding_box
Yields an iterator over all bounding boxes in different scales that are sampled for the given image.
**Parameters:**
``image`` : array_like(2D or 3D)
The image, for which the bounding boxes should be generated
**Yields:**
``bounding_box`` : :py:class:`BoundingBox`
An iterator iterating over all bounding boxes for the given ``image``
""""""
for scale, scaled_image_shape in self.scales(image):
# prepare the feature extractor to extract features from the given image
for bb in self.sample_scaled(scaled_image_shape):
# extract features for
yield bb.scale(1./scale)"
1205,"def iterate(self, image, feature_extractor, feature_vector):
""""""iterate(image, feature_extractor, feature_vector) -> bounding_box
Scales the given image, and extracts features from all possible bounding boxes.
For each of the sampled bounding boxes, this function fills the given pre-allocated feature vector and yields the current bounding box.
**Parameters:**
``image`` : array_like(2D)
The given image to extract features for
``feature_extractor`` : :py:class:`FeatureExtractor`
The feature extractor to use to extract the features for the sampled patches
``feature_vector`` : :py:class:`numpy.ndarray` (1D, uint16)
The pre-allocated feature vector that will be filled inside this function; needs to be of size :py:attr:`FeatureExtractor.number_of_features`
**Yields:**
``bounding_box`` : :py:class:`BoundingBox`
The bounding box for which the current features are extracted for
""""""
for scale, scaled_image_shape in self.scales(image):
# prepare the feature extractor to extract features from the given image
feature_extractor.prepare(image, scale)
for bb in self.sample_scaled(scaled_image_shape):
# extract features for
feature_extractor.extract_indexed(bb, feature_vector)
yield bb.scale(1./scale)"
1206,"def iterate_cascade(self, cascade, image, threshold = None):
""""""iterate_cascade(self, cascade, image, [threshold]) -> prediction, bounding_box
Iterates over the given image and computes the cascade of classifiers.
This function will compute the cascaded classification result for the given ``image`` using the given ``cascade``.
It yields a tuple of prediction value and the according bounding box.
If a ``threshold`` is specified, only those ``prediction``\s are returned, which exceed the given ``threshold``.
.. note::
The ``threshold`` does not overwrite the cascade thresholds `:py:attr:`Cascade.thresholds`, but only threshold the final prediction.
Specifying the ``threshold`` here is just slightly faster than thresholding the yielded prediction.
**Parameters:**
``cascade`` : :py:class:`Cascade`
The cascade that performs the predictions
``image`` : array_like(2D)
The image for which the predictions should be computed
``threshold`` : float
The threshold, which limits the number of predictions
**Yields:**
``prediction`` : float
The prediction value for the current bounding box
``bounding_box`` : :py:class:`BoundingBox`
An iterator over all possible sampled bounding boxes (which exceed the prediction ``threshold``, if given)
""""""
for scale, scaled_image_shape in self.scales(image):
# prepare the feature extractor to extract features from the given image
cascade.prepare(image, scale)