removed optim module; moved its functionality to core and photo modules; moved drawing functions from core to imgproc. Removed FilterEngine etc. from public API
This commit is contained in:
@@ -506,96 +506,6 @@ CV_EXPORTS_W void randn(InputOutputArray dst, InputArray mean, InputArray stddev
|
||||
//! shuffles the input array elements
|
||||
CV_EXPORTS_W void randShuffle(InputOutputArray dst, double iterFactor = 1., RNG* rng = 0);
|
||||
|
||||
//! draws the line segment (pt1, pt2) in the image
|
||||
CV_EXPORTS_W void line(InputOutputArray img, Point pt1, Point pt2, const Scalar& color,
|
||||
int thickness = 1, int lineType = LINE_8, int shift = 0);
|
||||
|
||||
//! draws an arrow from pt1 to pt2 in the image
|
||||
CV_EXPORTS_W void arrowedLine(InputOutputArray img, Point pt1, Point pt2, const Scalar& color,
|
||||
int thickness=1, int line_type=8, int shift=0, double tipLength=0.1);
|
||||
|
||||
//! draws the rectangle outline or a solid rectangle with the opposite corners pt1 and pt2 in the image
|
||||
CV_EXPORTS_W void rectangle(InputOutputArray img, Point pt1, Point pt2,
|
||||
const Scalar& color, int thickness = 1,
|
||||
int lineType = LINE_8, int shift = 0);
|
||||
|
||||
//! draws the rectangle outline or a solid rectangle covering rec in the image
|
||||
CV_EXPORTS void rectangle(CV_IN_OUT Mat& img, Rect rec,
|
||||
const Scalar& color, int thickness = 1,
|
||||
int lineType = LINE_8, int shift = 0);
|
||||
|
||||
//! draws the circle outline or a solid circle in the image
|
||||
CV_EXPORTS_W void circle(InputOutputArray img, Point center, int radius,
|
||||
const Scalar& color, int thickness = 1,
|
||||
int lineType = LINE_8, int shift = 0);
|
||||
|
||||
//! draws an elliptic arc, ellipse sector or a rotated ellipse in the image
|
||||
CV_EXPORTS_W void ellipse(InputOutputArray img, Point center, Size axes,
|
||||
double angle, double startAngle, double endAngle,
|
||||
const Scalar& color, int thickness = 1,
|
||||
int lineType = LINE_8, int shift = 0);
|
||||
|
||||
//! draws a rotated ellipse in the image
|
||||
CV_EXPORTS_W void ellipse(InputOutputArray img, const RotatedRect& box, const Scalar& color,
|
||||
int thickness = 1, int lineType = LINE_8);
|
||||
|
||||
//! draws a filled convex polygon in the image
|
||||
CV_EXPORTS void fillConvexPoly(Mat& img, const Point* pts, int npts,
|
||||
const Scalar& color, int lineType = LINE_8,
|
||||
int shift = 0);
|
||||
|
||||
CV_EXPORTS_W void fillConvexPoly(InputOutputArray img, InputArray points,
|
||||
const Scalar& color, int lineType = LINE_8,
|
||||
int shift = 0);
|
||||
|
||||
//! fills an area bounded by one or more polygons
|
||||
CV_EXPORTS void fillPoly(Mat& img, const Point** pts,
|
||||
const int* npts, int ncontours,
|
||||
const Scalar& color, int lineType = LINE_8, int shift = 0,
|
||||
Point offset = Point() );
|
||||
|
||||
CV_EXPORTS_W void fillPoly(InputOutputArray img, InputArrayOfArrays pts,
|
||||
const Scalar& color, int lineType = LINE_8, int shift = 0,
|
||||
Point offset = Point() );
|
||||
|
||||
//! draws one or more polygonal curves
|
||||
CV_EXPORTS void polylines(Mat& img, const Point* const* pts, const int* npts,
|
||||
int ncontours, bool isClosed, const Scalar& color,
|
||||
int thickness = 1, int lineType = LINE_8, int shift = 0 );
|
||||
|
||||
CV_EXPORTS_W void polylines(InputOutputArray img, InputArrayOfArrays pts,
|
||||
bool isClosed, const Scalar& color,
|
||||
int thickness = 1, int lineType = LINE_8, int shift = 0 );
|
||||
|
||||
//! draws contours in the image
|
||||
CV_EXPORTS_W void drawContours( InputOutputArray image, InputArrayOfArrays contours,
|
||||
int contourIdx, const Scalar& color,
|
||||
int thickness = 1, int lineType = LINE_8,
|
||||
InputArray hierarchy = noArray(),
|
||||
int maxLevel = INT_MAX, Point offset = Point() );
|
||||
|
||||
//! clips the line segment by the rectangle Rect(0, 0, imgSize.width, imgSize.height)
|
||||
CV_EXPORTS bool clipLine(Size imgSize, CV_IN_OUT Point& pt1, CV_IN_OUT Point& pt2);
|
||||
|
||||
//! clips the line segment by the rectangle imgRect
|
||||
CV_EXPORTS_W bool clipLine(Rect imgRect, CV_OUT CV_IN_OUT Point& pt1, CV_OUT CV_IN_OUT Point& pt2);
|
||||
|
||||
//! converts elliptic arc to a polygonal curve
|
||||
CV_EXPORTS_W void ellipse2Poly( Point center, Size axes, int angle,
|
||||
int arcStart, int arcEnd, int delta,
|
||||
CV_OUT std::vector<Point>& pts );
|
||||
|
||||
//! renders text string in the image
|
||||
CV_EXPORTS_W void putText( InputOutputArray img, const String& text, Point org,
|
||||
int fontFace, double fontScale, Scalar color,
|
||||
int thickness = 1, int lineType = LINE_8,
|
||||
bool bottomLeftOrigin = false );
|
||||
|
||||
//! returns bounding box of the text string
|
||||
CV_EXPORTS_W Size getTextSize(const String& text, int fontFace,
|
||||
double fontScale, int thickness,
|
||||
CV_OUT int* baseLine);
|
||||
|
||||
/*!
|
||||
Principal Component Analysis
|
||||
|
||||
@@ -1319,5 +1229,7 @@ template<> struct ParamType<uchar>
|
||||
|
||||
#include "opencv2/core/operations.hpp"
|
||||
#include "opencv2/core/cvstd.inl.hpp"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
#include "opencv2/core/optim.hpp"
|
||||
|
||||
#endif /*__OPENCV_CORE_HPP__*/
|
||||
|
@@ -1262,192 +1262,6 @@ CVAPI(int) cvNextGraphItem( CvGraphScanner* scanner );
|
||||
/* Creates a copy of graph */
|
||||
CVAPI(CvGraph*) cvCloneGraph( const CvGraph* graph, CvMemStorage* storage );
|
||||
|
||||
/****************************************************************************************\
|
||||
* Drawing *
|
||||
\****************************************************************************************/
|
||||
|
||||
/****************************************************************************************\
|
||||
* Drawing functions work with images/matrices of arbitrary type. *
|
||||
* For color images the channel order is BGR[A] *
|
||||
* Antialiasing is supported only for 8-bit image now. *
|
||||
* All the functions include parameter color that means rgb value (that may be *
|
||||
* constructed with CV_RGB macro) for color images and brightness *
|
||||
* for grayscale images. *
|
||||
* If a drawn figure is partially or completely outside of the image, it is clipped.*
|
||||
\****************************************************************************************/
|
||||
|
||||
#define CV_RGB( r, g, b ) cvScalar( (b), (g), (r), 0 )
|
||||
#define CV_FILLED -1
|
||||
|
||||
#define CV_AA 16
|
||||
|
||||
/* Draws 4-connected, 8-connected or antialiased line segment connecting two points */
|
||||
CVAPI(void) cvLine( CvArr* img, CvPoint pt1, CvPoint pt2,
|
||||
CvScalar color, int thickness CV_DEFAULT(1),
|
||||
int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
|
||||
|
||||
/* Draws a rectangle given two opposite corners of the rectangle (pt1 & pt2),
|
||||
if thickness<0 (e.g. thickness == CV_FILLED), the filled box is drawn */
|
||||
CVAPI(void) cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2,
|
||||
CvScalar color, int thickness CV_DEFAULT(1),
|
||||
int line_type CV_DEFAULT(8),
|
||||
int shift CV_DEFAULT(0));
|
||||
|
||||
/* Draws a rectangle specified by a CvRect structure */
|
||||
CVAPI(void) cvRectangleR( CvArr* img, CvRect r,
|
||||
CvScalar color, int thickness CV_DEFAULT(1),
|
||||
int line_type CV_DEFAULT(8),
|
||||
int shift CV_DEFAULT(0));
|
||||
|
||||
|
||||
/* Draws a circle with specified center and radius.
|
||||
Thickness works in the same way as with cvRectangle */
|
||||
CVAPI(void) cvCircle( CvArr* img, CvPoint center, int radius,
|
||||
CvScalar color, int thickness CV_DEFAULT(1),
|
||||
int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));
|
||||
|
||||
/* Draws ellipse outline, filled ellipse, elliptic arc or filled elliptic sector,
|
||||
depending on <thickness>, <start_angle> and <end_angle> parameters. The resultant figure
|
||||
is rotated by <angle>. All the angles are in degrees */
|
||||
CVAPI(void) cvEllipse( CvArr* img, CvPoint center, CvSize axes,
|
||||
double angle, double start_angle, double end_angle,
|
||||
CvScalar color, int thickness CV_DEFAULT(1),
|
||||
int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));
|
||||
|
||||
CV_INLINE void cvEllipseBox( CvArr* img, CvBox2D box, CvScalar color,
|
||||
int thickness CV_DEFAULT(1),
|
||||
int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) )
|
||||
{
|
||||
CvSize axes;
|
||||
axes.width = cvRound(box.size.width*0.5);
|
||||
axes.height = cvRound(box.size.height*0.5);
|
||||
|
||||
cvEllipse( img, cvPointFrom32f( box.center ), axes, box.angle,
|
||||
0, 360, color, thickness, line_type, shift );
|
||||
}
|
||||
|
||||
/* Fills convex or monotonous polygon. */
|
||||
CVAPI(void) cvFillConvexPoly( CvArr* img, const CvPoint* pts, int npts, CvScalar color,
|
||||
int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));
|
||||
|
||||
/* Fills an area bounded by one or more arbitrary polygons */
|
||||
CVAPI(void) cvFillPoly( CvArr* img, CvPoint** pts, const int* npts,
|
||||
int contours, CvScalar color,
|
||||
int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
|
||||
|
||||
/* Draws one or more polygonal curves */
|
||||
CVAPI(void) cvPolyLine( CvArr* img, CvPoint** pts, const int* npts, int contours,
|
||||
int is_closed, CvScalar color, int thickness CV_DEFAULT(1),
|
||||
int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
|
||||
|
||||
#define cvDrawRect cvRectangle
|
||||
#define cvDrawLine cvLine
|
||||
#define cvDrawCircle cvCircle
|
||||
#define cvDrawEllipse cvEllipse
|
||||
#define cvDrawPolyLine cvPolyLine
|
||||
|
||||
/* Clips the line segment connecting *pt1 and *pt2
|
||||
by the rectangular window
|
||||
(0<=x<img_size.width, 0<=y<img_size.height). */
|
||||
CVAPI(int) cvClipLine( CvSize img_size, CvPoint* pt1, CvPoint* pt2 );
|
||||
|
||||
/* Initializes line iterator. Initially, line_iterator->ptr will point
|
||||
to pt1 (or pt2, see left_to_right description) location in the image.
|
||||
Returns the number of pixels on the line between the ending points. */
|
||||
CVAPI(int) cvInitLineIterator( const CvArr* image, CvPoint pt1, CvPoint pt2,
|
||||
CvLineIterator* line_iterator,
|
||||
int connectivity CV_DEFAULT(8),
|
||||
int left_to_right CV_DEFAULT(0));
|
||||
|
||||
/* Moves iterator to the next line point */
|
||||
#define CV_NEXT_LINE_POINT( line_iterator ) \
|
||||
{ \
|
||||
int _line_iterator_mask = (line_iterator).err < 0 ? -1 : 0; \
|
||||
(line_iterator).err += (line_iterator).minus_delta + \
|
||||
((line_iterator).plus_delta & _line_iterator_mask); \
|
||||
(line_iterator).ptr += (line_iterator).minus_step + \
|
||||
((line_iterator).plus_step & _line_iterator_mask); \
|
||||
}
|
||||
|
||||
|
||||
/* basic font types */
|
||||
#define CV_FONT_HERSHEY_SIMPLEX 0
|
||||
#define CV_FONT_HERSHEY_PLAIN 1
|
||||
#define CV_FONT_HERSHEY_DUPLEX 2
|
||||
#define CV_FONT_HERSHEY_COMPLEX 3
|
||||
#define CV_FONT_HERSHEY_TRIPLEX 4
|
||||
#define CV_FONT_HERSHEY_COMPLEX_SMALL 5
|
||||
#define CV_FONT_HERSHEY_SCRIPT_SIMPLEX 6
|
||||
#define CV_FONT_HERSHEY_SCRIPT_COMPLEX 7
|
||||
|
||||
/* font flags */
|
||||
#define CV_FONT_ITALIC 16
|
||||
|
||||
#define CV_FONT_VECTOR0 CV_FONT_HERSHEY_SIMPLEX
|
||||
|
||||
|
||||
/* Font structure */
|
||||
typedef struct CvFont
|
||||
{
|
||||
const char* nameFont; //Qt:nameFont
|
||||
CvScalar color; //Qt:ColorFont -> cvScalar(blue_component, green_component, red\_component[, alpha_component])
|
||||
int font_face; //Qt: bool italic /* =CV_FONT_* */
|
||||
const int* ascii; /* font data and metrics */
|
||||
const int* greek;
|
||||
const int* cyrillic;
|
||||
float hscale, vscale;
|
||||
float shear; /* slope coefficient: 0 - normal, >0 - italic */
|
||||
int thickness; //Qt: weight /* letters thickness */
|
||||
float dx; /* horizontal interval between letters */
|
||||
int line_type; //Qt: PointSize
|
||||
}
|
||||
CvFont;
|
||||
|
||||
/* Initializes font structure used further in cvPutText */
|
||||
CVAPI(void) cvInitFont( CvFont* font, int font_face,
|
||||
double hscale, double vscale,
|
||||
double shear CV_DEFAULT(0),
|
||||
int thickness CV_DEFAULT(1),
|
||||
int line_type CV_DEFAULT(8));
|
||||
|
||||
CV_INLINE CvFont cvFont( double scale, int thickness CV_DEFAULT(1) )
|
||||
{
|
||||
CvFont font;
|
||||
cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, scale, scale, 0, thickness, CV_AA );
|
||||
return font;
|
||||
}
|
||||
|
||||
/* Renders text stroke with specified font and color at specified location.
|
||||
CvFont should be initialized with cvInitFont */
|
||||
CVAPI(void) cvPutText( CvArr* img, const char* text, CvPoint org,
|
||||
const CvFont* font, CvScalar color );
|
||||
|
||||
/* Calculates bounding box of text stroke (useful for alignment) */
|
||||
CVAPI(void) cvGetTextSize( const char* text_string, const CvFont* font,
|
||||
CvSize* text_size, int* baseline );
|
||||
|
||||
|
||||
|
||||
/* Unpacks color value, if arrtype is CV_8UC?, <color> is treated as
|
||||
packed color value, otherwise the first channels (depending on arrtype)
|
||||
of destination scalar are set to the same value = <color> */
|
||||
CVAPI(CvScalar) cvColorToScalar( double packed_color, int arrtype );
|
||||
|
||||
/* Returns the polygon points which make up the given ellipse. The ellipse is define by
|
||||
the box of size 'axes' rotated 'angle' around the 'center'. A partial sweep
|
||||
of the ellipse arc can be done by spcifying arc_start and arc_end to be something
|
||||
other than 0 and 360, respectively. The input array 'pts' must be large enough to
|
||||
hold the result. The total number of points stored into 'pts' is returned by this
|
||||
function. */
|
||||
CVAPI(int) cvEllipse2Poly( CvPoint center, CvSize axes,
|
||||
int angle, int arc_start, int arc_end, CvPoint * pts, int delta );
|
||||
|
||||
/* Draws contour outlines or filled interiors on the image */
|
||||
CVAPI(void) cvDrawContours( CvArr *img, CvSeq* contour,
|
||||
CvScalar external_color, CvScalar hole_color,
|
||||
int max_level, int thickness CV_DEFAULT(1),
|
||||
int line_type CV_DEFAULT(8),
|
||||
CvPoint offset CV_DEFAULT(cvPoint(0,0)));
|
||||
|
||||
/* Does look-up transformation. Elements of the source array
|
||||
(that should be 8uC1 or 8sC1) are used as indexes in lutarr 256-element table */
|
||||
|
111
modules/core/include/opencv2/core/optim.hpp
Normal file
111
modules/core/include/opencv2/core/optim.hpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the OpenCV Foundation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OPTIM_HPP__
|
||||
#define __OPENCV_OPTIM_HPP__
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
class CV_EXPORTS MinProblemSolver : public Algorithm
|
||||
{
|
||||
public:
|
||||
class CV_EXPORTS Function
|
||||
{
|
||||
public:
|
||||
virtual ~Function() {}
|
||||
virtual double calc(const double* x) const = 0;
|
||||
virtual void getGradient(const double* /*x*/,double* /*grad*/) {}
|
||||
};
|
||||
|
||||
virtual Ptr<Function> getFunction() const = 0;
|
||||
virtual void setFunction(const Ptr<Function>& f) = 0;
|
||||
|
||||
virtual TermCriteria getTermCriteria() const = 0;
|
||||
virtual void setTermCriteria(const TermCriteria& termcrit) = 0;
|
||||
|
||||
// x contain the initial point before the call and the minima position (if algorithm converged) after. x is assumed to be (something that
|
||||
// after getMat() will return) row-vector or column-vector. *It's size and should
|
||||
// be consisted with previous dimensionality data given, if any (otherwise, it determines dimensionality)*
|
||||
virtual double minimize(InputOutputArray x) = 0;
|
||||
};
|
||||
|
||||
//! downhill simplex class
|
||||
class CV_EXPORTS DownhillSolver : public MinProblemSolver
|
||||
{
|
||||
public:
|
||||
//! returns row-vector, even if the column-vector was given
|
||||
virtual void getInitStep(OutputArray step) const=0;
|
||||
//!This should be called at least once before the first call to minimize() and step is assumed to be (something that
|
||||
//! after getMat() will return) row-vector or column-vector. *It's dimensionality determines the dimensionality of a problem.*
|
||||
virtual void setInitStep(InputArray step)=0;
|
||||
|
||||
// both minRange & minError are specified by termcrit.epsilon;
|
||||
// In addition, user may specify the number of iterations that the algorithm does.
|
||||
static Ptr<DownhillSolver> create(const Ptr<MinProblemSolver::Function>& f=Ptr<MinProblemSolver::Function>(),
|
||||
InputArray initStep=Mat_<double>(1,1,0.0),
|
||||
TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS,5000,0.000001));
|
||||
};
|
||||
|
||||
//! conjugate gradient method
|
||||
class CV_EXPORTS ConjGradSolver : public MinProblemSolver
|
||||
{
|
||||
public:
|
||||
static Ptr<ConjGradSolver> create(const Ptr<MinProblemSolver::Function>& f=Ptr<ConjGradSolver::Function>(),
|
||||
TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS,5000,0.000001));
|
||||
};
|
||||
|
||||
//!the return codes for solveLP() function
|
||||
enum
|
||||
{
|
||||
SOLVELP_UNBOUNDED = -2, //problem is unbounded (target function can achieve arbitrary high values)
|
||||
SOLVELP_UNFEASIBLE = -1, //problem is unfeasible (there are no points that satisfy all the constraints imposed)
|
||||
SOLVELP_SINGLE = 0, //there is only one maximum for target function
|
||||
SOLVELP_MULTI = 1 //there are multiple maxima for target function - the arbitrary one is returned
|
||||
};
|
||||
|
||||
CV_EXPORTS_W int solveLP(const Mat& Func, const Mat& Constr, Mat& z);
|
||||
|
||||
}// cv
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user