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

Commit 2b98d39

Browse files
committed
Merge branch 'android.fix' into hunter-3.0.0
2 parents 9cd2a86 + 0fcc5fa commit 2b98d39

File tree

14 files changed

+70
-36
lines changed

14 files changed

+70
-36
lines changed

CMakeLists.txt

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF
199199
OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS AND NOT WINRT) )
200200
OCV_OPTION(WITH_OPENMP "Include OpenMP support" OFF)
201201
OCV_OPTION(WITH_CSTRIPES "Include C= support" OFF IF (WIN32 AND NOT WINRT) )
202-
OCV_OPTION(WITH_PTHREADS_PF "Use pthreads-based parallel_for" OFF IF (NOT WIN32) )
202+
OCV_OPTION(WITH_PTHREADS_PF "Use pthreads-based parallel_for" ON IF (NOT WIN32) )
203203
OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) )
204204
OCV_OPTION(WITH_UNICAP "Include Unicap support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
205205
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT ANDROID) )
@@ -1037,6 +1037,27 @@ if(DEFINED WITH_GPHOTO2)
10371037
endif(DEFINED WITH_GPHOTO2)
10381038

10391039

1040+
# Order is similar to CV_PARALLEL_FRAMEWORK in core/src/parallel.cpp
1041+
ocv_clear_vars(CV_PARALLEL_FRAMEWORK)
1042+
if(HAVE_TBB)
1043+
set(CV_PARALLEL_FRAMEWORK "TBB (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})")
1044+
elseif(HAVE_CSTRIPES)
1045+
set(CV_PARALLEL_FRAMEWORK "C=")
1046+
elseif(HAVE_OPENMP)
1047+
set(CV_PARALLEL_FRAMEWORK "OpenMP")
1048+
elseif(HAVE_GCD)
1049+
set(CV_PARALLEL_FRAMEWORK "GCD")
1050+
elseif(WINRT OR HAVE_CONCURRENCY)
1051+
set(CV_PARALLEL_FRAMEWORK "Concurrency")
1052+
elseif(HAVE_PTHREADS_PF)
1053+
set(CV_PARALLEL_FRAMEWORK "pthreads")
1054+
else()
1055+
set(CV_PARALLEL_FRAMEWORK "none")
1056+
endif()
1057+
status("")
1058+
status(" Parallel framework:" TRUE THEN "${CV_PARALLEL_FRAMEWORK}" ELSE NO)
1059+
1060+
10401061
# ========================== Other third-party libraries ==========================
10411062
status("")
10421063
status(" Other third-party libraries:")
@@ -1056,12 +1077,6 @@ status(" Use IPP Async:" HAVE_IPP_A THEN "YES" ELSE NO)
10561077
endif(DEFINED WITH_IPP_A)
10571078

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

cmake/OpenCVFindLibsPerf.cmake

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,16 @@ if(WITH_OPENMP)
120120
set(HAVE_OPENMP "${OPENMP_FOUND}")
121121
endif()
122122

123-
if(UNIX OR ANDROID)
124-
if(NOT APPLE AND NOT HAVE_TBB AND NOT HAVE_OPENMP)
125-
set(HAVE_PTHREADS_PF 1)
126-
else()
127-
set(HAVE_PTHREADS_PF 0)
123+
if(NOT MSVC AND NOT DEFINED HAVE_PTHREADS)
124+
set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/pthread_test.cpp")
125+
file(WRITE "${_fname}" "#include <pthread.h>\nint main() { (void)pthread_self(); return 0; }\n")
126+
try_compile(HAVE_PTHREADS "${CMAKE_BINARY_DIR}" "${_fname}")
127+
file(REMOVE "${_fname}")
128128
endif()
129+
130+
ocv_clear_vars(HAVE_PTHREADS_PF)
131+
if(WITH_PTHREADS_PF)
132+
set(HAVE_PTHREADS_PF ${HAVE_PTHREADS})
129133
else()
130134
set(HAVE_PTHREADS_PF 0)
131135
endif()

cmake/templates/cvconfig.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@
139139
/* PNG codec */
140140
#cmakedefine HAVE_PNG
141141

142+
/* Posix threads (pthreads) */
143+
#cmakedefine HAVE_PTHREADS
144+
145+
/* parallel_for with pthreads */
146+
#cmakedefine HAVE_PTHREADS_PF
147+
142148
/* Qt support */
143149
#cmakedefine HAVE_QT
144150

modules/calib3d/src/calibration.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,7 @@ void cvStereoRectify( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2,
21942194
for( k = 0; k < 2; k++ ) {
21952195
const CvMat* A = k == 0 ? _cameraMatrix1 : _cameraMatrix2;
21962196
const CvMat* Dk = k == 0 ? _distCoeffs1 : _distCoeffs2;
2197-
double dk1 = Dk ? cvmGet(Dk, 0, 0) : 0;
2197+
double dk1 = Dk && Dk->data.ptr ? cvmGet(Dk, 0, 0) : 0;
21982198
double fc = cvmGet(A,idx^1,idx^1);
21992199
if( dk1 < 0 ) {
22002200
fc *= 1 + dk1*(nx*nx + ny*ny)/(4*fc*fc);
@@ -3372,7 +3372,9 @@ void cv::stereoRectify( InputArray _cameraMatrix1, InputArray _distCoeffs1,
33723372
p_Q = &(c_Q = _Qmat.getMat());
33733373
}
33743374

3375-
cvStereoRectify( &c_cameraMatrix1, &c_cameraMatrix2, &c_distCoeffs1, &c_distCoeffs2,
3375+
CvMat *p_distCoeffs1 = distCoeffs1.empty() ? NULL : &c_distCoeffs1;
3376+
CvMat *p_distCoeffs2 = distCoeffs2.empty() ? NULL : &c_distCoeffs2;
3377+
cvStereoRectify( &c_cameraMatrix1, &c_cameraMatrix2, p_distCoeffs1, p_distCoeffs2,
33763378
imageSize, &c_R, &c_T, &c_R1, &c_R2, &c_P1, &c_P2, p_Q, flags, alpha,
33773379
newImageSize, (CvRect*)validPixROI1, (CvRect*)validPixROI2);
33783380
}

modules/core/include/opencv2/core/version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#define CV_VERSION_MAJOR 3
5454
#define CV_VERSION_MINOR 0
5555
#define CV_VERSION_REVISION 0
56-
#define CV_VERSION_STATUS ""
56+
#define CV_VERSION_STATUS "-dev"
5757

5858
#define CVAUX_STR_EXP(__A) #__A
5959
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)

modules/core/src/parallel.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
4. HAVE_GCD - system wide, used automatically (APPLE only)
8181
5. WINRT - system wide, used automatically (Windows RT only)
8282
6. HAVE_CONCURRENCY - part of runtime, used automatically (Windows only - MSVS 10, MSVS 11)
83+
7. HAVE_PTHREADS_PF - pthreads if available
8384
*/
8485

8586
#if defined HAVE_TBB
@@ -125,15 +126,21 @@
125126
# define CV_PARALLEL_FRAMEWORK "winrt-concurrency"
126127
#elif defined HAVE_CONCURRENCY
127128
# define CV_PARALLEL_FRAMEWORK "ms-concurrency"
128-
#elif defined HAVE_PTHREADS
129+
#elif defined HAVE_PTHREADS_PF
129130
# define CV_PARALLEL_FRAMEWORK "pthreads"
130131
#endif
131132

132133
namespace cv
133134
{
134135
ParallelLoopBody::~ParallelLoopBody() {}
136+
#ifdef HAVE_PTHREADS_PF
137+
void parallel_for_pthreads(const cv::Range& range, const cv::ParallelLoopBody& body, double nstripes);
138+
size_t parallel_pthreads_get_threads_num();
139+
void parallel_pthreads_set_threads_num(int num);
140+
#endif
135141
}
136142

143+
137144
namespace
138145
{
139146
#ifdef CV_PARALLEL_FRAMEWORK
@@ -300,8 +307,8 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
300307
Concurrency::CurrentScheduler::Detach();
301308
}
302309

303-
#elif defined HAVE_PTHREADS
304-
void parallel_for_pthreads(const Range& range, const ParallelLoopBody& body, double nstripes);
310+
#elif defined HAVE_PTHREADS_PF
311+
305312
parallel_for_pthreads(range, body, nstripes);
306313

307314
#else
@@ -359,9 +366,7 @@ int cv::getNumThreads(void)
359366
? Concurrency::CurrentScheduler::Get()->GetNumberOfVirtualProcessors()
360367
: pplScheduler->GetNumberOfVirtualProcessors());
361368

362-
#elif defined HAVE_PTHREADS
363-
364-
size_t parallel_pthreads_get_threads_num();
369+
#elif defined HAVE_PTHREADS_PF
365370

366371
return parallel_pthreads_get_threads_num();
367372

@@ -422,9 +427,7 @@ void cv::setNumThreads( int threads )
422427
Concurrency::MaxConcurrency, threads-1));
423428
}
424429

425-
#elif defined HAVE_PTHREADS
426-
427-
void parallel_pthreads_set_threads_num(int num);
430+
#elif defined HAVE_PTHREADS_PF
428431

429432
parallel_pthreads_set_threads_num(threads);
430433

@@ -450,6 +453,8 @@ int cv::getThreadNum(void)
450453
return 0;
451454
#elif defined HAVE_CONCURRENCY
452455
return std::max(0, (int)Concurrency::Context::VirtualProcessorId()); // zero for master thread, unique number for others but not necessary 1,2,3,...
456+
#elif defined HAVE_PTHREADS_PF
457+
return (int)(size_t)(void*)pthread_self(); // no zero-based indexing
453458
#else
454459
return 0;
455460
#endif

modules/core/src/parallel_pthreads.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
#include "precomp.hpp"
4444

45-
#if defined HAVE_PTHREADS && HAVE_PTHREADS
45+
#ifdef HAVE_PTHREADS_PF
4646

4747
#include <algorithm>
4848
#include <pthread.h>

modules/core/src/precomp.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,6 @@ TLSData<CoreTLSData>& getCoreTlsData();
292292
#define CL_RUNTIME_EXPORT
293293
#endif
294294

295-
#ifndef HAVE_PTHREADS
296-
#if !(defined WIN32 || defined _WIN32 || defined WINCE || defined HAVE_WINRT)
297-
#define HAVE_PTHREADS 1
298-
#endif
299-
#endif
300-
301295
extern bool __termination; // skip some cleanups, because process is terminating
302296
// (for example, if ExitProcess() was already called)
303297

modules/imgproc/include/opencv2/imgproc.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,7 @@ See the line detection example below:
16891689
#include <opencv2/highgui.hpp>
16901690
16911691
using namespace cv;
1692+
using namespace std;
16921693
16931694
int main(int argc, char** argv)
16941695
{
@@ -1774,18 +1775,19 @@ Example: :
17741775
#include <math.h>
17751776
17761777
using namespace cv;
1778+
using namespace std;
17771779
17781780
int main(int argc, char** argv)
17791781
{
17801782
Mat img, gray;
1781-
if( argc != 2 && !(img=imread(argv[1], 1)).data)
1783+
if( argc != 2 || !(img=imread(argv[1], 1)).data)
17821784
return -1;
17831785
cvtColor(img, gray, COLOR_BGR2GRAY);
17841786
// smooth it, otherwise a lot of false circles may be detected
17851787
GaussianBlur( gray, gray, Size(9, 9), 2, 2 );
17861788
vector<Vec3f> circles;
17871789
HoughCircles(gray, circles, HOUGH_GRADIENT,
1788-
2, gray->rows/4, 200, 100 );
1790+
2, gray.rows/4, 200, 100 );
17891791
for( size_t i = 0; i < circles.size(); i++ )
17901792
{
17911793
Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
@@ -1797,6 +1799,8 @@ Example: :
17971799
}
17981800
namedWindow( "circles", 1 );
17991801
imshow( "circles", img );
1802+
1803+
waitKey(0);
18001804
return 0;
18011805
}
18021806
@endcode

modules/imgproc/src/distransform.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static void getDistanceTransformMask( int maskType, float *metrics )
438438
metrics[2] = 2.1969f;
439439
break;
440440
default:
441-
CV_Error(CV_StsBadArg, "Uknown metric type");
441+
CV_Error(CV_StsBadArg, "Unknown metric type");
442442
}
443443
}
444444

@@ -662,7 +662,7 @@ distanceATS_L1_8u( const Mat& src, Mat& dst )
662662

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

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

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

735735
if( distType == CV_DIST_C || distType == CV_DIST_L1 )
736736
maskSize = !need_labels ? CV_DIST_MASK_3 : CV_DIST_MASK_5;

0 commit comments

Comments
 (0)