OpenCV 2.4.3 (RC)

org.opencv.core
Class Algorithm

java.lang.Object
  extended by org.opencv.core.Algorithm
Direct Known Subclasses:
BackgroundSubtractor, EM, FaceRecognizer

public class Algorithm
extends java.lang.Object

This is a base class for all more or less complex algorithms in OpenCV, especially for classes of algorithms, for which there can be multiple implementations. The examples are stereo correspondence (for which there are algorithms like block matching, semi-global block matching, graph-cut etc.), background subtraction (which can be done using mixture-of-gaussians models, codebook-based algorithm etc.), optical flow (block matching, Lucas-Kanade, Horn-Schunck etc.).

The class provides the following features for all derived classes:

Here is example of SIFT use in your application via Algorithm interface:

#include "opencv2/opencv.hpp"

// C++ code:

#include "opencv2/nonfree/nonfree.hpp"...

initModule_nonfree(); // to load SURF/SIFT etc.

Ptr sift = Algorithm.create("Feature2D.SIFT");

FileStorage fs("sift_params.xml", FileStorage.READ);

if(fs.isOpened()) // if we have file with parameters, read them

sift->read(fs["sift_params"]);

fs.release();

else // else modify the parameters and store them; user can later edit the file to use different parameters

sift->set("contrastThreshold", 0.01f); // lower the contrast threshold, compared to the default value

WriteStructContext ws(fs, "sift_params", CV_NODE_MAP);

sift->write(fs);

Mat image = imread("myimage.png", 0), descriptors;

vector keypoints;

(*sift)(image, noArray(), keypoints, descriptors);

See Also:
org.opencv.core.Algorithm

Field Summary
protected  long nativeObj
           
 
Constructor Summary
protected Algorithm(long addr)
           
 
Method Summary
protected  void finalize()
           
 boolean getBool(java.lang.String name)
           
 double getDouble(java.lang.String name)
           
 int getInt(java.lang.String name)
           
 Mat getMat(java.lang.String name)
           
 java.util.List<Mat> getMatVector(java.lang.String name)
           
 java.lang.String getString(java.lang.String name)
           
 java.lang.String paramHelp(java.lang.String name)
           
 int paramType(java.lang.String name)
           
 void setBool(java.lang.String name, boolean value)
          Sets the algorithm parameter The method sets value of the particular parameter.
 void setDouble(java.lang.String name, double value)
          Sets the algorithm parameter The method sets value of the particular parameter.
 void setInt(java.lang.String name, int value)
          Sets the algorithm parameter The method sets value of the particular parameter.
 void setMat(java.lang.String name, Mat value)
          Sets the algorithm parameter The method sets value of the particular parameter.
 void setMatVector(java.lang.String name, java.util.List<Mat> value)
          Sets the algorithm parameter The method sets value of the particular parameter.
 void setString(java.lang.String name, java.lang.String value)
          Sets the algorithm parameter The method sets value of the particular parameter.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nativeObj

protected final long nativeObj
Constructor Detail

Algorithm

protected Algorithm(long addr)
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getBool

public boolean getBool(java.lang.String name)

getDouble

public double getDouble(java.lang.String name)

getInt

public int getInt(java.lang.String name)

getMat

public Mat getMat(java.lang.String name)

getMatVector

public java.util.List<Mat> getMatVector(java.lang.String name)

getString

public java.lang.String getString(java.lang.String name)

paramHelp

public java.lang.String paramHelp(java.lang.String name)

paramType

public int paramType(java.lang.String name)

setBool

public void setBool(java.lang.String name,
                    boolean value)

Sets the algorithm parameter

The method sets value of the particular parameter. Some of the algorithm parameters may be declared as read-only. If you try to set such a parameter, you will get exception with the corresponding error message.

Parameters:
name - The parameter name.
value - The parameter value.
See Also:
org.opencv.core.Algorithm.set

setDouble

public void setDouble(java.lang.String name,
                      double value)

Sets the algorithm parameter

The method sets value of the particular parameter. Some of the algorithm parameters may be declared as read-only. If you try to set such a parameter, you will get exception with the corresponding error message.

Parameters:
name - The parameter name.
value - The parameter value.
See Also:
org.opencv.core.Algorithm.set

setInt

public void setInt(java.lang.String name,
                   int value)

Sets the algorithm parameter

The method sets value of the particular parameter. Some of the algorithm parameters may be declared as read-only. If you try to set such a parameter, you will get exception with the corresponding error message.

Parameters:
name - The parameter name.
value - The parameter value.
See Also:
org.opencv.core.Algorithm.set

setMat

public void setMat(java.lang.String name,
                   Mat value)

Sets the algorithm parameter

The method sets value of the particular parameter. Some of the algorithm parameters may be declared as read-only. If you try to set such a parameter, you will get exception with the corresponding error message.

Parameters:
name - The parameter name.
value - The parameter value.
See Also:
org.opencv.core.Algorithm.set

setMatVector

public void setMatVector(java.lang.String name,
                         java.util.List<Mat> value)

Sets the algorithm parameter

The method sets value of the particular parameter. Some of the algorithm parameters may be declared as read-only. If you try to set such a parameter, you will get exception with the corresponding error message.

Parameters:
name - The parameter name.
value - The parameter value.
See Also:
org.opencv.core.Algorithm.set

setString

public void setString(java.lang.String name,
                      java.lang.String value)

Sets the algorithm parameter

The method sets value of the particular parameter. Some of the algorithm parameters may be declared as read-only. If you try to set such a parameter, you will get exception with the corresponding error message.

Parameters:
name - The parameter name.
value - The parameter value.
See Also:
org.opencv.core.Algorithm.set

Official OpenCV 2.4 Documentation