Skip to content
This repository has been archived by the owner on Mar 22, 2020. It is now read-only.

Commit

Permalink
Merge branch 'android.fix' into hunter-3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslo committed Jun 17, 2015
2 parents 9cd2a86 + 0fcc5fa commit 2b98d39
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 36 deletions.
29 changes: 22 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF
OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_OPENMP "Include OpenMP support" OFF)
OCV_OPTION(WITH_CSTRIPES "Include C= support" OFF IF (WIN32 AND NOT WINRT) )
OCV_OPTION(WITH_PTHREADS_PF "Use pthreads-based parallel_for" OFF IF (NOT WIN32) )
OCV_OPTION(WITH_PTHREADS_PF "Use pthreads-based parallel_for" ON IF (NOT WIN32) )
OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) )
OCV_OPTION(WITH_UNICAP "Include Unicap support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT ANDROID) )
Expand Down Expand Up @@ -1037,6 +1037,27 @@ if(DEFINED WITH_GPHOTO2)
endif(DEFINED WITH_GPHOTO2)


# Order is similar to CV_PARALLEL_FRAMEWORK in core/src/parallel.cpp
ocv_clear_vars(CV_PARALLEL_FRAMEWORK)
if(HAVE_TBB)
set(CV_PARALLEL_FRAMEWORK "TBB (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})")
elseif(HAVE_CSTRIPES)
set(CV_PARALLEL_FRAMEWORK "C=")
elseif(HAVE_OPENMP)
set(CV_PARALLEL_FRAMEWORK "OpenMP")
elseif(HAVE_GCD)
set(CV_PARALLEL_FRAMEWORK "GCD")
elseif(WINRT OR HAVE_CONCURRENCY)
set(CV_PARALLEL_FRAMEWORK "Concurrency")
elseif(HAVE_PTHREADS_PF)
set(CV_PARALLEL_FRAMEWORK "pthreads")
else()
set(CV_PARALLEL_FRAMEWORK "none")
endif()
status("")
status(" Parallel framework:" TRUE THEN "${CV_PARALLEL_FRAMEWORK}" ELSE NO)


# ========================== Other third-party libraries ==========================
status("")
status(" Other third-party libraries:")
Expand All @@ -1056,12 +1077,6 @@ status(" Use IPP Async:" HAVE_IPP_A THEN "YES" ELSE NO)
endif(DEFINED WITH_IPP_A)

status(" Use Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO)
status(" Use TBB:" HAVE_TBB THEN "YES (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})" ELSE NO)
status(" Use OpenMP:" HAVE_OPENMP THEN YES ELSE NO)
status(" Use GCD" HAVE_GCD THEN YES ELSE NO)
status(" Use Concurrency" HAVE_CONCURRENCY THEN YES ELSE NO)
status(" Use C=:" HAVE_CSTRIPES THEN YES ELSE NO)
status(" Use pthreads for parallel for:" HAVE_PTHREADS_PF THEN YES ELSE NO)
status(" Use Cuda:" HAVE_CUDA THEN "YES (ver ${CUDA_VERSION_STRING})" ELSE NO)
status(" Use OpenCL:" HAVE_OPENCL THEN YES ELSE NO)

Expand Down
14 changes: 9 additions & 5 deletions cmake/OpenCVFindLibsPerf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,16 @@ if(WITH_OPENMP)
set(HAVE_OPENMP "${OPENMP_FOUND}")
endif()

if(UNIX OR ANDROID)
if(NOT APPLE AND NOT HAVE_TBB AND NOT HAVE_OPENMP)
set(HAVE_PTHREADS_PF 1)
else()
set(HAVE_PTHREADS_PF 0)
if(NOT MSVC AND NOT DEFINED HAVE_PTHREADS)
set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/pthread_test.cpp")
file(WRITE "${_fname}" "#include <pthread.h>\nint main() { (void)pthread_self(); return 0; }\n")
try_compile(HAVE_PTHREADS "${CMAKE_BINARY_DIR}" "${_fname}")
file(REMOVE "${_fname}")
endif()

ocv_clear_vars(HAVE_PTHREADS_PF)
if(WITH_PTHREADS_PF)
set(HAVE_PTHREADS_PF ${HAVE_PTHREADS})
else()
set(HAVE_PTHREADS_PF 0)
endif()
6 changes: 6 additions & 0 deletions cmake/templates/cvconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@
/* PNG codec */
#cmakedefine HAVE_PNG

/* Posix threads (pthreads) */
#cmakedefine HAVE_PTHREADS

/* parallel_for with pthreads */
#cmakedefine HAVE_PTHREADS_PF

/* Qt support */
#cmakedefine HAVE_QT

Expand Down
6 changes: 4 additions & 2 deletions modules/calib3d/src/calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,7 @@ void cvStereoRectify( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2,
for( k = 0; k < 2; k++ ) {
const CvMat* A = k == 0 ? _cameraMatrix1 : _cameraMatrix2;
const CvMat* Dk = k == 0 ? _distCoeffs1 : _distCoeffs2;
double dk1 = Dk ? cvmGet(Dk, 0, 0) : 0;
double dk1 = Dk && Dk->data.ptr ? cvmGet(Dk, 0, 0) : 0;
double fc = cvmGet(A,idx^1,idx^1);
if( dk1 < 0 ) {
fc *= 1 + dk1*(nx*nx + ny*ny)/(4*fc*fc);
Expand Down Expand Up @@ -3372,7 +3372,9 @@ void cv::stereoRectify( InputArray _cameraMatrix1, InputArray _distCoeffs1,
p_Q = &(c_Q = _Qmat.getMat());
}

cvStereoRectify( &c_cameraMatrix1, &c_cameraMatrix2, &c_distCoeffs1, &c_distCoeffs2,
CvMat *p_distCoeffs1 = distCoeffs1.empty() ? NULL : &c_distCoeffs1;
CvMat *p_distCoeffs2 = distCoeffs2.empty() ? NULL : &c_distCoeffs2;
cvStereoRectify( &c_cameraMatrix1, &c_cameraMatrix2, p_distCoeffs1, p_distCoeffs2,
imageSize, &c_R, &c_T, &c_R1, &c_R2, &c_P1, &c_P2, p_Q, flags, alpha,
newImageSize, (CvRect*)validPixROI1, (CvRect*)validPixROI2);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/core/include/opencv2/core/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#define CV_VERSION_MAJOR 3
#define CV_VERSION_MINOR 0
#define CV_VERSION_REVISION 0
#define CV_VERSION_STATUS ""
#define CV_VERSION_STATUS "-dev"

#define CVAUX_STR_EXP(__A) #__A
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
Expand Down
23 changes: 14 additions & 9 deletions modules/core/src/parallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
4. HAVE_GCD - system wide, used automatically (APPLE only)
5. WINRT - system wide, used automatically (Windows RT only)
6. HAVE_CONCURRENCY - part of runtime, used automatically (Windows only - MSVS 10, MSVS 11)
7. HAVE_PTHREADS_PF - pthreads if available
*/

#if defined HAVE_TBB
Expand Down Expand Up @@ -125,15 +126,21 @@
# define CV_PARALLEL_FRAMEWORK "winrt-concurrency"
#elif defined HAVE_CONCURRENCY
# define CV_PARALLEL_FRAMEWORK "ms-concurrency"
#elif defined HAVE_PTHREADS
#elif defined HAVE_PTHREADS_PF
# define CV_PARALLEL_FRAMEWORK "pthreads"
#endif

namespace cv
{
ParallelLoopBody::~ParallelLoopBody() {}
#ifdef HAVE_PTHREADS_PF
void parallel_for_pthreads(const cv::Range& range, const cv::ParallelLoopBody& body, double nstripes);
size_t parallel_pthreads_get_threads_num();
void parallel_pthreads_set_threads_num(int num);
#endif
}


namespace
{
#ifdef CV_PARALLEL_FRAMEWORK
Expand Down Expand Up @@ -300,8 +307,8 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
Concurrency::CurrentScheduler::Detach();
}

#elif defined HAVE_PTHREADS
void parallel_for_pthreads(const Range& range, const ParallelLoopBody& body, double nstripes);
#elif defined HAVE_PTHREADS_PF

parallel_for_pthreads(range, body, nstripes);

#else
Expand Down Expand Up @@ -359,9 +366,7 @@ int cv::getNumThreads(void)
? Concurrency::CurrentScheduler::Get()->GetNumberOfVirtualProcessors()
: pplScheduler->GetNumberOfVirtualProcessors());

#elif defined HAVE_PTHREADS

size_t parallel_pthreads_get_threads_num();
#elif defined HAVE_PTHREADS_PF

return parallel_pthreads_get_threads_num();

Expand Down Expand Up @@ -422,9 +427,7 @@ void cv::setNumThreads( int threads )
Concurrency::MaxConcurrency, threads-1));
}

#elif defined HAVE_PTHREADS

void parallel_pthreads_set_threads_num(int num);
#elif defined HAVE_PTHREADS_PF

parallel_pthreads_set_threads_num(threads);

Expand All @@ -450,6 +453,8 @@ int cv::getThreadNum(void)
return 0;
#elif defined HAVE_CONCURRENCY
return std::max(0, (int)Concurrency::Context::VirtualProcessorId()); // zero for master thread, unique number for others but not necessary 1,2,3,...
#elif defined HAVE_PTHREADS_PF
return (int)(size_t)(void*)pthread_self(); // no zero-based indexing
#else
return 0;
#endif
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/parallel_pthreads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

#include "precomp.hpp"

#if defined HAVE_PTHREADS && HAVE_PTHREADS
#ifdef HAVE_PTHREADS_PF

#include <algorithm>
#include <pthread.h>
Expand Down
6 changes: 0 additions & 6 deletions modules/core/src/precomp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,6 @@ TLSData<CoreTLSData>& getCoreTlsData();
#define CL_RUNTIME_EXPORT
#endif

#ifndef HAVE_PTHREADS
#if !(defined WIN32 || defined _WIN32 || defined WINCE || defined HAVE_WINRT)
#define HAVE_PTHREADS 1
#endif
#endif

extern bool __termination; // skip some cleanups, because process is terminating
// (for example, if ExitProcess() was already called)

Expand Down
8 changes: 6 additions & 2 deletions modules/imgproc/include/opencv2/imgproc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,7 @@ See the line detection example below:
#include <opencv2/highgui.hpp>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
Expand Down Expand Up @@ -1774,18 +1775,19 @@ Example: :
#include <math.h>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
Mat img, gray;
if( argc != 2 && !(img=imread(argv[1], 1)).data)
if( argc != 2 || !(img=imread(argv[1], 1)).data)
return -1;
cvtColor(img, gray, COLOR_BGR2GRAY);
// smooth it, otherwise a lot of false circles may be detected
GaussianBlur( gray, gray, Size(9, 9), 2, 2 );
vector<Vec3f> circles;
HoughCircles(gray, circles, HOUGH_GRADIENT,
2, gray->rows/4, 200, 100 );
2, gray.rows/4, 200, 100 );
for( size_t i = 0; i < circles.size(); i++ )
{
Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
Expand All @@ -1797,6 +1799,8 @@ Example: :
}
namedWindow( "circles", 1 );
imshow( "circles", img );
waitKey(0);
return 0;
}
@endcode
Expand Down
6 changes: 3 additions & 3 deletions modules/imgproc/src/distransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ static void getDistanceTransformMask( int maskType, float *metrics )
metrics[2] = 2.1969f;
break;
default:
CV_Error(CV_StsBadArg, "Uknown metric type");
CV_Error(CV_StsBadArg, "Unknown metric type");
}
}

Expand Down Expand Up @@ -662,7 +662,7 @@ distanceATS_L1_8u( const Mat& src, Mat& dst )

// do right edge
a = lut[dbase[width-1+dststep]];
dbase[width-1] = (uchar)(MIN(a, dbase[width-1]));
a = dbase[width-1] = (uchar)(MIN(a, dbase[width-1]));

for( x = width - 2; x >= 0; x-- )
{
Expand Down Expand Up @@ -730,7 +730,7 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe
float _mask[5] = {0};

if( maskSize != CV_DIST_MASK_3 && maskSize != CV_DIST_MASK_5 && maskSize != CV_DIST_MASK_PRECISE )
CV_Error( CV_StsBadSize, "Mask size should be 3 or 5 or 0 (presize)" );
CV_Error( CV_StsBadSize, "Mask size should be 3 or 5 or 0 (precise)" );

if( distType == CV_DIST_C || distType == CV_DIST_L1 )
maskSize = !need_labels ? CV_DIST_MASK_3 : CV_DIST_MASK_5;
Expand Down
2 changes: 2 additions & 0 deletions modules/java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ else()
set(LIB_NAME_SUFIX "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}")
endif()

file(MAKE_DIRECTORY "${OpenCV_BINARY_DIR}/bin")

# step 4: build jar
if(ANDROID)
set(JAR_FILE "${OpenCV_BINARY_DIR}/bin/classes.jar")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#ifndef __OPENCV_OBJDETECT_DBT_HPP__
#define __OPENCV_OBJDETECT_DBT_HPP__

// After this condition removal update blacklist for bindings: modules/python/common.cmake
#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(__ANDROID__) || \
(defined(__cplusplus) && __cplusplus > 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1700)

Expand Down
1 change: 1 addition & 0 deletions modules/python/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ endforeach(m)
ocv_list_filterout(opencv_hdrs ".h$")
ocv_list_filterout(opencv_hdrs "cuda")
ocv_list_filterout(opencv_hdrs "cudev")
ocv_list_filterout(opencv_hdrs "detection_based_tracker.hpp") # Conditional compilation

set(cv2_generated_hdrs
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_include.h"
Expand Down
Binary file added samples/data/aloeGT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2b98d39

Please sign in to comment.