Skip to content

Commit f41b8b9

Browse files
committed
Blank module and first draft of solver API.
At this point we have a skeleton of a new module (optim) which can barely compile properly (unlike previous commit). Besides, there is a first draft of solver and lpsolver (linear optimization solver) in this commit.
1 parent f2afe64 commit f41b8b9

18 files changed

+80
-592
lines changed

modules/optim/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
set(the_description "Generic optimization")
2-
ocv_define_module(optim)
2+
ocv_define_module(optim opencv_imgproc)
3+
#ocv_define_module(optim core)

modules/optim/doc/denoising.rst

-91
This file was deleted.

modules/optim/doc/inpainting.rst

-32
This file was deleted.

modules/optim/doc/photo.rst

-11
This file was deleted.

modules/optim/include/opencv2/photo.hpp renamed to modules/optim/include/opencv2/optim.hpp

+26-25
Original file line numberDiff line numberDiff line change
@@ -40,46 +40,47 @@
4040
//
4141
//M*/
4242

43-
#ifndef __OPENCV_PHOTO_HPP__
44-
#define __OPENCV_PHOTO_HPP__
43+
#ifndef __OPENCV_OPTIM_HPP__
44+
#define __OPENCV_OPTIM_HPP__
4545

4646
#include "opencv2/core.hpp"
47-
#include "opencv2/imgproc.hpp"
47+
#include "opencv2/core/mat.hpp"
4848

4949
/*! \namespace cv
5050
Namespace where all the C++ OpenCV functionality resides
5151
*/
5252
namespace cv
5353
{
5454

55-
//! the inpainting algorithm
56-
enum
55+
/* //! restores the damaged image areas using one of the available intpainting algorithms */
56+
class Solver : public Algorithm /* Algorithm is the base OpenCV class */
5757
{
58-
INPAINT_NS = 0, // Navier-Stokes algorithm
59-
INPAINT_TELEA = 1 // A. Telea algorithm
60-
};
61-
62-
//! restores the damaged image areas using one of the available intpainting algorithms
63-
CV_EXPORTS_W void inpaint( InputArray src, InputArray inpaintMask,
64-
OutputArray dst, double inpaintRadius, int flags );
58+
class Function
59+
{
60+
public:
61+
virtual ~Function();
62+
virtual double calc(InputArray args) const = 0;
63+
//virtual double calc(InputArray args, OutputArray grad) const = 0;
64+
};
6565

66+
// could be reused for all the generic algorithms like downhill simplex.
67+
virtual void solve(InputArray x0, OutputArray result) const = 0;
6668

67-
CV_EXPORTS_W void fastNlMeansDenoising( InputArray src, OutputArray dst, float h = 3,
68-
int templateWindowSize = 7, int searchWindowSize = 21);
69+
virtual void setTermCriteria(const TermCriteria& criteria) = 0;
70+
virtual TermCriteria getTermCriteria() = 0;
6971

70-
CV_EXPORTS_W void fastNlMeansDenoisingColored( InputArray src, OutputArray dst,
71-
float h = 3, float hColor = 3,
72-
int templateWindowSize = 7, int searchWindowSize = 21);
72+
// more detailed API to be defined later ...
7373

74-
CV_EXPORTS_W void fastNlMeansDenoisingMulti( InputArrayOfArrays srcImgs, OutputArray dst,
75-
int imgToDenoiseIndex, int temporalWindowSize,
76-
float h = 3, int templateWindowSize = 7, int searchWindowSize = 21);
74+
};
7775

78-
CV_EXPORTS_W void fastNlMeansDenoisingColoredMulti( InputArrayOfArrays srcImgs, OutputArray dst,
79-
int imgToDenoiseIndex, int temporalWindowSize,
80-
float h = 3, float hColor = 3,
81-
int templateWindowSize = 7, int searchWindowSize = 21);
76+
class LPSolver : public Solver
77+
{
78+
public:
79+
virtual void solve(InputArray coeffs, InputArray constraints, OutputArray result) const = 0;
80+
// ...
81+
};
8282

83-
} // cv
83+
Ptr<LPSolver> createLPSimplexSolver();
84+
}// cv
8485

8586
#endif

modules/optim/include/opencv2/photo/photo.hpp renamed to modules/optim/include/opencv2/optim/optim.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@
4545
#error this is a compatibility header which should not be used inside the OpenCV library
4646
#endif
4747

48-
#include "opencv2/photo.hpp"
48+
#include "opencv2/optim.hpp"

modules/optim/perf/perf_inpaint.cpp

-38
This file was deleted.

modules/optim/perf/perf_main.cpp

-3
This file was deleted.

modules/optim/perf/perf_precomp.cpp

-1
This file was deleted.

modules/optim/perf/perf_precomp.hpp

-20
This file was deleted.

modules/optim/src/lpsolver.cpp

+2-45
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,2 @@
1-
#include "opencv2/opencv.hpp"
2-
3-
namespace cv {
4-
namespace optim {
5-
6-
class Solver : public Algorithm /* Algorithm is base OpenCV class */
7-
{
8-
class Function
9-
{
10-
public:
11-
virtual ~Function() {}
12-
virtual double calc(InputArray args) const = 0;
13-
virtual double calc(InputArgs, OutputArray grad) const = 0;
14-
};
15-
16-
// could be reused for all the generic algorithms like downhill simplex.
17-
virtual void solve(InputArray x0, OutputArray result) const = 0;
18-
19-
virtual void setTermCriteria(const TermCriteria& criteria) = 0;
20-
virtual TermCriteria getTermCriteria() = 0;
21-
22-
// more detailed API to be defined later ...
23-
};
24-
25-
class LPSolver : public Solver
26-
{
27-
public:
28-
virtual void solve(InputArray coeffs, InputArray constraints, OutputArray result) const = 0;
29-
// ...
30-
};
31-
32-
Ptr<LPSolver> createLPSimplexSolver();
33-
34-
}}
35-
36-
/*===============
37-
Hill climbing solver is more generic one:*/
38-
/*
39-
class DownhillSolver : public Solver
40-
{
41-
public:
42-
// various setters and getters, if needed
43-
};
44-
45-
Ptr<DownhillSolver> createDownhillSolver(const Ptr<Solver::Function>& func);*/
1+
#include "precomp.hpp"
2+
#include "opencv2/optim.hpp"

modules/optim/src/precomp.cpp

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*M///////////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4+
//
5+
// By downloading, copying, installing or using the software you agree to this license.
6+
// If you do not agree to this license, do not download, install,
7+
// copy or use the software.
8+
//
9+
//
10+
// Intel License Agreement
11+
// For Open Source Computer Vision Library
12+
//
13+
// Copyright (C) 2000, Intel Corporation, all rights reserved.
14+
// Third party copyrights are property of their respective owners.
15+
//
16+
// Redistribution and use in source and binary forms, with or without modification,
17+
// are permitted provided that the following conditions are met:
18+
//
19+
// * Redistribution's of source code must retain the above copyright notice,
20+
// this list of conditions and the following disclaimer.
21+
//
22+
// * Redistribution's in binary form must reproduce the above copyright notice,
23+
// this list of conditions and the following disclaimer in the documentation
24+
// and/or other materials provided with the distribution.
25+
//
26+
// * The name of Intel Corporation may not be used to endorse or promote products
27+
// derived from this software without specific prior written permission.
28+
//
29+
// This software is provided by the copyright holders and contributors "as is" and
30+
// any express or implied warranties, including, but not limited to, the implied
31+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
32+
// In no event shall the Intel Corporation or contributors be liable for any direct,
33+
// indirect, incidental, special, exemplary, or consequential damages
34+
// (including, but not limited to, procurement of substitute goods or services;
35+
// loss of use, data, or profits; or business interruption) however caused
36+
// and on any theory of liability, whether in contract, strict liability,
37+
// or tort (including negligence or otherwise) arising in any way out of
38+
// the use of this software, even if advised of the possibility of such damage.
39+
//
40+
//M*/
41+
42+
#include "precomp.hpp"
43+
44+
/* End of file. */

0 commit comments

Comments
 (0)