View Source Evision.CascadeClassifier (Evision v0.2.9)

Summary

Types

t()

Type that represents an CascadeClassifier struct.

Functions

CascadeClassifier

Loads a classifier from a file.

detectMultiScale2

detectMultiScale3

Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.

Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.

Checks whether the classifier has been loaded.

getOriginalWindowSize

isOldFormatCascade

Loads a classifier from a file.

Reads a classifier from a FileStorage node.

Types

@type t() :: %Evision.CascadeClassifier{ref: reference()}

Type that represents an CascadeClassifier struct.

  • ref. reference()

    The underlying erlang resource variable.

Functions

@spec cascadeClassifier() :: t() | {:error, String.t()}

CascadeClassifier

Return
  • self: Evision.CascadeClassifier.t()

Python prototype (for reference only):

CascadeClassifier() -> <CascadeClassifier object>
Link to this function

cascadeClassifier(named_args)

View Source
@spec cascadeClassifier(Keyword.t()) :: any() | {:error, String.t()}
@spec cascadeClassifier(binary()) :: t() | {:error, String.t()}

Loads a classifier from a file.

Positional Arguments
  • filename: String.

    Name of the file from which the classifier is loaded.

Return
  • self: Evision.CascadeClassifier.t()

Python prototype (for reference only):

CascadeClassifier(filename) -> <CascadeClassifier object>
@spec convert(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

convert(oldcascade, newcascade)

View Source
@spec convert(binary(), binary()) :: boolean() | {:error, String.t()}

convert

Positional Arguments
Return
  • retval: bool

Python prototype (for reference only):

convert(oldcascade, newcascade) -> retval
Link to this function

detectMultiScale2(named_args)

View Source
@spec detectMultiScale2(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

detectMultiScale2(self, image)

View Source
@spec detectMultiScale2(t(), Evision.Mat.maybe_mat_in()) ::
  {[{number(), number(), number(), number()}], [integer()]}
  | {:error, String.t()}

detectMultiScale2

Positional Arguments
  • self: Evision.CascadeClassifier.t()

  • image: Evision.Mat.

    Matrix of the type CV_8U containing an image where objects are detected.

Keyword Arguments
  • scaleFactor: double.

    Parameter specifying how much the image size is reduced at each image scale.

  • minNeighbors: integer().

    Parameter specifying how many neighbors each candidate rectangle should have to retain it.

  • flags: integer().

    Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.

  • minSize: Size.

    Minimum possible object size. Objects smaller than that are ignored.

  • maxSize: Size.

    Maximum possible object size. Objects larger than that are ignored. If maxSize == minSize model is evaluated on single scale.

Return
  • objects: [Rect].

    Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.

  • numDetections: [integer()].

    Vector of detection numbers for the corresponding objects. An object's number of detections is the number of neighboring positively classified rectangles that were joined together to form the object.

Has overloading in C++

Python prototype (for reference only):

detectMultiScale2(image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]]) -> objects, numDetections
Link to this function

detectMultiScale2(self, image, opts)

View Source
@spec detectMultiScale2(
  t(),
  Evision.Mat.maybe_mat_in(),
  [
    flags: term(),
    maxSize: term(),
    minNeighbors: term(),
    minSize: term(),
    scaleFactor: term()
  ]
  | nil
) ::
  {[{number(), number(), number(), number()}], [integer()]}
  | {:error, String.t()}

detectMultiScale2

Positional Arguments
  • self: Evision.CascadeClassifier.t()

  • image: Evision.Mat.

    Matrix of the type CV_8U containing an image where objects are detected.

Keyword Arguments
  • scaleFactor: double.

    Parameter specifying how much the image size is reduced at each image scale.

  • minNeighbors: integer().

    Parameter specifying how many neighbors each candidate rectangle should have to retain it.

  • flags: integer().

    Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.

  • minSize: Size.

    Minimum possible object size. Objects smaller than that are ignored.

  • maxSize: Size.

    Maximum possible object size. Objects larger than that are ignored. If maxSize == minSize model is evaluated on single scale.

Return
  • objects: [Rect].

    Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.

  • numDetections: [integer()].

    Vector of detection numbers for the corresponding objects. An object's number of detections is the number of neighboring positively classified rectangles that were joined together to form the object.

Has overloading in C++

Python prototype (for reference only):

detectMultiScale2(image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]]) -> objects, numDetections
Link to this function

detectMultiScale3(named_args)

View Source
@spec detectMultiScale3(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

detectMultiScale3(self, image)

View Source
@spec detectMultiScale3(t(), Evision.Mat.maybe_mat_in()) ::
  {[{number(), number(), number(), number()}], [integer()], [number()]}
  | {:error, String.t()}

detectMultiScale3

Positional Arguments
Keyword Arguments
  • scaleFactor: double.
  • minNeighbors: integer().
  • flags: integer().
  • minSize: Size.
  • maxSize: Size.
  • outputRejectLevels: bool.
Return
  • objects: [Rect]
  • rejectLevels: [integer()]
  • levelWeights: [double]

Has overloading in C++

This function allows you to retrieve the final stage decision certainty of classification. For this, one needs to set outputRejectLevels on true and provide the rejectLevels and levelWeights parameter. For each resulting detection, levelWeights will then contain the certainty of classification at the final stage. This value can then be used to separate strong from weaker classifications. A code sample on how to use it efficiently can be found below:

Mat img;
vector<double> weights;
vector<int> levels;
vector<Rect> detections;
CascadeClassifier model("/path/to/your/model.xml");
model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true);
cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;

Python prototype (for reference only):

detectMultiScale3(image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize[, outputRejectLevels]]]]]]) -> objects, rejectLevels, levelWeights
Link to this function

detectMultiScale3(self, image, opts)

View Source
@spec detectMultiScale3(
  t(),
  Evision.Mat.maybe_mat_in(),
  [
    flags: term(),
    maxSize: term(),
    minNeighbors: term(),
    minSize: term(),
    outputRejectLevels: term(),
    scaleFactor: term()
  ]
  | nil
) ::
  {[{number(), number(), number(), number()}], [integer()], [number()]}
  | {:error, String.t()}

detectMultiScale3

Positional Arguments
Keyword Arguments
  • scaleFactor: double.
  • minNeighbors: integer().
  • flags: integer().
  • minSize: Size.
  • maxSize: Size.
  • outputRejectLevels: bool.
Return
  • objects: [Rect]
  • rejectLevels: [integer()]
  • levelWeights: [double]

Has overloading in C++

This function allows you to retrieve the final stage decision certainty of classification. For this, one needs to set outputRejectLevels on true and provide the rejectLevels and levelWeights parameter. For each resulting detection, levelWeights will then contain the certainty of classification at the final stage. This value can then be used to separate strong from weaker classifications. A code sample on how to use it efficiently can be found below:

Mat img;
vector<double> weights;
vector<int> levels;
vector<Rect> detections;
CascadeClassifier model("/path/to/your/model.xml");
model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true);
cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;

Python prototype (for reference only):

detectMultiScale3(image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize[, outputRejectLevels]]]]]]) -> objects, rejectLevels, levelWeights
Link to this function

detectMultiScale(named_args)

View Source
@spec detectMultiScale(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

detectMultiScale(self, image)

View Source
@spec detectMultiScale(t(), Evision.Mat.maybe_mat_in()) ::
  [{number(), number(), number(), number()}] | {:error, String.t()}

Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.

Positional Arguments
  • self: Evision.CascadeClassifier.t()

  • image: Evision.Mat.

    Matrix of the type CV_8U containing an image where objects are detected.

Keyword Arguments
  • scaleFactor: double.

    Parameter specifying how much the image size is reduced at each image scale.

  • minNeighbors: integer().

    Parameter specifying how many neighbors each candidate rectangle should have to retain it.

  • flags: integer().

    Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.

  • minSize: Size.

    Minimum possible object size. Objects smaller than that are ignored.

  • maxSize: Size.

    Maximum possible object size. Objects larger than that are ignored. If maxSize == minSize model is evaluated on single scale.

Return
  • objects: [Rect].

    Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.

Python prototype (for reference only):

detectMultiScale(image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]]) -> objects
Link to this function

detectMultiScale(self, image, opts)

View Source
@spec detectMultiScale(
  t(),
  Evision.Mat.maybe_mat_in(),
  [
    flags: term(),
    maxSize: term(),
    minNeighbors: term(),
    minSize: term(),
    scaleFactor: term()
  ]
  | nil
) :: [{number(), number(), number(), number()}] | {:error, String.t()}

Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.

Positional Arguments
  • self: Evision.CascadeClassifier.t()

  • image: Evision.Mat.

    Matrix of the type CV_8U containing an image where objects are detected.

Keyword Arguments
  • scaleFactor: double.

    Parameter specifying how much the image size is reduced at each image scale.

  • minNeighbors: integer().

    Parameter specifying how many neighbors each candidate rectangle should have to retain it.

  • flags: integer().

    Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.

  • minSize: Size.

    Minimum possible object size. Objects smaller than that are ignored.

  • maxSize: Size.

    Maximum possible object size. Objects larger than that are ignored. If maxSize == minSize model is evaluated on single scale.

Return
  • objects: [Rect].

    Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.

Python prototype (for reference only):

detectMultiScale(image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]]) -> objects
@spec empty(Keyword.t()) :: any() | {:error, String.t()}
@spec empty(t()) :: boolean() | {:error, String.t()}

Checks whether the classifier has been loaded.

Positional Arguments
  • self: Evision.CascadeClassifier.t()
Return
  • retval: bool

Python prototype (for reference only):

empty() -> retval
Link to this function

getFeatureType(named_args)

View Source
@spec getFeatureType(Keyword.t()) :: any() | {:error, String.t()}
@spec getFeatureType(t()) :: integer() | {:error, String.t()}

getFeatureType

Positional Arguments
  • self: Evision.CascadeClassifier.t()
Return
  • retval: integer()

Python prototype (for reference only):

getFeatureType() -> retval
Link to this function

getOriginalWindowSize(named_args)

View Source
@spec getOriginalWindowSize(Keyword.t()) :: any() | {:error, String.t()}
@spec getOriginalWindowSize(t()) :: {number(), number()} | {:error, String.t()}

getOriginalWindowSize

Positional Arguments
  • self: Evision.CascadeClassifier.t()
Return
  • retval: Size

Python prototype (for reference only):

getOriginalWindowSize() -> retval
Link to this function

isOldFormatCascade(named_args)

View Source
@spec isOldFormatCascade(Keyword.t()) :: any() | {:error, String.t()}
@spec isOldFormatCascade(t()) :: boolean() | {:error, String.t()}

isOldFormatCascade

Positional Arguments
  • self: Evision.CascadeClassifier.t()
Return
  • retval: bool

Python prototype (for reference only):

isOldFormatCascade() -> retval
@spec load(Keyword.t()) :: any() | {:error, String.t()}
@spec load(t(), binary()) :: boolean() | {:error, String.t()}

Loads a classifier from a file.

Positional Arguments
  • self: Evision.CascadeClassifier.t()

  • filename: String.

    Name of the file from which the classifier is loaded. The file may contain an old HAAR classifier trained by the haartraining application or a new cascade classifier trained by the traincascade application.

Return
  • retval: bool

Python prototype (for reference only):

load(filename) -> retval
@spec read(Keyword.t()) :: any() | {:error, String.t()}
@spec read(t(), Evision.FileNode.t()) :: boolean() | {:error, String.t()}

Reads a classifier from a FileStorage node.

Positional Arguments
Return
  • retval: bool

Note: The file may contain a new cascade classifier (trained by the traincascade application) only.

Python prototype (for reference only):

read(node) -> retval