Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated library exports #8198

Merged
merged 2 commits into from Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Expand Up @@ -29,6 +29,8 @@ else()
cmake_minimum_required(VERSION "${MIN_VER_CMAKE}" FATAL_ERROR)
endif()

set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

# Following block can break build in case of cross-compilng
# but CMAKE_CROSSCOMPILING variable will be set only on project(OpenCV) command
# so we will try to detect cross-compiling by presense of CMAKE_TOOLCHAIN_FILE
Expand Down Expand Up @@ -311,6 +313,7 @@ OCV_OPTION(ENABLE_IMPL_COLLECTION "Collect implementation data on function c
OCV_OPTION(ENABLE_INSTRUMENTATION "Instrument functions to collect calls trace and performance" OFF )
OCV_OPTION(ENABLE_GNU_STL_DEBUG "Enable GNU STL Debug mode (defines _GLIBCXX_DEBUG)" OFF IF ((NOT CMAKE_VERSION VERSION_LESS "2.8.11") AND CMAKE_COMPILER_IS_GNUCXX) )
OCV_OPTION(ENABLE_BUILD_HARDENING "Enable hardening of the resulting binaries (against security attacks, detects memory corruption, etc)" OFF)
OCV_OPTION(ENABLE_LTO "Enable Link Time Optimization" OFF IF CMAKE_COMPILER_IS_GNUCXX OR MSVC)
OCV_OPTION(GENERATE_ABI_DESCRIPTOR "Generate XML file for abi_compliance_checker tool" OFF IF UNIX)
OCV_OPTION(CV_ENABLE_INTRINSICS "Use intrinsic-based optimized code" ON )
OCV_OPTION(CV_DISABLE_OPTIMIZATION "Disable explicit optimized code (dispatched code/intrinsics/loop unrolling/etc)" OFF )
Expand Down
26 changes: 0 additions & 26 deletions apps/traincascade/old_ml.hpp
Expand Up @@ -1895,32 +1895,6 @@ class CvANN_MLP : public CvStatModel
cv::RNG* rng;
};

/****************************************************************************************\
* Auxilary functions declarations *
\****************************************************************************************/

/* Generates <sample> from multivariate normal distribution, where <mean> - is an
average row vector, <cov> - symmetric covariation matrix */
CVAPI(void) cvRandMVNormal( CvMat* mean, CvMat* cov, CvMat* sample,
CvRNG* rng CV_DEFAULT(0) );

/* Generates sample from gaussian mixture distribution */
CVAPI(void) cvRandGaussMixture( CvMat* means[],
CvMat* covs[],
float weights[],
int clsnum,
CvMat* sample,
CvMat* sampClasses CV_DEFAULT(0) );

#define CV_TS_CONCENTRIC_SPHERES 0

/* creates test set */
CVAPI(void) cvCreateTestSet( int type, CvMat** samples,
int num_samples,
int num_features,
CvMat** responses,
int num_classes, ... );

/****************************************************************************************\
* Data *
\****************************************************************************************/
Expand Down
191 changes: 0 additions & 191 deletions apps/traincascade/old_ml_inner_functions.cpp
Expand Up @@ -114,153 +114,11 @@ void CvStatModel::write( CvFileStorage*, const char* ) const
OPENCV_ERROR( CV_StsNotImplemented, "CvStatModel::write", "" );
}


void CvStatModel::read( CvFileStorage*, CvFileNode* )
{
OPENCV_ERROR( CV_StsNotImplemented, "CvStatModel::read", "" );
}


/* Calculates upper triangular matrix S, where A is a symmetrical matrix A=S'*S */
static void cvChol( CvMat* A, CvMat* S )
{
int dim = A->rows;

int i, j, k;
float sum;

for( i = 0; i < dim; i++ )
{
for( j = 0; j < i; j++ )
CV_MAT_ELEM(*S, float, i, j) = 0;

sum = 0;
for( k = 0; k < i; k++ )
sum += CV_MAT_ELEM(*S, float, k, i) * CV_MAT_ELEM(*S, float, k, i);

CV_MAT_ELEM(*S, float, i, i) = (float)sqrt(CV_MAT_ELEM(*A, float, i, i) - sum);

for( j = i + 1; j < dim; j++ )
{
sum = 0;
for( k = 0; k < i; k++ )
sum += CV_MAT_ELEM(*S, float, k, i) * CV_MAT_ELEM(*S, float, k, j);

CV_MAT_ELEM(*S, float, i, j) =
(CV_MAT_ELEM(*A, float, i, j) - sum) / CV_MAT_ELEM(*S, float, i, i);

}
}
}

/* Generates <sample> from multivariate normal distribution, where <mean> - is an
average row vector, <cov> - symmetric covariation matrix */
CV_IMPL void cvRandMVNormal( CvMat* mean, CvMat* cov, CvMat* sample, CvRNG* rng )
{
int dim = sample->cols;
int amount = sample->rows;

CvRNG state = rng ? *rng : cvRNG( cvGetTickCount() );
cvRandArr(&state, sample, CV_RAND_NORMAL, cvScalarAll(0), cvScalarAll(1) );

CvMat* utmat = cvCreateMat(dim, dim, sample->type);
CvMat* vect = cvCreateMatHeader(1, dim, sample->type);

cvChol(cov, utmat);

int i;
for( i = 0; i < amount; i++ )
{
cvGetRow(sample, vect, i);
cvMatMulAdd(vect, utmat, mean, vect);
}

cvReleaseMat(&vect);
cvReleaseMat(&utmat);
}


/* Generates <sample> of <amount> points from a discrete variate xi,
where Pr{xi = k} == probs[k], 0 < k < len - 1. */
static void cvRandSeries( float probs[], int len, int sample[], int amount )
{
CvMat* univals = cvCreateMat(1, amount, CV_32FC1);
float* knots = (float*)cvAlloc( len * sizeof(float) );

int i, j;

CvRNG state = cvRNG(-1);
cvRandArr(&state, univals, CV_RAND_UNI, cvScalarAll(0), cvScalarAll(1) );

knots[0] = probs[0];
for( i = 1; i < len; i++ )
knots[i] = knots[i - 1] + probs[i];

for( i = 0; i < amount; i++ )
for( j = 0; j < len; j++ )
{
if ( CV_MAT_ELEM(*univals, float, 0, i) <= knots[j] )
{
sample[i] = j;
break;
}
}

cvFree(&knots);
}

/* Generates <sample> from gaussian mixture distribution */
CV_IMPL void cvRandGaussMixture( CvMat* means[],
CvMat* covs[],
float weights[],
int clsnum,
CvMat* sample,
CvMat* sampClasses )
{
int dim = sample->cols;
int amount = sample->rows;

int i, clss;

int* sample_clsnum = (int*)cvAlloc( amount * sizeof(int) );
CvMat** utmats = (CvMat**)cvAlloc( clsnum * sizeof(CvMat*) );
CvMat* vect = cvCreateMatHeader(1, dim, CV_32FC1);

CvMat* classes;
if( sampClasses )
classes = sampClasses;
else
classes = cvCreateMat(1, amount, CV_32FC1);

CvRNG state = cvRNG(-1);
cvRandArr(&state, sample, CV_RAND_NORMAL, cvScalarAll(0), cvScalarAll(1));

cvRandSeries(weights, clsnum, sample_clsnum, amount);

for( i = 0; i < clsnum; i++ )
{
utmats[i] = cvCreateMat(dim, dim, CV_32FC1);
cvChol(covs[i], utmats[i]);
}

for( i = 0; i < amount; i++ )
{
CV_MAT_ELEM(*classes, float, 0, i) = (float)sample_clsnum[i];
cvGetRow(sample, vect, i);
clss = sample_clsnum[i];
cvMatMulAdd(vect, utmats[clss], means[clss], vect);
}

if( !sampClasses )
cvReleaseMat(&classes);
for( i = 0; i < clsnum; i++ )
cvReleaseMat(&utmats[i]);
cvFree(&utmats);
cvFree(&sample_clsnum);
cvReleaseMat(&vect);
}


CvMat* icvGenerateRandomClusterCenters ( int seed, const CvMat* data,
int num_of_clusters, CvMat* _centers )
{
Expand Down Expand Up @@ -317,55 +175,6 @@ CvMat* icvGenerateRandomClusterCenters ( int seed, const CvMat* data,
return _centers ? _centers : centers;
} // end of icvGenerateRandomClusterCenters

// By S. Dilman - begin -

#define ICV_RAND_MAX 4294967296 // == 2^32

// static void cvRandRoundUni (CvMat* center,
// float radius_small,
// float radius_large,
// CvMat* desired_matrix,
// CvRNG* rng_state_ptr)
// {
// float rad, norm, coefficient;
// int dim, size, i, j;
// CvMat *cov, sample;
// CvRNG rng_local;

// CV_FUNCNAME("cvRandRoundUni");
// __BEGIN__

// rng_local = *rng_state_ptr;

// CV_ASSERT ((radius_small >= 0) &&
// (radius_large > 0) &&
// (radius_small <= radius_large));
// CV_ASSERT (center && desired_matrix && rng_state_ptr);
// CV_ASSERT (center->rows == 1);
// CV_ASSERT (center->cols == desired_matrix->cols);

// dim = desired_matrix->cols;
// size = desired_matrix->rows;
// cov = cvCreateMat (dim, dim, CV_32FC1);
// cvSetIdentity (cov);
// cvRandMVNormal (center, cov, desired_matrix, &rng_local);

// for (i = 0; i < size; i++)
// {
// rad = (float)(cvRandReal(&rng_local)*(radius_large - radius_small) + radius_small);
// cvGetRow (desired_matrix, &sample, i);
// norm = (float) cvNorm (&sample, 0, CV_L2);
// coefficient = rad / norm;
// for (j = 0; j < dim; j++)
// CV_MAT_ELEM (sample, float, 0, j) *= coefficient;
// }

// __END__

// }

// By S. Dilman - end -

static int CV_CDECL
icvCmpIntegers( const void* a, const void* b )
{
Expand Down
2 changes: 1 addition & 1 deletion apps/traincascade/old_ml_tree.cpp
Expand Up @@ -1880,7 +1880,7 @@ double CvDTree::calc_node_dir( CvDTreeNode* node )
namespace cv
{

template<> CV_EXPORTS void DefaultDeleter<CvDTreeSplit>::operator ()(CvDTreeSplit* obj) const
template<> void DefaultDeleter<CvDTreeSplit>::operator ()(CvDTreeSplit* obj) const
{
fastFree(obj);
}
Expand Down
24 changes: 15 additions & 9 deletions cmake/OpenCVCompilerOptions.cmake
Expand Up @@ -178,10 +178,15 @@ if(CMAKE_COMPILER_IS_GNUCXX)
OPENCV_EXTRA_FLAGS_RELEASE OPENCV_EXTRA_FLAGS_DEBUG OPENCV_EXTRA_C_FLAGS OPENCV_EXTRA_CXX_FLAGS)
string(REPLACE "-fomit-frame-pointer" "" ${flags} "${${flags}}")
string(REPLACE "-ffunction-sections" "" ${flags} "${${flags}}")
string(REPLACE "-fdata-sections" "" ${flags} "${${flags}}")
endforeach()
elseif(NOT ((IOS OR ANDROID) AND NOT BUILD_SHARED_LIBS))
# Remove unreferenced functions: function level linking
add_extra_compiler_option(-ffunction-sections)
add_extra_compiler_option(-fdata-sections)
if(NOT APPLE AND NOT OPENCV_SKIP_GC_SECTIONS)
set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS} -Wl,--gc-sections")
endif()
endif()

if(ENABLE_COVERAGE)
Expand All @@ -195,6 +200,10 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set(WITH_VTK OFF) # There are issues with VTK 6.0
endif()

if(ENABLE_LTO)
add_extra_compiler_option(-flto)
endif()

set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} -DNDEBUG")
if(NOT " ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} " MATCHES "-O")
set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG} -O0")
Expand Down Expand Up @@ -229,6 +238,12 @@ if(MSVC)
if(OPENCV_WARNINGS_ARE_ERRORS)
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /WX")
endif()

if(ENABLE_LTO)
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /GL")
set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS} /LTCG")
endif()

endif()

if(MSVC12 AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
Expand All @@ -241,15 +256,6 @@ if(WINRT_PHONE AND WINRT_8_0)
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} /AI\$(WindowsSDK_MetadataPath)")
endif()

# Extra link libs if the user selects building static libs:
if(NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX AND NOT ANDROID)
# Android does not need these settings because they are already set by toolchain file
if(NOT MINGW)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} stdc++)
endif()
set(OPENCV_EXTRA_FLAGS "-fPIC ${OPENCV_EXTRA_FLAGS}")
endif()

include(cmake/OpenCVCompilerOptimizations.cmake)

if(COMMAND ocv_compiler_optimization_options)
Expand Down
11 changes: 5 additions & 6 deletions cmake/OpenCVModule.cmake
Expand Up @@ -852,7 +852,6 @@ macro(_ocv_create_module)
${${the_module}_pch}
${_VS_VERSION_FILE}
)

set_target_properties(${the_module} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};Module")
set_source_files_properties(${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES} ${${the_module}_pch}
PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};Module")
Expand All @@ -879,8 +878,13 @@ macro(_ocv_create_module)
COMPILE_PDB_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
DEFINE_SYMBOL CVAPI_EXPORTS
)

if(ANDROID AND BUILD_FAT_JAVA_LIB)
target_compile_definitions(${the_module} PRIVATE CVAPI_EXPORTS)
endif()

# For dynamic link numbering convenions
if(NOT ANDROID)
# Android SDK build scripts can include only .so files into final .apk
Expand All @@ -891,11 +895,6 @@ macro(_ocv_create_module)
)
endif()

if((NOT DEFINED OPENCV_MODULE_TYPE AND BUILD_SHARED_LIBS)
OR (DEFINED OPENCV_MODULE_TYPE AND OPENCV_MODULE_TYPE STREQUAL SHARED))
set_target_properties(${the_module} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS)
endif()

if (ENABLE_GNU_STL_DEBUG)
target_compile_definitions(${the_module} PUBLIC _GLIBCXX_DEBUG)
endif()
Expand Down
20 changes: 15 additions & 5 deletions modules/core/include/opencv2/core/cvdef.h
Expand Up @@ -248,12 +248,22 @@ Cv64suf;
# define DISABLE_OPENCV_24_COMPATIBILITY
#endif

#if (defined _WIN32 || defined WINCE || defined __CYGWIN__) && defined CVAPI_EXPORTS
# define CV_EXPORTS __declspec(dllexport)
#elif defined __GNUC__ && __GNUC__ >= 4
# define CV_EXPORTS __attribute__ ((visibility ("default")))
#ifdef CVAPI_EXPORTS
# if (defined _WIN32 || defined WINCE || defined __CYGWIN__)
# define CV_EXPORTS __declspec(dllexport)
# elif defined __GNUC__ && __GNUC__ >= 4
# define CV_EXPORTS __attribute__ ((visibility ("default")))
# endif
#endif

#ifndef CV_EXPORTS
# define CV_EXPORTS
#endif

#ifdef _MSC_VER
# define CV_EXPORTS_TEMPLATE
#else
# define CV_EXPORTS
# define CV_EXPORTS_TEMPLATE CV_EXPORTS
#endif

#ifndef CV_DEPRECATED
Expand Down
2 changes: 1 addition & 1 deletion modules/core/include/opencv2/core/private.hpp
Expand Up @@ -162,7 +162,7 @@ CV_EXPORTS void scalarToRawData(const cv::Scalar& s, void* buf, int type, int un

//! Allocate all memory buffers which will not be freed, ease filtering memcheck issues
template <typename T>
CV_EXPORTS T* allocSingleton(size_t count) { return static_cast<T*>(fastMalloc(sizeof(T) * count)); }
T* allocSingleton(size_t count) { return static_cast<T*>(fastMalloc(sizeof(T) * count)); }
}

// property implementation macros
Expand Down