From 3f417f1ec36bfb021bf1c6bc89a4450f08a3087c Mon Sep 17 00:00:00 2001 From: Vsevolod Glumov Date: Fri, 14 Dec 2012 10:49:51 +0400 Subject: [PATCH 01/21] Fixes for issues #2570, #2492, #2559, #2489, #2592. --- .../bounding_rects_circles/bounding_rects_circles.rst | 2 +- doc/user_guide/ug_mat.rst | 8 +++++--- modules/imgproc/doc/miscellaneous_transformations.rst | 2 +- .../doc/structural_analysis_and_shape_descriptors.rst | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/tutorials/imgproc/shapedescriptors/bounding_rects_circles/bounding_rects_circles.rst b/doc/tutorials/imgproc/shapedescriptors/bounding_rects_circles/bounding_rects_circles.rst index 90baaaff95..d073a1b925 100644 --- a/doc/tutorials/imgproc/shapedescriptors/bounding_rects_circles/bounding_rects_circles.rst +++ b/doc/tutorials/imgproc/shapedescriptors/bounding_rects_circles/bounding_rects_circles.rst @@ -85,7 +85,7 @@ This tutorial code's is shown lines below. You can also download it from `here < for( int i = 0; i < contours.size(); i++ ) { approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true ); boundRect[i] = boundingRect( Mat(contours_poly[i]) ); - minEnclosingCircle( contours_poly[i], center[i], radius[i] ); + minEnclosingCircle( (Mat)contours_poly[i], center[i], radius[i] ); } diff --git a/doc/user_guide/ug_mat.rst b/doc/user_guide/ug_mat.rst index f4a75eada5..f6474fac11 100644 --- a/doc/user_guide/ug_mat.rst +++ b/doc/user_guide/ug_mat.rst @@ -71,7 +71,9 @@ There are functions in OpenCV, especially from calib3d module, such as ``project //... fill the array Mat pointsMat = Mat(points); -One can access a point in this matrix using the same method \texttt{Mat::at}: :: +One can access a point in this matrix using the same method ``Mat::at`` : + +:: Point2f point = pointsMat.at(i, 0); @@ -109,7 +111,7 @@ Selecting a region of interest: :: Rect r(10, 10, 100, 100); Mat smallImg = img(r); -A convertion from \texttt{Mat} to C API data structures: :: +A convertion from ``Mat`` to C API data structures: :: Mat img = imread("image.jpg"); IplImage img1 = img; @@ -150,7 +152,7 @@ A call to ``waitKey()`` starts a message passing cycle that waits for a key stro double minVal, maxVal; minMaxLoc(sobelx, &minVal, &maxVal); //find minimum and maximum intensities Mat draw; - sobelx.convertTo(draw, CV_8U, 255.0/(maxVal - minVal), -minVal); + sobelx.convertTo(draw, CV_8U, 255.0/(maxVal - minVal), -minVal * 255.0/(maxVal - minVal)); namedWindow("image", CV_WINDOW_AUTOSIZE); imshow("image", draw); diff --git a/modules/imgproc/doc/miscellaneous_transformations.rst b/modules/imgproc/doc/miscellaneous_transformations.rst index 9b0ee6d0ab..6d91d8956c 100644 --- a/modules/imgproc/doc/miscellaneous_transformations.rst +++ b/modules/imgproc/doc/miscellaneous_transformations.rst @@ -661,7 +661,7 @@ Applies a fixed-level threshold to each array element. :param dst: output array of the same size and type as ``src``. - :param thresh: treshold value. + :param thresh: threshold value. :param maxval: maximum value to use with the ``THRESH_BINARY`` and ``THRESH_BINARY_INV`` thresholding types. diff --git a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst index d89e652fd8..99d02c2b36 100644 --- a/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst +++ b/modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst @@ -137,7 +137,7 @@ Finds contours in a binary image. :param contours: Detected contours. Each contour is stored as a vector of points. - :param hierarchy: Optional output vector containing information about the image topology. It has as many elements as the number of contours. For each contour ``contours[i]`` , the elements ``hierarchy[i][0]`` , ``hiearchy[i][1]`` , ``hiearchy[i][2]`` , and ``hiearchy[i][3]`` are set to 0-based indices in ``contours`` of the next and previous contours at the same hierarchical level: the first child contour and the parent contour, respectively. If for a contour ``i`` there are no next, previous, parent, or nested contours, the corresponding elements of ``hierarchy[i]`` will be negative. + :param hierarchy: Optional output vector, containing information about the image topology. It has as many elements as the number of contours. For each i-th contour ``contours[i]`` , the elements ``hierarchy[i][0]`` , ``hiearchy[i][1]`` , ``hiearchy[i][2]`` , and ``hiearchy[i][3]`` are set to 0-based indices in ``contours`` of the next and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. If for the contour ``i`` there are no next, previous, parent, or nested contours, the corresponding elements of ``hierarchy[i]`` will be negative. :param mode: Contour retrieval mode (if you use Python see also a note below). From 7701fa7a633d13fc64c4d8521206838bce24a329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Piel?= Date: Sat, 15 Dec 2012 12:11:13 +0100 Subject: [PATCH 02/21] highgui: fix segfault on CvCapture_GStreamer::open when compiled with GStreamer, open (of a file) segfaults. Fix was suggested by Bostjan Vesnicer. --- modules/highgui/src/cap_gstreamer.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/highgui/src/cap_gstreamer.cpp b/modules/highgui/src/cap_gstreamer.cpp index 60ba8852e6..863ddad096 100644 --- a/modules/highgui/src/cap_gstreamer.cpp +++ b/modules/highgui/src/cap_gstreamer.cpp @@ -399,12 +399,12 @@ bool CvCapture_GStreamer::open( int type, const char* filename ) gst_app_sink_set_max_buffers (GST_APP_SINK(sink), 1); gst_app_sink_set_drop (GST_APP_SINK(sink), stream); - - gst_app_sink_set_caps(GST_APP_SINK(sink), gst_caps_new_simple("video/x-raw-rgb", - "red_mask", G_TYPE_INT, 0x0000FF, - "green_mask", G_TYPE_INT, 0x00FF00, - "blue_mask", G_TYPE_INT, 0xFF0000, - NULL)); + caps = gst_caps_new_simple("video/x-raw-rgb", + "red_mask", G_TYPE_INT, 0x0000FF, + "green_mask", G_TYPE_INT, 0x00FF00, + "blue_mask", G_TYPE_INT, 0xFF0000, + NULL); + gst_app_sink_set_caps(GST_APP_SINK(sink), caps); gst_caps_unref(caps); if(gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_READY) == From 0bbba847a413f86e91d81f28f9cc7bd04a3375c9 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Sat, 15 Dec 2012 15:21:52 +0400 Subject: [PATCH 03/21] Fix equalization formula in equalizeHist function & rewrite in C++ Old implementation did lut[i] = 255 * (count(Y <= i)) / (width * height) which actually shifts uniform histograms. From now histogram is equalized as C = count(Y == min(Y)) lut[i] = 255 * (count(Y <= i) - C) / (width * height - C) --- modules/imgproc/src/histogram.cpp | 118 +++++++++++++++++++++--------- 1 file changed, 83 insertions(+), 35 deletions(-) diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index edcb240575..353ad5e0b1 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -2407,58 +2407,106 @@ cvCalcProbDensity( const CvHistogram* hist, const CvHistogram* hist_mask, CV_IMPL void cvEqualizeHist( const CvArr* srcarr, CvArr* dstarr ) { - CvMat sstub, *src = cvGetMat(srcarr, &sstub); - CvMat dstub, *dst = cvGetMat(dstarr, &dstub); + cv::equalizeHist(cv::cvarrToMat(srcarr), cv::cvarrToMat(dstarr)); +} + +void cv::equalizeHist( InputArray _src, OutputArray _dst ) +{ + Mat src = _src.getMat(); + CV_Assert( src.type() == CV_8UC1 ); + + _dst.create( src.size(), src.type() ); + Mat dst = _dst.getMat(); + + if(src.empty()) + return; + + const int hist_sz = (1 << (8*sizeof(uchar))); + int hist[hist_sz] = {0,}; - CV_Assert( CV_ARE_SIZES_EQ(src, dst) && CV_ARE_TYPES_EQ(src, dst) && - CV_MAT_TYPE(src->type) == CV_8UC1 ); - CvSize size = cvGetMatSize(src); - if( CV_IS_MAT_CONT(src->type & dst->type) ) + const size_t sstep = src.step; + const size_t dstep = dst.step; + + int width = src.cols; + int height = src.rows; + + if (src.isContinuous()) { - size.width *= size.height; - size.height = 1; + width *= height; + height = 1; } - int x, y; - const int hist_sz = 256; - int hist[hist_sz]; - memset(hist, 0, sizeof(hist)); - for( y = 0; y < size.height; y++ ) + for (const uchar* ptr = src.ptr(); height--; ptr += sstep) { - const uchar* sptr = src->data.ptr + src->step*y; - for( x = 0; x < size.width; x++ ) - hist[sptr[x]]++; + int x = 0; + for (; x <= width - 4; x += 4) + { + int t0 = ptr[x], t1 = ptr[x+1]; + hist[t0]++; hist[t1]++; + t0 = ptr[x+2]; t1 = ptr[x+3]; + hist[t0]++; hist[t1]++; + } + + for (; x < width; ++x, ++ptr) + hist[ptr[x]]++; + } + + int i = 0; + while (!hist[i]) ++i; + + int total = (int)src.total(); + if (hist[i] == total) + { + dst.setTo(i); + return; } - float scale = 255.f/(size.width*size.height); + float scale = (hist_sz - 1.f)/(total - hist[i]); int sum = 0; - uchar lut[hist_sz+1]; - for( int i = 0; i < hist_sz; i++ ) + int lut[hist_sz]; + + for (lut[i++] = 0; i < hist_sz; ++i) { sum += hist[i]; - int val = cvRound(sum*scale); - lut[i] = CV_CAST_8U(val); + lut[i] = saturate_cast(sum * scale); } - lut[0] = 0; - for( y = 0; y < size.height; y++ ) + int cols = src.cols; + int rows = src.rows; + + if (src.isContinuous() && dst.isContinuous()) { - const uchar* sptr = src->data.ptr + src->step*y; - uchar* dptr = dst->data.ptr + dst->step*y; - for( x = 0; x < size.width; x++ ) - dptr[x] = lut[sptr[x]]; + cols *= rows; + rows = 1; } -} + const uchar* sptr = src.ptr(); + uchar* dptr = dst.ptr(); -void cv::equalizeHist( InputArray _src, OutputArray _dst ) -{ - Mat src = _src.getMat(); - _dst.create( src.size(), src.type() ); - Mat dst = _dst.getMat(); - CvMat _csrc = src, _cdst = dst; - cvEqualizeHist( &_csrc, &_cdst ); + for (; rows--; sptr += sstep, dptr += dstep) + { + int x = 0; + for (; x <= cols - 4; x += 4) + { + int v0 = sptr[x]; + int v1 = sptr[x+1]; + int x0 = lut[v0]; + int x1 = lut[v1]; + dptr[x] = (uchar)x0; + dptr[x+1] = (uchar)x1; + + v0 = sptr[x+2]; + v1 = sptr[x+3]; + x0 = lut[v0]; + x1 = lut[v1]; + dptr[x+2] = (uchar)x0; + dptr[x+3] = (uchar)x1; + } + + for (; x < cols; ++x) + dptr[x] = (uchar)lut[sptr[x]]; + } } /* Implementation of RTTI and Generic Functions for CvHistogram */ From 80a1d569caee4f9e7777d3d445ccff5bb2445d64 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Sat, 15 Dec 2012 20:15:34 +0400 Subject: [PATCH 04/21] Add support for multidimentional matrices into the sanity checks --- modules/ts/src/ts_perf.cpp | 41 ++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp index 70dcfe69c9..1240aec817 100644 --- a/modules/ts/src/ts_perf.cpp +++ b/modules/ts/src/ts_perf.cpp @@ -305,23 +305,25 @@ double Regression::getElem(cv::Mat& m, int y, int x, int cn) void Regression::write(cv::Mat m) { + if (!m.empty() && m.dims < 2) return; + double min, max; - cv::minMaxLoc(m, &min, &max); + cv::minMaxIdx(m, &min, &max); write() << "min" << min << "max" << max; - write() << "last" << "{" << "x" << m.cols-1 << "y" << m.rows-1 - << "val" << getElem(m, m.rows-1, m.cols-1, m.channels()-1) << "}"; + write() << "last" << "{" << "x" << m.size.p[1] - 1 << "y" << m.size.p[0] - 1 + << "val" << getElem(m, m.size.p[0] - 1, m.size.p[1] - 1, m.channels() - 1) << "}"; int x, y, cn; - x = regRNG.uniform(0, m.cols); - y = regRNG.uniform(0, m.rows); + x = regRNG.uniform(0, m.size.p[1]); + y = regRNG.uniform(0, m.size.p[0]); cn = regRNG.uniform(0, m.channels()); write() << "rng1" << "{" << "x" << x << "y" << y; if(cn > 0) write() << "cn" << cn; write() << "val" << getElem(m, y, x, cn) << "}"; - x = regRNG.uniform(0, m.cols); - y = regRNG.uniform(0, m.rows); + x = regRNG.uniform(0, m.size.p[1]); + y = regRNG.uniform(0, m.size.p[0]); cn = regRNG.uniform(0, m.channels()); write() << "rng2" << "{" << "x" << x << "y" << y; if (cn > 0) write() << "cn" << cn; @@ -339,8 +341,10 @@ static double evalEps(double expected, double actual, double _eps, ERROR_TYPE er void Regression::verify(cv::FileNode node, cv::Mat actual, double _eps, std::string argname, ERROR_TYPE err) { + if (!actual.empty() && actual.dims < 2) return; + double actual_min, actual_max; - cv::minMaxLoc(actual, &actual_min, &actual_max); + cv::minMaxIdx(actual, &actual_min, &actual_max); double expect_min = (double)node["min"]; double eps = evalEps(expect_min, actual_min, _eps, err); @@ -353,12 +357,12 @@ void Regression::verify(cv::FileNode node, cv::Mat actual, double _eps, std::str << argname << " has unexpected maximal value" << std::endl; cv::FileNode last = node["last"]; - double actual_last = getElem(actual, actual.rows - 1, actual.cols - 1, actual.channels() - 1); + double actual_last = getElem(actual, actual.size.p[0] - 1, actual.size.p[1] - 1, actual.channels() - 1); int expect_cols = (int)last["x"] + 1; int expect_rows = (int)last["y"] + 1; - ASSERT_EQ(expect_cols, actual.cols) + ASSERT_EQ(expect_cols, actual.size.p[1]) << argname << " has unexpected number of columns" << std::endl; - ASSERT_EQ(expect_rows, actual.rows) + ASSERT_EQ(expect_rows, actual.size.p[0]) << argname << " has unexpected number of rows" << std::endl; double expect_last = (double)last["val"]; @@ -372,6 +376,8 @@ void Regression::verify(cv::FileNode node, cv::Mat actual, double _eps, std::str int cn1 = rng1["cn"]; double expect_rng1 = (double)rng1["val"]; + // it is safe to use x1 and y1 without checks here because we have already + // verified that mat size is the same as recorded double actual_rng1 = getElem(actual, y1, x1, cn1); eps = evalEps(expect_rng1, actual_rng1, _eps, err); @@ -490,7 +496,7 @@ void Regression::verify(cv::FileNode node, cv::InputArray array, double eps, ERR std::cout << " Expected: " << std::endl << expected << std::endl << " Actual:" << std::endl << actual << std::endl; double max; - cv::minMaxLoc(diff.reshape(1), 0, &max); + cv::minMaxIdx(diff.reshape(1), 0, &max); FAIL() << " Absolute difference (=" << max << ") between argument \"" << node.name() << "[" << idx << "]\" and expected value is greater than " << eps; @@ -544,7 +550,7 @@ void Regression::verify(cv::FileNode node, cv::InputArray array, double eps, ERR std::cout << " Expected: " << std::endl << expected << std::endl << " Actual:" << std::endl << actual << std::endl; double max; - cv::minMaxLoc(diff.reshape(1), 0, &max); + cv::minMaxIdx(diff.reshape(1), 0, &max); FAIL() << " Difference (=" << max << ") between argument1 \"" << node.name() << "\" and expected value is greater than " << eps; @@ -1154,12 +1160,17 @@ void TestBase::RunPerfTestBody() catch(cv::Exception e) { metrics.terminationReason = performance_metrics::TERM_EXCEPTION; - FAIL() << "Expected: PerfTestBody() doesn't throw an exception.\n Actual: it throws:\n " << e.what(); + FAIL() << "Expected: PerfTestBody() doesn't throw an exception.\n Actual: it throws cv::Exception:\n " << e.what(); + } + catch(std::exception e) + { + metrics.terminationReason = performance_metrics::TERM_EXCEPTION; + FAIL() << "Expected: PerfTestBody() doesn't throw an exception.\n Actual: it throws std::exception:\n " << e.what(); } catch(...) { metrics.terminationReason = performance_metrics::TERM_EXCEPTION; - FAIL() << "Expected: PerfTestBody() doesn't throw an exception.\n Actual: it throws."; + FAIL() << "Expected: PerfTestBody() doesn't throw an exception.\n Actual: it throws..."; } } From 7d94236c14dc2181cb659bd9118821aef05da79f Mon Sep 17 00:00:00 2001 From: Daniil-Osokin Date: Sat, 6 Oct 2012 18:06:29 +0400 Subject: [PATCH 05/21] TBB version of calcHist --- modules/imgproc/src/histogram.cpp | 580 +++++++++++++++++++++++++++++- 1 file changed, 579 insertions(+), 1 deletion(-) diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index edcb240575..89699f8c88 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -165,11 +165,13 @@ static void histPrepareImages( const Mat* images, int nimages, const int* channe deltas[dims*2 + 1] = (int)(mask.step/mask.elemSize1()); } +#ifndef HAVE_TBB if( isContinuous ) { imsize.width *= imsize.height; imsize.height = 1; } +#endif if( !ranges ) { @@ -207,6 +209,538 @@ static void histPrepareImages( const Mat* images, int nimages, const int* channe ////////////////////////////////// C A L C U L A T E H I S T O G R A M //////////////////////////////////// +#ifdef HAVE_TBB +enum {one = 1, two, three}; // array elements number + +template +class calcHist1D_Invoker +{ +public: + calcHist1D_Invoker( const vector& _ptrs, const vector& _deltas, + Mat& hist, const double* _uniranges, int sz, int dims, + Size& imageSize ) + : mask_(_ptrs[dims]), + mstep_(_deltas[dims*2 + 1]), + imageWidth_(imageSize.width), + histogramSize_(hist.size()), histogramType_(hist.type()), + globalHistogram_((tbb::atomic*)hist.data) + { + p_[0] = ((T**)&_ptrs[0])[0]; + step_[0] = (&_deltas[0])[1]; + d_[0] = (&_deltas[0])[0]; + a_[0] = (&_uniranges[0])[0]; + b_[0] = (&_uniranges[0])[1]; + size_[0] = sz; + } + + void operator()( const BlockedRange& range ) const + { + T* p0 = p_[0] + range.begin() * (step_[0] + imageWidth_*d_[0]); + uchar* mask = mask_ + range.begin()*mstep_; + + for( int row = range.begin(); row < range.end(); row++, p0 += step_[0] ) + { + if( !mask_ ) + { + for( int x = 0; x < imageWidth_; x++, p0 += d_[0] ) + { + int idx = cvFloor(*p0*a_[0] + b_[0]); + if( (unsigned)idx < (unsigned)size_[0] ) + { + globalHistogram_[idx].fetch_and_add(1); + } + } + } + else + { + for( int x = 0; x < imageWidth_; x++, p0 += d_[0] ) + { + if( mask[x] ) + { + int idx = cvFloor(*p0*a_[0] + b_[0]); + if( (unsigned)idx < (unsigned)size_[0] ) + { + globalHistogram_[idx].fetch_and_add(1); + } + } + } + mask += mstep_; + } + } + } + +private: + T* p_[one]; + uchar* mask_; + int step_[one]; + int d_[one]; + int mstep_; + double a_[one]; + double b_[one]; + int size_[one]; + int imageWidth_; + Size histogramSize_; + int histogramType_; + tbb::atomic* globalHistogram_; +}; + +template +class calcHist2D_Invoker +{ +public: + calcHist2D_Invoker( const vector& _ptrs, const vector& _deltas, + Mat& hist, const double* _uniranges, const int* size, + int dims, Size& imageSize, size_t* hstep ) + : mask_(_ptrs[dims]), + mstep_(_deltas[dims*2 + 1]), + imageWidth_(imageSize.width), + histogramSize_(hist.size()), histogramType_(hist.type()), + globalHistogram_(hist.data) + { + p_[0] = ((T**)&_ptrs[0])[0]; p_[1] = ((T**)&_ptrs[0])[1]; + step_[0] = (&_deltas[0])[1]; step_[1] = (&_deltas[0])[3]; + d_[0] = (&_deltas[0])[0]; d_[1] = (&_deltas[0])[2]; + a_[0] = (&_uniranges[0])[0]; a_[1] = (&_uniranges[0])[2]; + b_[0] = (&_uniranges[0])[1]; b_[1] = (&_uniranges[0])[3]; + size_[0] = size[0]; size_[1] = size[1]; + hstep_[0] = hstep[0]; + } + + void operator()(const BlockedRange& range) const + { + T* p0 = p_[0] + range.begin()*(step_[0] + imageWidth_*d_[0]); + T* p1 = p_[1] + range.begin()*(step_[1] + imageWidth_*d_[1]); + uchar* mask = mask_ + range.begin()*mstep_; + + for( int row = range.begin(); row < range.end(); row++, p0 += step_[0], p1 += step_[1] ) + { + if( !mask_ ) + { + for( int x = 0; x < imageWidth_; x++, p0 += d_[0], p1 += d_[1] ) + { + int idx0 = cvFloor(*p0*a_[0] + b_[0]); + int idx1 = cvFloor(*p1*a_[1] + b_[1]); + if( (unsigned)idx0 < (unsigned)size_[0] && (unsigned)idx1 < (unsigned)size_[1] ) + ( (tbb::atomic*)(globalHistogram_ + hstep_[0]*idx0) )[idx1].fetch_and_add(1); + } + } + else + { + for( int x = 0; x < imageWidth_; x++, p0 += d_[0], p1 += d_[1] ) + { + if( mask[x] ) + { + int idx0 = cvFloor(*p0*a_[0] + b_[0]); + int idx1 = cvFloor(*p1*a_[1] + b_[1]); + if( (unsigned)idx0 < (unsigned)size_[0] && (unsigned)idx1 < (unsigned)size_[1] ) + ((tbb::atomic*)(globalHistogram_ + hstep_[0]*idx0))[idx1].fetch_and_add(1); + } + } + mask += mstep_; + } + } + } + +private: + T* p_[two]; + uchar* mask_; + int step_[two]; + int d_[two]; + int mstep_; + double a_[two]; + double b_[two]; + int size_[two]; + const int imageWidth_; + size_t hstep_[one]; + Size histogramSize_; + int histogramType_; + uchar* globalHistogram_; +}; + + +template +class calcHist3D_Invoker +{ +public: + calcHist3D_Invoker( const vector& _ptrs, const vector& _deltas, + Size imsize, Mat& hist, const double* uniranges, int _dims, + size_t* hstep, int* size ) + : mask_(_ptrs[_dims]), + mstep_(_deltas[_dims*2 + 1]), + imageWidth_(imsize.width), + globalHistogram_(hist.data) + { + p_[0] = ((T**)&_ptrs[0])[0]; p_[1] = ((T**)&_ptrs[0])[1]; p_[2] = ((T**)&_ptrs[0])[2]; + step_[0] = (&_deltas[0])[1]; step_[1] = (&_deltas[0])[3]; step_[2] = (&_deltas[0])[5]; + d_[0] = (&_deltas[0])[0]; d_[1] = (&_deltas[0])[2]; d_[2] = (&_deltas[0])[4]; + a_[0] = uniranges[0]; a_[1] = uniranges[2]; a_[2] = uniranges[4]; + b_[0] = uniranges[1]; b_[1] = uniranges[3]; b_[2] = uniranges[5]; + size_[0] = size[0]; size_[1] = size[1]; size_[2] = size[2]; + hstep_[0] = hstep[0]; hstep_[1] = hstep[1]; + } + + void operator()( const BlockedRange& range ) const + { + T* p0 = p_[0] + range.begin()*(imageWidth_*d_[0] + step_[0]); + T* p1 = p_[1] + range.begin()*(imageWidth_*d_[1] + step_[1]); + T* p2 = p_[2] + range.begin()*(imageWidth_*d_[2] + step_[2]); + uchar* mask = mask_ + range.begin()*mstep_; + + for( int i = range.begin(); i < range.end(); i++, p0 += step_[0], p1 += step_[1], p2 += step_[2] ) + { + if( !mask_ ) + { + for( int x = 0; x < imageWidth_; x++, p0 += d_[0], p1 += d_[1], p2 += d_[2] ) + { + int idx0 = cvFloor(*p0*a_[0] + b_[0]); + int idx1 = cvFloor(*p1*a_[1] + b_[1]); + int idx2 = cvFloor(*p2*a_[2] + b_[2]); + if( (unsigned)idx0 < (unsigned)size_[0] && + (unsigned)idx1 < (unsigned)size_[1] && + (unsigned)idx2 < (unsigned)size_[2] ) + { + ( (tbb::atomic*)(globalHistogram_ + hstep_[0]*idx0 + hstep_[1]*idx1) )[idx2].fetch_and_add(1); + } + } + } + else + { + for( int x = 0; x < imageWidth_; x++, p0 += d_[0], p1 += d_[1], p2 += d_[2] ) + { + if( mask[x] ) + { + int idx0 = cvFloor(*p0*a_[0] + b_[0]); + int idx1 = cvFloor(*p1*a_[1] + b_[1]); + int idx2 = cvFloor(*p2*a_[2] + b_[2]); + if( (unsigned)idx0 < (unsigned)size_[0] && + (unsigned)idx1 < (unsigned)size_[1] && + (unsigned)idx2 < (unsigned)size_[2] ) + { + ( (tbb::atomic*)(globalHistogram_ + hstep_[0]*idx0 + hstep_[1]*idx1) )[idx2].fetch_and_add(1); + } + } + } + mask += mstep_; + } + } + } + + static bool isFit( const Mat& histogram, const Size imageSize ) + { + return ( imageSize.width * imageSize.height >= 320*240 + && histogram.total() >= 8*8*8 ); + } + +private: + T* p_[three]; + uchar* mask_; + int step_[three]; + int d_[three]; + const int mstep_; + double a_[three]; + double b_[three]; + int size_[three]; + int imageWidth_; + size_t hstep_[two]; + uchar* globalHistogram_; +}; + +class CalcHist1D_8uInvoker +{ +public: + CalcHist1D_8uInvoker( const vector& ptrs, const vector& deltas, + Size imsize, Mat& hist, int dims, const vector& tab, + tbb::mutex* lock ) + : mask_(ptrs[dims]), + mstep_(deltas[dims*2 + 1]), + imageWidth_(imsize.width), + imageSize_(imsize), + histSize_(hist.size()), histType_(hist.type()), + tab_((size_t*)&tab[0]), + histogramWriteLock_(lock), + globalHistogram_(hist.data) + { + p_[0] = (&ptrs[0])[0]; + step_[0] = (&deltas[0])[1]; + d_[0] = (&deltas[0])[0]; + } + + void operator()( const BlockedRange& range ) const + { + int localHistogram[256] = { 0, }; + uchar* mask = mask_; + uchar* p0 = p_[0]; + int x; + tbb::mutex::scoped_lock lock; + + if( !mask_ ) + { + int n = (imageWidth_ - 4) / 4 + 1; + int tail = imageWidth_ - n*4; + + int xN = 4*n; + p0 += (xN*d_[0] + tail*d_[0] + step_[0]) * range.begin(); + } + else + { + p0 += (imageWidth_*d_[0] + step_[0]) * range.begin(); + mask += mstep_*range.begin(); + } + + for( int i = range.begin(); i < range.end(); i++, p0 += step_[0] ) + { + if( !mask_ ) + { + if( d_[0] == 1 ) + { + for( x = 0; x <= imageWidth_ - 4; x += 4 ) + { + int t0 = p0[x], t1 = p0[x+1]; + localHistogram[t0]++; localHistogram[t1]++; + t0 = p0[x+2]; t1 = p0[x+3]; + localHistogram[t0]++; localHistogram[t1]++; + } + p0 += x; + } + else + { + for( x = 0; x <= imageWidth_ - 4; x += 4 ) + { + int t0 = p0[0], t1 = p0[d_[0]]; + localHistogram[t0]++; localHistogram[t1]++; + p0 += d_[0]*2; + t0 = p0[0]; t1 = p0[d_[0]]; + localHistogram[t0]++; localHistogram[t1]++; + p0 += d_[0]*2; + } + } + + for( ; x < imageWidth_; x++, p0 += d_[0] ) + { + localHistogram[*p0]++; + } + } + else + { + for( x = 0; x < imageWidth_; x++, p0 += d_[0] ) + { + if( mask[x] ) + { + localHistogram[*p0]++; + } + } + mask += mstep_; + } + } + + lock.acquire(*histogramWriteLock_); + for(int i = 0; i < 256; i++ ) + { + size_t hidx = tab_[i]; + if( hidx < OUT_OF_RANGE ) + { + *(int*)((globalHistogram_ + hidx)) += localHistogram[i]; + } + } + lock.release(); + } + + static bool isFit( const Mat& histogram, const Size imageSize ) + { + return ( histogram.total() >= 8 + && imageSize.width * imageSize.height >= 160*120 ); + } + +private: + uchar* p_[one]; + uchar* mask_; + int mstep_; + int step_[one]; + int d_[one]; + int imageWidth_; + Size imageSize_; + Size histSize_; + int histType_; + size_t* tab_; + tbb::mutex* histogramWriteLock_; + uchar* globalHistogram_; +}; + +class CalcHist2D_8uInvoker +{ +public: + CalcHist2D_8uInvoker( const vector& _ptrs, const vector& _deltas, + Size imsize, Mat& hist, int dims, const vector& _tab, + tbb::mutex* lock ) + : mask_(_ptrs[dims]), + mstep_(_deltas[dims*2 + 1]), + imageWidth_(imsize.width), + histSize_(hist.size()), histType_(hist.type()), + tab_((size_t*)&_tab[0]), + histogramWriteLock_(lock), + globalHistogram_(hist.data) + { + p_[0] = (uchar*)(&_ptrs[0])[0]; p_[1] = (uchar*)(&_ptrs[0])[1]; + step_[0] = (&_deltas[0])[1]; step_[1] = (&_deltas[0])[3]; + d_[0] = (&_deltas[0])[0]; d_[1] = (&_deltas[0])[2]; + } + + void operator()( const BlockedRange& range ) const + { + uchar* p0 = p_[0] + range.begin()*(step_[0] + imageWidth_*d_[0]); + uchar* p1 = p_[1] + range.begin()*(step_[1] + imageWidth_*d_[1]); + uchar* mask = mask_ + range.begin()*mstep_; + + Mat localHist = Mat::zeros(histSize_, histType_); + uchar* localHistData = localHist.data; + tbb::mutex::scoped_lock lock; + + for(int i = range.begin(); i < range.end(); i++, p0 += step_[0], p1 += step_[1]) + { + if( !mask_ ) + { + for( int x = 0; x < imageWidth_; x++, p0 += d_[0], p1 += d_[1] ) + { + size_t idx = tab_[*p0] + tab_[*p1 + 256]; + if( idx < OUT_OF_RANGE ) + { + ++*(int*)(localHistData + idx); + } + } + } + else + { + for( int x = 0; x < imageWidth_; x++, p0 += d_[0], p1 += d_[1] ) + { + size_t idx; + if( mask[x] && (idx = tab_[*p0] + tab_[*p1 + 256]) < OUT_OF_RANGE ) + { + ++*(int*)(localHistData + idx); + } + } + mask += mstep_; + } + } + + lock.acquire(*histogramWriteLock_); + for(int i = 0; i < histSize_.width*histSize_.height; i++) + { + ((int*)globalHistogram_)[i] += ((int*)localHistData)[i]; + } + lock.release(); + } + + static bool isFit( const Mat& histogram, const Size imageSize ) + { + return ( (histogram.total() > 4*4 && histogram.total() <= 116*116 + && imageSize.width * imageSize.height >= 320*240) + || (histogram.total() > 116*116 && imageSize.width * imageSize.height >= 1280*720) ); + } + +private: + uchar* p_[two]; + uchar* mask_; + int step_[two]; + int d_[two]; + int mstep_; + int imageWidth_; + Size histSize_; + int histType_; + size_t* tab_; + tbb::mutex* histogramWriteLock_; + uchar* globalHistogram_; +}; + +class CalcHist3D_8uInvoker +{ +public: + CalcHist3D_8uInvoker( const vector& _ptrs, const vector& _deltas, + Size imsize, Mat& hist, int dims, const vector& tab ) + : mask_(_ptrs[dims]), + mstep_(_deltas[dims*2 + 1]), + histogramSize_(hist.size.p), histogramType_(hist.type()), + imageWidth_(imsize.width), + tab_((size_t*)&tab[0]), + globalHistogram_(hist.data) + { + p_[0] = (uchar*)(&_ptrs[0])[0]; p_[1] = (uchar*)(&_ptrs[0])[1]; p_[2] = (uchar*)(&_ptrs[0])[2]; + step_[0] = (&_deltas[0])[1]; step_[1] = (&_deltas[0])[3]; step_[2] = (&_deltas[0])[5]; + d_[0] = (&_deltas[0])[0]; d_[1] = (&_deltas[0])[2]; d_[2] = (&_deltas[0])[4]; + } + + void operator()( const BlockedRange& range ) const + { + uchar* p0 = p_[0] + range.begin()*(step_[0] + imageWidth_*d_[0]); + uchar* p1 = p_[1] + range.begin()*(step_[1] + imageWidth_*d_[1]); + uchar* p2 = p_[2] + range.begin()*(step_[2] + imageWidth_*d_[2]); + uchar* mask = mask_ + range.begin()*mstep_; + + for(int i = range.begin(); i < range.end(); i++, p0 += step_[0], p1 += step_[1], p2 += step_[2] ) + { + if( !mask_ ) + { + for( int x = 0; x < imageWidth_; x++, p0 += d_[0], p1 += d_[1], p2 += d_[2] ) + { + size_t idx = tab_[*p0] + tab_[*p1 + 256] + tab_[*p2 + 512]; + if( idx < OUT_OF_RANGE ) + { + ( *(tbb::atomic*)(globalHistogram_ + idx) ).fetch_and_add(1); + } + } + } + else + { + for( int x = 0; x < imageWidth_; x++, p0 += d_[0], p1 += d_[1], p2 += d_[2] ) + { + size_t idx; + if( mask[x] && (idx = tab_[*p0] + tab_[*p1 + 256] + tab_[*p2 + 512]) < OUT_OF_RANGE ) + { + (*(tbb::atomic*)(globalHistogram_ + idx)).fetch_and_add(1); + } + } + mask += mstep_; + } + } + } + + static bool isFit( const Mat& histogram, const Size imageSize ) + { + return ( histogram.total() >= 128*128*128 + && imageSize.width * imageSize.width >= 320*240 ); + } + +private: + uchar* p_[three]; + uchar* mask_; + int mstep_; + int step_[three]; + int d_[three]; + int* histogramSize_; + int histogramType_; + int imageWidth_; + size_t* tab_; + uchar* globalHistogram_; +}; + +static void +callCalcHist2D_8u( vector& _ptrs, const vector& _deltas, + Size imsize, Mat& hist, int dims, vector& _tab ) +{ + int grainSize = imsize.height / tbb::task_scheduler_init::default_num_threads(); + tbb::mutex histogramWriteLock; + + CalcHist2D_8uInvoker body(_ptrs, _deltas, imsize, hist, dims, _tab, &histogramWriteLock); + parallel_for(BlockedRange(0, imsize.height, grainSize), body); +} + +static void +callCalcHist3D_8u( vector& _ptrs, const vector& _deltas, + Size imsize, Mat& hist, int dims, vector& _tab ) +{ + CalcHist3D_8uInvoker body(_ptrs, _deltas, imsize, hist, dims, _tab); + parallel_for(BlockedRange(0, imsize.height), body); +} +#endif template static void calcHist_( vector& _ptrs, const vector& _deltas, @@ -234,6 +768,11 @@ calcHist_( vector& _ptrs, const vector& _deltas, if( dims == 1 ) { +#ifdef HAVE_TBB + calcHist1D_Invoker body(_ptrs, _deltas, hist, _uniranges, size[0], dims, imsize); + parallel_for(BlockedRange(0, imsize.height), body); + return; +#endif double a = uniranges[0], b = uniranges[1]; int sz = size[0], d0 = deltas[0], step0 = deltas[1]; const T* p0 = (const T*)ptrs[0]; @@ -259,6 +798,11 @@ calcHist_( vector& _ptrs, const vector& _deltas, } else if( dims == 2 ) { +#ifdef HAVE_TBB + calcHist2D_Invoker body(_ptrs, _deltas, hist, _uniranges, size, dims, imsize, hstep); + parallel_for(BlockedRange(0, imsize.height), body); + return; +#endif double a0 = uniranges[0], b0 = uniranges[1], a1 = uniranges[2], b1 = uniranges[3]; int sz0 = size[0], sz1 = size[1]; int d0 = deltas[0], step0 = deltas[1], @@ -290,6 +834,14 @@ calcHist_( vector& _ptrs, const vector& _deltas, } else if( dims == 3 ) { +#ifdef HAVE_TBB + if( calcHist3D_Invoker::isFit(hist, imsize) ) + { + calcHist3D_Invoker body(_ptrs, _deltas, imsize, hist, uniranges, dims, hstep, size); + parallel_for(BlockedRange(0, imsize.height), body); + return; + } +#endif double a0 = uniranges[0], b0 = uniranges[1], a1 = uniranges[2], b1 = uniranges[3], a2 = uniranges[4], b2 = uniranges[5]; @@ -441,8 +993,20 @@ calcHist_8u( vector& _ptrs, const vector& _deltas, if( dims == 1 ) { +#ifdef HAVE_TBB + if( CalcHist1D_8uInvoker::isFit(hist, imsize) ) + { + int treadsNumber = tbb::task_scheduler_init::default_num_threads(); + int grainSize = imsize.height/treadsNumber; + tbb::mutex histogramWriteLock; + + CalcHist1D_8uInvoker body(_ptrs, _deltas, imsize, hist, dims, _tab, &histogramWriteLock); + parallel_for(BlockedRange(0, imsize.height, grainSize), body); + return; + } +#endif int d0 = deltas[0], step0 = deltas[1]; - int matH[256] = {0}; + int matH[256] = { 0, }; const uchar* p0 = (const uchar*)ptrs[0]; for( ; imsize.height--; p0 += step0, mask += mstep ) @@ -489,6 +1053,13 @@ calcHist_8u( vector& _ptrs, const vector& _deltas, } else if( dims == 2 ) { +#ifdef HAVE_TBB + if( CalcHist2D_8uInvoker::isFit(hist, imsize) ) + { + callCalcHist2D_8u(_ptrs, _deltas, imsize, hist, dims, _tab); + return; + } +#endif int d0 = deltas[0], step0 = deltas[1], d1 = deltas[2], step1 = deltas[3]; const uchar* p0 = (const uchar*)ptrs[0]; @@ -514,6 +1085,13 @@ calcHist_8u( vector& _ptrs, const vector& _deltas, } else if( dims == 3 ) { +#ifdef HAVE_TBB + if( CalcHist3D_8uInvoker::isFit(hist, imsize) ) + { + callCalcHist3D_8u(_ptrs, _deltas, imsize, hist, dims, _tab); + return; + } +#endif int d0 = deltas[0], step0 = deltas[1], d1 = deltas[2], step1 = deltas[3], d2 = deltas[4], step2 = deltas[5]; From cd501d947c11e25e75403611313d7ec3b5cb6047 Mon Sep 17 00:00:00 2001 From: Daniil-Osokin Date: Sat, 6 Oct 2012 18:23:21 +0400 Subject: [PATCH 06/21] perf tests for calcHist 2-3D case --- modules/imgproc/perf/perf_histogram.cpp | 73 ++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 7 deletions(-) diff --git a/modules/imgproc/perf/perf_histogram.cpp b/modules/imgproc/perf/perf_histogram.cpp index 2cb7ee5fc6..3b320633ae 100644 --- a/modules/imgproc/perf/perf_histogram.cpp +++ b/modules/imgproc/perf/perf_histogram.cpp @@ -9,14 +9,14 @@ using std::tr1::get; typedef tr1::tuple Size_Source_t; typedef TestBaseWithParam Size_Source; - typedef TestBaseWithParam MatSize; +static const float rangeHight = 256.0f; +static const float rangeLow = 0.0f; -PERF_TEST_P(Size_Source, calcHist, - testing::Combine(testing::Values(TYPICAL_MAT_SIZES), - testing::Values(CV_8U, CV_32F) - ) +PERF_TEST_P(Size_Source, calcHist1d, + testing::Combine(testing::Values(sz3MP, sz5MP), + testing::Values(CV_8U, CV_16U, CV_32F) ) ) { Size size = get<0>(GetParam()); @@ -28,10 +28,69 @@ PERF_TEST_P(Size_Source, calcHist, int dims = 1; int numberOfImages = 1; - const float r[] = {0.0f, 256.0f}; + const float r[] = {rangeLow, rangeHight}; const float* ranges[] = {r}; - declare.in(source, WARMUP_RNG).time(20).iterations(1000); + randu(source, rangeLow, rangeHight); + + declare.in(source); + + TEST_CYCLE() + { + calcHist(&source, numberOfImages, channels, Mat(), hist, dims, histSize, ranges); + } + + SANITY_CHECK(hist); +} + +PERF_TEST_P(Size_Source, calcHist2d, + testing::Combine(testing::Values(sz3MP, sz5MP), + testing::Values(CV_8UC2, CV_16UC2, CV_32FC2) ) + ) +{ + Size size = get<0>(GetParam()); + MatType type = get<1>(GetParam()); + Mat source(size.height, size.width, type); + Mat hist; + int channels [] = {0, 1}; + int histSize [] = {256, 256}; + int dims = 2; + int numberOfImages = 1; + + const float r[] = {rangeLow, rangeHight}; + const float* ranges[] = {r, r}; + + randu(source, rangeLow, rangeHight); + + declare.in(source); + TEST_CYCLE() + { + calcHist(&source, numberOfImages, channels, Mat(), hist, dims, histSize, ranges); + } + + SANITY_CHECK(hist); +} + +PERF_TEST_P(Size_Source, calcHist3d, + testing::Combine(testing::Values(sz3MP, sz5MP), + testing::Values(CV_8UC3, CV_16UC3, CV_32FC3) ) + ) +{ + Size size = get<0>(GetParam()); + MatType type = get<1>(GetParam()); + Mat hist; + int channels [] = {0, 1, 2}; + int histSize [] = {32, 32, 32}; + int dims = 3; + int numberOfImages = 1; + Mat source(size.height, size.width, type); + + const float r[] = {rangeLow, rangeHight}; + const float* ranges[] = {r, r, r}; + + randu(source, rangeLow, rangeHight); + + declare.in(source); TEST_CYCLE() { calcHist(&source, numberOfImages, channels, Mat(), hist, dims, histSize, ranges); From dfa4b2fefacc60d43e8b94dc09ccecad4c4d5baf Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 18 Dec 2012 15:58:17 +0400 Subject: [PATCH 07/21] Workaround for gcc overoptimization compiler bug. --- modules/core/src/persistence.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 35f1e9a8e2..99d46c298c 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -5200,6 +5200,7 @@ void FileStorage::release() string FileStorage::releaseAndGetString() { string buf; + buf.reserve(16); // HACK: Work around for compiler bug if( fs.obj && fs.obj->outbuf ) icvClose(fs.obj, &buf); From 3c09b075fcf967f2e49dda05df88463e992bae7c Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 18 Dec 2012 18:34:51 +0400 Subject: [PATCH 08/21] OpenCV Manager selection chapter added to documentation. --- android/service/doc/UseCases.rst | 44 ++++++++++++++++-- .../android_binary_package/O4A_SDK.rst | 24 ++-------- .../dev_with_OCV_on_Android.rst | 16 +------ .../install_opencv_manager_with_adb.png | Bin 16485 -> 0 bytes 4 files changed, 46 insertions(+), 38 deletions(-) delete mode 100644 doc/tutorials/introduction/android_binary_package/images/install_opencv_manager_with_adb.png diff --git a/android/service/doc/UseCases.rst b/android/service/doc/UseCases.rst index 96e733984e..ff26410e70 100644 --- a/android/service/doc/UseCases.rst +++ b/android/service/doc/UseCases.rst @@ -1,6 +1,40 @@ -******************************************* Manager Workflow -******************************************* +**************** + +.. _manager_selection: + +OpenCV Manager selection +------------------------ + +Since version 1.7 several packages of OpenCV Manager is built. Every package includes OpenCV library +for package target platform. The internal library is used for most cases, except the rare one, when +arm-v7a without NEON instruction set processor is detected. In this case additional binary package +for arm-v7a is used. The new package selection logic in most cases simplifies OpenCV installation +on end user devices. In most cases OpenCV Manager may be installed automatically from Google Play. +For such case, when Google Play is not available, i.e. emulator, developer board, etc, you can +install it manually using adb tool. + +.. code-block:: sh + :linenos: + + adb install OpenCV-2.4.3-android-sdk/apk/OpenCV_2.4.3_Manager_2.0_.apk + +Use table to determine right OpenCV Manager package: + ++----------------------------+-----------------+-----------------------------------------------------+ +| Hardware Platform | Android version | Package name | ++============================+=================+=====================================================+ +| Intel x86 | >= 2.3 | OpenCV_2.4.3_Manager_2.0_x86.apk | ++----------------------------+-----------------+-----------------------------------------------------+ +| MIPS | >= 2.3 | OpenCV_2.4.3_Manager_2.0_mips.apk | ++----------------------------+-----------------+-----------------------------------------------------+ +| armeabi (arm-v5, arm-v6) | >= 2.3 | OpenCV_2.4.3_Manager_2.0_armeabi.apk | ++----------------------------+-----------------+-----------------------------------------------------+ +| armeabi-v7a (arm-v7a-NEON) | >= 2.3 | OpenCV_2.4.3_Manager_2.0_armv7a-neon.apk | ++----------------------------+-----------------+-----------------------------------------------------+ +| armeabi-v7a (arm-v7a-NEON) | 2.2 | OpenCV_2.4.3.1_Manager_2.3_armv7a-neon-android8.apk | ++----------------------------+-----------------+-----------------------------------------------------+ + First application start ----------------------- @@ -9,10 +43,10 @@ There is no OpenCV Manager or OpenCV libraries: .. image:: img/NoService.png -Aditional library package installation --------------------------------------- +Additional library package installation +--------------------------------------- -There is an OpenCV Manager service, but there is no apropriate OpenCV library. +There is an OpenCV Manager service, but it does not contain appropriate OpenCV library. If OpenCV library installation has been approved\: .. image:: img/LibInstallAproved.png diff --git a/doc/tutorials/introduction/android_binary_package/O4A_SDK.rst b/doc/tutorials/introduction/android_binary_package/O4A_SDK.rst index b46e417d5a..b426c5c1ec 100644 --- a/doc/tutorials/introduction/android_binary_package/O4A_SDK.rst +++ b/doc/tutorials/introduction/android_binary_package/O4A_SDK.rst @@ -50,8 +50,8 @@ The structure of package contents looks as follows: OpenCV-2.4.3-android-sdk |_ apk - | |_ OpenCV_2.4.3_binary_pack_XXX.apk - | |_ OpenCV_2.4.3_Manager.apk + | |_ OpenCV_2.4.3_binary_pack_armv7a.apk + | |_ OpenCV_2.4.3_Manager_2.0_XXX.apk | |_ doc |_ samples @@ -85,8 +85,8 @@ The structure of package contents looks as follows: On production devices that have access to Google Play Market (and Internet) these packages will be installed from Market on the first start of an application using OpenCV Manager API. But devkits without Market or Internet connection require this packages to be installed manually. - Install the `Manager.apk` and the corresponding `binary_pack.apk` depending on the device CPU, - the Manager GUI provides this info. Below you'll see exact commands on how to do this. + Install the `Manager.apk` and optional `binary_pack.apk` if it needed. + See :ref:`manager_selection` for details. .. note:: Installation from Internet is the preferable way since OpenCV team may publish updated versions of this packages on the Market. @@ -280,21 +280,7 @@ Well, running samples from Eclipse is very simple: To get rid of the message you will need to install `OpenCV Manager` and the appropriate `OpenCV binary pack`. Simply tap :menuselection:`Yes` if you have *Google Play Market* installed on your device/emulator. It will redirect you to the corresponding page on *Google Play Market*. - If you have no access to the *Market*, which is often the case with emulators - you will need to install the packages from OpenCV4Android SDK folder manually. Open the console/terminal and type in the following two commands: - - .. code-block:: sh - :linenos: - - /platform-tools/adb install /apk/OpenCV_2.4.3_Manager.apk - /platform-tools/adb install /apk/OpenCV_2.4.3_binary_pack_armv7a.apk - - If you're running Windows, that will probably look like this: - - .. image:: images/install_opencv_manager_with_adb.png - :alt: Run these commands in the console to install OpenCV Manager - :align: center - - When done, you will be able to run OpenCV samples on your device/emulator seamlessly. + If you have no access to the *Market*, which is often the case with emulators - you will need to install the packages from OpenCV4Android SDK folder manually. See :ref:`manager_selection` for details. * Here is ``Tutorial 2 - Use OpenCV Camera`` sample, running on top of stock camera-preview of the emulator. diff --git a/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.rst b/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.rst index f7f0c4718c..ba82a8a016 100644 --- a/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.rst +++ b/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.rst @@ -54,20 +54,8 @@ Using async initialization is a **recommended** way for application development. :alt: Add dependency from OpenCV library :align: center -To run OpenCV Manager-based application for the first time you need to install package with the `OpenCV Manager` for your platform. Armeabi, Armeabi-v7a with NEON, x86 and MIPS achitectures supported. -You can do it using Google Play Market or manually with ``adb`` tool: - -.. code-block:: sh - :linenos: - - /platform-tools/adb install /apk/OpenCV_2.4.3_Manager.apk - -For rare cases if NEON instruction set is not supported you need to install aditional OpenCV Library package: - -.. code-block:: sh - :linenos: - - /platform-tools/adb install /apk/OpenCV_2.4.3_binary_pack_armv7a.apk +In most cases OpenCV Manager may be installed automatically from Google Play. For such case, when Google Play is not available, i.e. emulator, developer board, etc, you can +install it manually using adb tool. See :ref:`manager_selection` for details. There is a very base code snippet implementing the async initialization. It shows basic principles. See the "15-puzzle" OpenCV sample for details. diff --git a/doc/tutorials/introduction/android_binary_package/images/install_opencv_manager_with_adb.png b/doc/tutorials/introduction/android_binary_package/images/install_opencv_manager_with_adb.png deleted file mode 100644 index 4bebe00e65a818fd35fa318974ba6f5ec801f2a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16485 zcmeIZcT|&G*XWCzZAD;PC`ySP5osb#AW;#KE+8N^2ud%~B_WA!1VjXs-XkJiKza=U zY0`TqiS!x*gd~Kt6Ws56&UeT7zH#pT@BZ;J2IGNewYlb6YtH%n)>`3@^)yB( zikILK;^4Tzq4nV2lUHf@^oWwHZLsBjz$uLcevK~eL#E>o%)e)wC``t?btI$<*@@{K zb8w$KsxOSOjs5eC+sTQ+sagevk4djf!@V|iUfV7&YI1PO9Z_v~CMcNn=FOXPNdlb2 zA5o?@fwVMWZoMcP>^Hg!EU80A!|U!;8&FCL;3n3%g0+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pH+Jxg#kVx*6nee73?EWvubdK#Vl>6RP2&YxkESfpozoYgQCPwo5VFSLqD`r$ez z7dXquMx6cMkR64a*z#RV^O)*Kn9VC)PXHVoW2ee%zy?ge4;Hy$l>QJzm^My|B{jM8 zo)K|<^yU3Y9=0^6%4K!UUjKhd@F}5m7Ydms)=Tm-|c zUq(q^>pY@IeBq^yNi?zdVd0#6>*K{64X+>Y+NB8gx#GM0diShsJcgW|wbj&7iMe|R z2aDm<1CpC0ol`{Nc2Rolg*bZ8mJ{MxB>J=?ezQm;|7h&q~9G~nx#V3Po!2DJ{|stkfe+egW+H46Gxwf zc_9u&Iz(i_)lxN}(`>~xseX5YfDpVD{g!a{00i+H9H8(Ezq$DZ#QzAv|C8|le#78D zy84f<{_opL|IIAXByedU^yXFuvkt6r)0epw*hM^gM*_X0!>O;j-3q2vf@uR`K;PBu zME?JC;{@qHU&j{|8jc3t>0Hr-016+>;+^1Hc%1!YCf13`1HNn`0ooZ zNk#<9CWh7}QSzjEiSG~aPkOH+&MI8(_dS`WI0)ib(;GVn#Kfm0Xy#KI zi(UWs-!x-EFd=|FO`7IpqOdHsz31SMJc5#LWM9=ixJIP1{Ry+8c5uV!g~vb7MbH1~ tS&0=u9+W!SJ$h|N`vSYFBt<6ZWI!HwK%( Date: Tue, 18 Dec 2012 16:10:11 +0400 Subject: [PATCH 09/21] Add threaded version of equalizeHist --- modules/imgproc/src/histogram.cpp | 223 +++++++++++++++++++++--------- 1 file changed, 160 insertions(+), 63 deletions(-) diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index 353ad5e0b1..12edfa0c20 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -2404,6 +2404,146 @@ cvCalcProbDensity( const CvHistogram* hist, const CvHistogram* hist_mask, } } +class EqualizeHistCalcHist_Invoker +{ +public: + enum {HIST_SZ = 256}; + +#ifdef HAVE_TBB + typedef tbb::mutex* MutextPtr; +#else + typedef void* MutextPtr; +#endif + + EqualizeHistCalcHist_Invoker(cv::Mat& src, int* histogram, MutextPtr histogramLock) + : src_(src), globalHistogram_(histogram), histogramLock_(histogramLock) + { } + + void operator()( const cv::BlockedRange& rowRange ) const + { + int localHistogram[HIST_SZ] = {0, }; + + const size_t sstep = src_.step; + + int width = src_.cols; + int height = rowRange.end() - rowRange.begin(); + + if (src_.isContinuous()) + { + width *= height; + height = 1; + } + + for (const uchar* ptr = src_.ptr(rowRange.begin()); height--; ptr += sstep) + { + int x = 0; + for (; x <= width - 4; x += 4) + { + int t0 = ptr[x], t1 = ptr[x+1]; + localHistogram[t0]++; localHistogram[t1]++; + t0 = ptr[x+2]; t1 = ptr[x+3]; + localHistogram[t0]++; localHistogram[t1]++; + } + + for (; x < width; ++x, ++ptr) + localHistogram[ptr[x]]++; + } + +#ifdef HAVE_TBB + tbb::mutex::scoped_lock lock(*histogramLock_); +#endif + + for( int i = 0; i < HIST_SZ; i++ ) + globalHistogram_[i] += localHistogram[i]; + } + + static bool isWorthParallel( const cv::Mat& src ) + { +#ifdef HAVE_TBB + return ( src.total() >= 640*480 ); +#else + (void)src; + return false; +#endif + } + +private: + EqualizeHistCalcHist_Invoker& operator=(const EqualizeHistCalcHist_Invoker&); + + cv::Mat& src_; + int* globalHistogram_; + MutextPtr histogramLock_; +}; + +class EqualizeHistLut_Invoker +{ +public: + EqualizeHistLut_Invoker( cv::Mat& src, cv::Mat& dst, int* lut ) + : src_(src), + dst_(dst), + lut_(lut) + { } + + void operator()( const cv::BlockedRange& rowRange ) const + { + const size_t sstep = src_.step; + const size_t dstep = dst_.step; + + int width = src_.cols; + int height = rowRange.end() - rowRange.begin(); + int* lut = lut_; + + if (src_.isContinuous() && dst_.isContinuous()) + { + width *= height; + height = 1; + } + + const uchar* sptr = src_.ptr(rowRange.begin()); + uchar* dptr = dst_.ptr(rowRange.begin()); + + for (; height--; sptr += sstep, dptr += dstep) + { + int x = 0; + for (; x <= width - 4; x += 4) + { + int v0 = sptr[x]; + int v1 = sptr[x+1]; + int x0 = lut[v0]; + int x1 = lut[v1]; + dptr[x] = (uchar)x0; + dptr[x+1] = (uchar)x1; + + v0 = sptr[x+2]; + v1 = sptr[x+3]; + x0 = lut[v0]; + x1 = lut[v1]; + dptr[x+2] = (uchar)x0; + dptr[x+3] = (uchar)x1; + } + + for (; x < width; ++x) + dptr[x] = (uchar)lut[sptr[x]]; + } + } + + static bool isWorthParallel( const cv::Mat& src ) + { +#ifdef HAVE_TBB + return ( src.total() >= 640*480 ); +#else + (void)src; + return false; +#endif + } + +private: + EqualizeHistLut_Invoker& operator=(const EqualizeHistLut_Invoker&); + + cv::Mat& src_; + cv::Mat& dst_; + int* lut_; +}; CV_IMPL void cvEqualizeHist( const CvArr* srcarr, CvArr* dstarr ) { @@ -2421,35 +2561,25 @@ void cv::equalizeHist( InputArray _src, OutputArray _dst ) if(src.empty()) return; - const int hist_sz = (1 << (8*sizeof(uchar))); - int hist[hist_sz] = {0,}; +#ifdef HAVE_TBB + tbb::mutex histogramLockInstance; + EqualizeHistCalcHist_Invoker::MutextPtr histogramLock = &histogramLockInstance; +#else + EqualizeHistCalcHist_Invoker::MutextPtr histogramLock = 0; +#endif - const size_t sstep = src.step; - const size_t dstep = dst.step; + const int hist_sz = EqualizeHistCalcHist_Invoker::HIST_SZ; + int hist[hist_sz] = {0,}; + int lut[hist_sz]; - int width = src.cols; - int height = src.rows; + EqualizeHistCalcHist_Invoker calcBody(src, hist, histogramLock); + EqualizeHistLut_Invoker lutBody(src, dst, lut); + cv::BlockedRange heightRange(0, src.rows); - if (src.isContinuous()) - { - width *= height; - height = 1; - } - - for (const uchar* ptr = src.ptr(); height--; ptr += sstep) - { - int x = 0; - for (; x <= width - 4; x += 4) - { - int t0 = ptr[x], t1 = ptr[x+1]; - hist[t0]++; hist[t1]++; - t0 = ptr[x+2]; t1 = ptr[x+3]; - hist[t0]++; hist[t1]++; - } - - for (; x < width; ++x, ++ptr) - hist[ptr[x]]++; - } + if(EqualizeHistCalcHist_Invoker::isWorthParallel(src)) + parallel_for(heightRange, calcBody); + else + calcBody(heightRange); int i = 0; while (!hist[i]) ++i; @@ -2464,49 +2594,16 @@ void cv::equalizeHist( InputArray _src, OutputArray _dst ) float scale = (hist_sz - 1.f)/(total - hist[i]); int sum = 0; - int lut[hist_sz]; - for (lut[i++] = 0; i < hist_sz; ++i) { sum += hist[i]; lut[i] = saturate_cast(sum * scale); } - int cols = src.cols; - int rows = src.rows; - - if (src.isContinuous() && dst.isContinuous()) - { - cols *= rows; - rows = 1; - } - - const uchar* sptr = src.ptr(); - uchar* dptr = dst.ptr(); - - for (; rows--; sptr += sstep, dptr += dstep) - { - int x = 0; - for (; x <= cols - 4; x += 4) - { - int v0 = sptr[x]; - int v1 = sptr[x+1]; - int x0 = lut[v0]; - int x1 = lut[v1]; - dptr[x] = (uchar)x0; - dptr[x+1] = (uchar)x1; - - v0 = sptr[x+2]; - v1 = sptr[x+3]; - x0 = lut[v0]; - x1 = lut[v1]; - dptr[x+2] = (uchar)x0; - dptr[x+3] = (uchar)x1; - } - - for (; x < cols; ++x) - dptr[x] = (uchar)lut[sptr[x]]; - } + if(EqualizeHistLut_Invoker::isWorthParallel(src)) + parallel_for(heightRange, lutBody); + else + lutBody(heightRange); } /* Implementation of RTTI and Generic Functions for CvHistogram */ From d7c89fc64988641ac1f697d06b80de8af21e6c9a Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 19 Dec 2012 12:53:44 +0400 Subject: [PATCH 10/21] A lot of javadoc warnings duting javadoc build (Bug #2647) issue fixed Black list of entities, that are not implemented in Java API added to javadoc generator --- modules/java/generator/gen_javadoc.py | 19 ++++++++++++++++--- .../java/android+CameraBridgeViewBase.java | 2 +- .../src/java/android+OpenCVLoader.java | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/modules/java/generator/gen_javadoc.py b/modules/java/generator/gen_javadoc.py index 3c697277b5..71372d3a2c 100755 --- a/modules/java/generator/gen_javadoc.py +++ b/modules/java/generator/gen_javadoc.py @@ -3,6 +3,19 @@ import os, sys, re, string, glob from optparse import OptionParser +# Black list for classes and methods that does not implemented in Java API +# Created to exclude referencies to them in @see tag +JAVADOC_ENTITY_BLACK_LIST = set(["org.opencv.core.Core#abs", \ + "org.opencv.core.Core#theRNG", \ + "org.opencv.core.Core#extractImageCOI", \ + "org.opencv.core.PCA", \ + "org.opencv.core.SVD", \ + "org.opencv.core.RNG", \ + "org.opencv.imgproc.Imgproc#createMorphologyFilter", \ + "org.opencv.imgproc.Imgproc#createLinearFilter", \ + "org.opencv.imgproc.Imgproc#createSeparableLinearFilter", \ + "org.opencv.imgproc.FilterEngine"]) + class JavadocGenerator(object): def __init__(self, definitions = {}, modules= [], javadoc_marker = "//javadoc:"): self.definitions = definitions @@ -214,9 +227,9 @@ class JavadocGenerator(object): for see in decl["seealso"]: seedecl = self.definitions.get(see,None) if seedecl: - doc += prefix + " * @see " + self.getJavaName(seedecl, "#") + "\n" - else: - doc += prefix + " * @see " + see.replace("::",".") + "\n" + javadoc_name = self.getJavaName(seedecl, "#") + if (javadoc_name not in JAVADOC_ENTITY_BLACK_LIST): + doc += prefix + " * @see " + javadoc_name + "\n" prefix = " *\n" #doc += prefix + " * File: " + decl["file"] + " (line " + str(decl["line"]) + ")\n" diff --git a/modules/java/generator/src/java/android+CameraBridgeViewBase.java b/modules/java/generator/src/java/android+CameraBridgeViewBase.java index cd13d1f1a0..06288c94fc 100644 --- a/modules/java/generator/src/java/android+CameraBridgeViewBase.java +++ b/modules/java/generator/src/java/android+CameraBridgeViewBase.java @@ -344,7 +344,7 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac * @param supportedSizes * @param surfaceWidth * @param surfaceHeight - * @return + * @return optimal frame size */ protected Size calculateCameraFrameSize(List supportedSizes, ListItemAccessor accessor, int surfaceWidth, int surfaceHeight) { int calcWidth = 0; diff --git a/modules/java/generator/src/java/android+OpenCVLoader.java b/modules/java/generator/src/java/android+OpenCVLoader.java index ce5f4b7611..4c3655c12c 100644 --- a/modules/java/generator/src/java/android+OpenCVLoader.java +++ b/modules/java/generator/src/java/android+OpenCVLoader.java @@ -31,7 +31,7 @@ public class OpenCVLoader * @param Version OpenCV library version. * @param AppContext application context for connecting to the service. * @param Callback object, that implements LoaderCallbackInterface for handling the connection status. - * @return Returns true if initialization of OpenCV is successful. + * @return Returns true if initialization of OpenCV is successful. */ public static boolean initAsync(String Version, Context AppContext, LoaderCallbackInterface Callback) From 8763ad6c9942f17abf375f379d097bf5336761ec Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Wed, 19 Dec 2012 16:50:08 +0400 Subject: [PATCH 11/21] Fix ccache search in Android CMake toolchain. --- android/android.toolchain.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/android.toolchain.cmake b/android/android.toolchain.cmake index a282207d83..494bbaebc4 100644 --- a/android/android.toolchain.cmake +++ b/android/android.toolchain.cmake @@ -1031,6 +1031,9 @@ endif() # ccache support __INIT_VARIABLE( _ndk_ccache NDK_CCACHE ENV_NDK_CCACHE ) if( _ndk_ccache ) + if( DEFINED NDK_CCACHE AND NOT EXISTS NDK_CCACHE ) + unset( NDK_CCACHE CACHE ) + endif() find_program( NDK_CCACHE "${_ndk_ccache}" DOC "The path to ccache binary") else() unset( NDK_CCACHE CACHE ) From 1555922228ef0aaf7c69ec23a61c7bafa9af9018 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 19 Dec 2012 15:34:12 +0400 Subject: [PATCH 12/21] OpenCV for Android SDK installation improved; ReadMe.txt for OpenCV Manager added; share folder excluded from SDK. --- CMakeLists.txt | 2 +- android/service/CMakeLists.txt | 8 ++++++-- android/service/ReadMe.txt | 22 ---------------------- android/service/readme.txt | 28 ++++++++++++++++++++++++++++ samples/ocl/CMakeLists.txt | 2 +- 5 files changed, 36 insertions(+), 26 deletions(-) delete mode 100644 android/service/ReadMe.txt create mode 100644 android/service/readme.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 8707e0155d..7c3932a012 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -459,7 +459,7 @@ if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES) add_subdirectory(samples) endif() -if(BUILD_ANDROID_SERVICE) +if(ANDROID) add_subdirectory(android/service) endif() diff --git a/android/service/CMakeLists.txt b/android/service/CMakeLists.txt index c5fb11dea3..dde1455138 100644 --- a/android/service/CMakeLists.txt +++ b/android/service/CMakeLists.txt @@ -1,2 +1,6 @@ -add_subdirectory(engine) -#add_subdirectory(engine_test) +if(BUILD_ANDROID_SERVICE) + add_subdirectory(engine) + #add_subdirectory(engine_test) +endif() + +install(FILES "readme.txt" DESTINATION "apk/" COMPONENT main) diff --git a/android/service/ReadMe.txt b/android/service/ReadMe.txt deleted file mode 100644 index cd89762f4d..0000000000 --- a/android/service/ReadMe.txt +++ /dev/null @@ -1,22 +0,0 @@ -*************** -Package Content -*************** - -The package provides new OpenCV SDK that uses OpenCV Manager for library initialization. OpenCV Manager provides the following benefits: - -* Less memory usage. All apps use the same binaries from service and do not keep native libs inside them self; -* Hardware specific optimizations for all supported platforms; -* Trusted OpenCV library source. All packages with OpenCV are published on Google Play service; -* Regular updates and bug fixes; - -Package consists from Library Project for Java development with Eclipse, C++ headers and libraries for native application development, javadoc samples and prebuilt binaries for ARM and X86 platforms. -To try new SDK on serial device with Google Play just install sample package and follow application messages (Google Play service access will be needed). -TO start example on device without Google Play you need to install OpenCV manager package and OpenCV binary pack for your platform from apk folder before. -See docs/doc/tutorials/introduction/android_binary_package/android_binary_package.html and docs/android/refmain.html for details about service. -On-line documentation will be available at address: http://docs.opencv.org/trunk - -******** -Contacts -******** - -Please send all feedback to Alexander Smorkalov mailto: alexander.smorkalov@itseez.com \ No newline at end of file diff --git a/android/service/readme.txt b/android/service/readme.txt new file mode 100644 index 0000000000..69b6236e62 --- /dev/null +++ b/android/service/readme.txt @@ -0,0 +1,28 @@ +OpenCV Manager selection +======================== + +Since version 1.7 several packages of OpenCV Manager is built. Every package includes OpenCV library +for package target platform. The internal library is used for most cases, except the rare one, when +arm-v7a without NEON instruction set processor is detected. In this case additional binary package +for arm-v7a is used. The new package selection logic in most cases simplifies OpenCV installation +on end user devices. In most cases OpenCV Manager may be installed automatically from Google Play. +For such case, when Google Play is not available, i.e. emulator, developer board, etc, you can +install it manually using adb tool: + + adb install OpenCV-2.4.3-android-sdk/apk/OpenCV_2.4.3.2_Manager_2.4_.apk + +Use table to determine right OpenCV Manager package: + ++----------------------------+-----------------+-----------------------------------------------------+ +| Hardware Platform | Android version | Package name | ++============================+=================+=====================================================+ +| Intel x86 | >= 2.3 | OpenCV_2.4.3.2_Manager_2.4_x86.apk | ++----------------------------+-----------------+-----------------------------------------------------+ +| MIPS | >= 2.3 | OpenCV_2.4.3.2_Manager_2.4_mips.apk | ++----------------------------+-----------------+-----------------------------------------------------+ +| armeabi (arm-v5, arm-v6) | >= 2.3 | OpenCV_2.4.3.2_Manager_2.4_armeabi.apk | ++----------------------------+-----------------+-----------------------------------------------------+ +| armeabi-v7a (arm-v7a-NEON) | >= 2.3 | OpenCV_2.4.3.2_Manager_2.4_armv7a-neon.apk | ++----------------------------+-----------------+-----------------------------------------------------+ +| armeabi-v7a (arm-v7a-NEON) | 2.2 | OpenCV_2.4.3.2_Manager_2.4_armv7a-neon-android8.apk | ++----------------------------+-----------------+-----------------------------------------------------+ diff --git a/samples/ocl/CMakeLists.txt b/samples/ocl/CMakeLists.txt index 204c458263..40fe0e6e36 100644 --- a/samples/ocl/CMakeLists.txt +++ b/samples/ocl/CMakeLists.txt @@ -55,7 +55,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) endforeach() endif() -if (NOT WIN32) +if (INSTALL_C_EXAMPLES AND NOT WIN32) file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd ) install(FILES ${install_list} DESTINATION share/opencv/samples/${project} From 77df8730efd7b77799808ce190e44d0ff453be92 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 19 Dec 2012 18:51:17 +0400 Subject: [PATCH 13/21] Tutorial-5 sample extended. Application menu reorganized; Resolution control added. --- .../tutorial5/Sample5CameraControl.java | 46 ++++++++++++++++--- .../tutorial5/SampleJavaCameraView.java | 18 +++++++- 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/Sample5CameraControl.java b/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/Sample5CameraControl.java index ccc988a0cf..46d038a0e6 100644 --- a/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/Sample5CameraControl.java +++ b/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/Sample5CameraControl.java @@ -13,12 +13,14 @@ import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener; import android.annotation.SuppressLint; import android.app.Activity; +import android.hardware.Camera.Size; import android.os.Bundle; import android.os.Environment; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; +import android.view.SubMenu; import android.view.SurfaceView; import android.view.View; import android.view.View.OnTouchListener; @@ -29,7 +31,11 @@ public class Sample5CameraControl extends Activity implements CvCameraViewListen private static final String TAG = "OCVSample::Activity"; private SampleJavaCameraView mOpenCvCameraView; + private List mResolutionList; private MenuItem[] mEffectMenuItems; + private SubMenu mColorEffectsMenu; + private MenuItem[] mResolutionMenuItems; + private SubMenu mResolutionMenu; private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) { @Override @@ -109,22 +115,50 @@ public class Sample5CameraControl extends Activity implements CvCameraViewListen return true; } + mColorEffectsMenu = menu.addSubMenu("Color Effect"); mEffectMenuItems = new MenuItem[effects.size()]; int idx = 0; - ListIterator itr = effects.listIterator(); - while(itr.hasNext()) { - String element = itr.next(); - mEffectMenuItems[idx] = menu.add(element); + ListIterator effectItr = effects.listIterator(); + while(effectItr.hasNext()) { + String element = effectItr.next(); + mEffectMenuItems[idx] = mColorEffectsMenu.add(1, idx, Menu.NONE, element); idx++; } + + mResolutionMenu = menu.addSubMenu("Resolution"); + mResolutionList = mOpenCvCameraView.getResolutionList(); + mResolutionMenuItems = new MenuItem[mResolutionList.size()]; + + ListIterator resolutionItr = mResolutionList.listIterator(); + idx = 0; + while(resolutionItr.hasNext()) { + Size element = resolutionItr.next(); + mResolutionMenuItems[idx] = mResolutionMenu.add(2, idx, Menu.NONE, + Integer.valueOf(element.width).toString() + "x" + Integer.valueOf(element.height).toString()); + idx++; + } + return true; } public boolean onOptionsItemSelected(MenuItem item) { Log.i(TAG, "called onOptionsItemSelected; selected item: " + item); - mOpenCvCameraView.setEffect((String) item.getTitle()); - Toast.makeText(this, mOpenCvCameraView.getEffect(), Toast.LENGTH_SHORT).show(); + if (item.getGroupId() == 1) + { + mOpenCvCameraView.setEffect((String) item.getTitle()); + Toast.makeText(this, mOpenCvCameraView.getEffect(), Toast.LENGTH_SHORT).show(); + } + else if (item.getGroupId() == 2) + { + int id = item.getItemId(); + Size resolution = mResolutionList.get(id); + mOpenCvCameraView.setResolution(resolution); + resolution = mOpenCvCameraView.getResolution(); + String caption = Integer.valueOf(resolution.width).toString() + "x" + Integer.valueOf(resolution.height).toString(); + Toast.makeText(this, caption, Toast.LENGTH_SHORT).show(); + } + return true; } diff --git a/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/SampleJavaCameraView.java b/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/SampleJavaCameraView.java index 8cbf312ba9..da12bb0982 100644 --- a/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/SampleJavaCameraView.java +++ b/samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/SampleJavaCameraView.java @@ -10,6 +10,7 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.hardware.Camera; import android.hardware.Camera.PictureCallback; +import android.hardware.Camera.Size; import android.util.AttributeSet; import android.util.Log; @@ -34,11 +35,26 @@ public class SampleJavaCameraView extends JavaCameraView { } public void setEffect(String effect) { - Camera.Parameters params = mCamera.getParameters(); + Camera.Parameters params = mCamera.getParameters(); params.setColorEffect(effect); mCamera.setParameters(params); } + public List getResolutionList() { + return mCamera.getParameters().getSupportedPreviewSizes(); + } + + public void setResolution(Size resolution) { + disconnectCamera(); + mMaxHeight = resolution.height; + mMaxWidth = resolution.width; + connectCamera(getWidth(), getHeight()); + } + + public Size getResolution() { + return mCamera.getParameters().getPreviewSize(); + } + public void takePicture(final String fileName) { Log.i(TAG, "Tacking picture"); PictureCallback callback = new PictureCallback() { From ca7abe1239baf0e3d3bee6f06c0d97acd7094504 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Thu, 20 Dec 2012 12:25:59 +0400 Subject: [PATCH 14/21] Reduce number of performance tests for LBP cascade --- modules/objdetect/perf/perf_cascadeclassifier.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/objdetect/perf/perf_cascadeclassifier.cpp b/modules/objdetect/perf/perf_cascadeclassifier.cpp index 98007e45d3..531d1786af 100644 --- a/modules/objdetect/perf/perf_cascadeclassifier.cpp +++ b/modules/objdetect/perf/perf_cascadeclassifier.cpp @@ -14,11 +14,7 @@ PERF_TEST_P(ImageName_MinSize, CascadeClassifierLBPFrontalFace, testing::Combine(testing::Values( std::string("cv/shared/lena.png"), std::string("cv/shared/1_itseez-0000289.png"), std::string("cv/shared/1_itseez-0000492.png"), - std::string("cv/shared/1_itseez-0000573.png"), - std::string("cv/shared/1_itseez-0000892.png"), - std::string("cv/shared/1_itseez-0001238.png"), - std::string("cv/shared/1_itseez-0001438.png"), - std::string("cv/shared/1_itseez-0002524.png")), + std::string("cv/shared/1_itseez-0000573.png")), testing::Values(24, 30, 40, 50, 60, 70, 80, 90) ) ) From 71e7d444d8b1f82355596878bac0e274e948edb1 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Thu, 20 Dec 2012 12:28:30 +0400 Subject: [PATCH 15/21] All OpenCV Manager compiler warrnings fixed. --- .../engine/jni/BinderComponent/OpenCVEngine.cpp | 4 ++-- .../engine/jni/JNIWrapper/OpenCVLibraryInfo.cpp | 12 ++++++------ .../service/engine/jni/NativeService/PackageInfo.cpp | 8 ++++---- android/service/engine/jni/include/EngineCommon.h | 2 ++ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp b/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp index e08082004c..7cfe73ddfb 100644 --- a/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp +++ b/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp @@ -130,7 +130,7 @@ android::String16 OpenCVEngine::GetLibraryList(android::String16 version) LOGD("Trying to load info library \"%s\"", tmp.c_str()); void* handle; - const char* (*info_func)(); + InfoFunctionType info_func; handle = dlopen(tmp.c_str(), RTLD_LAZY); if (handle) @@ -138,7 +138,7 @@ android::String16 OpenCVEngine::GetLibraryList(android::String16 version) const char* error; dlerror(); - *(void **) (&info_func) = dlsym(handle, "GetLibraryList"); + info_func = (InfoFunctionType)dlsym(handle, "GetLibraryList"); if ((error = dlerror()) == NULL) { result = String16((*info_func)()); diff --git a/android/service/engine/jni/JNIWrapper/OpenCVLibraryInfo.cpp b/android/service/engine/jni/JNIWrapper/OpenCVLibraryInfo.cpp index c1cbccfe83..e7dc6d2f14 100644 --- a/android/service/engine/jni/JNIWrapper/OpenCVLibraryInfo.cpp +++ b/android/service/engine/jni/JNIWrapper/OpenCVLibraryInfo.cpp @@ -24,12 +24,12 @@ JNIEXPORT jlong JNICALL Java_org_opencv_engine_OpenCVLibraryInfo_open JNIEXPORT jstring JNICALL Java_org_opencv_engine_OpenCVLibraryInfo_getPackageName (JNIEnv* env, jobject, jlong handle) { - const char* (*info_func)(); + InfoFunctionType info_func; const char* result; const char* error; dlerror(); - *(void **) (&info_func) = dlsym((void*)handle, "GetPackageName"); + info_func = (InfoFunctionType)dlsym((void*)handle, "GetPackageName"); if ((error = dlerror()) == NULL) result = (*info_func)(); else @@ -44,12 +44,12 @@ JNIEXPORT jstring JNICALL Java_org_opencv_engine_OpenCVLibraryInfo_getPackageNam JNIEXPORT jstring JNICALL Java_org_opencv_engine_OpenCVLibraryInfo_getLibraryList (JNIEnv* env, jobject, jlong handle) { - const char* (*info_func)(); + InfoFunctionType info_func; const char* result; const char* error; dlerror(); - *(void **) (&info_func) = dlsym((void*)handle, "GetLibraryList"); + info_func = (InfoFunctionType)dlsym((void*)handle, "GetLibraryList"); if ((error = dlerror()) == NULL) result = (*info_func)(); else @@ -64,12 +64,12 @@ JNIEXPORT jstring JNICALL Java_org_opencv_engine_OpenCVLibraryInfo_getLibraryLis JNIEXPORT jstring JNICALL Java_org_opencv_engine_OpenCVLibraryInfo_getVersionName (JNIEnv* env, jobject, jlong handle) { - const char* (*info_func)(); + InfoFunctionType info_func; const char* result; const char* error; dlerror(); - *(void **) (&info_func) = dlsym((void*)handle, "GetRevision"); + info_func = (InfoFunctionType)dlsym((void*)handle, "GetRevision"); if ((error = dlerror()) == NULL) result = (*info_func)(); else diff --git a/android/service/engine/jni/NativeService/PackageInfo.cpp b/android/service/engine/jni/NativeService/PackageInfo.cpp index 1f4878f972..396178d5dc 100644 --- a/android/service/engine/jni/NativeService/PackageInfo.cpp +++ b/android/service/engine/jni/NativeService/PackageInfo.cpp @@ -342,8 +342,8 @@ InstallPath(install_path) LOGD("Trying to load info library \"%s\"", tmp.c_str()); void* handle; - const char* (*name_func)(); - const char* (*revision_func)(); + InfoFunctionType name_func; + InfoFunctionType revision_func; handle = dlopen(tmp.c_str(), RTLD_LAZY); if (handle) @@ -351,8 +351,8 @@ InstallPath(install_path) const char* error; dlerror(); - *(void **) (&name_func) = dlsym(handle, "GetPackageName"); - *(void **) (&revision_func) = dlsym(handle, "GetRevision"); + name_func = (InfoFunctionType)dlsym(handle, "GetPackageName"); + revision_func = (InfoFunctionType)dlsym(handle, "GetRevision"); error = dlerror(); if (!error && revision_func && name_func) diff --git a/android/service/engine/jni/include/EngineCommon.h b/android/service/engine/jni/include/EngineCommon.h index 8aa99f8c94..2bee139ea3 100644 --- a/android/service/engine/jni/include/EngineCommon.h +++ b/android/service/engine/jni/include/EngineCommon.h @@ -17,4 +17,6 @@ // Class name of OpenCV engine binder object. Is needned for connection to service #define OPECV_ENGINE_CLASSNAME "org.opencv.engine.OpenCVEngineInterface" +typedef const char* (*InfoFunctionType)(); + #endif \ No newline at end of file From 64f821908e41f44f9b8f50478942cd55b44bb2d7 Mon Sep 17 00:00:00 2001 From: takacsd Date: Thu, 20 Dec 2012 11:28:16 +0100 Subject: [PATCH 16/21] Add missing _WIN32 check in core/operations.hpp. Fix a compilation error with MinGW gcc 4.7 with enabled C++11 support (-std=c++11). Issue number: #2555 --- modules/core/include/opencv2/core/operations.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index e3ebe6e675..a9031749da 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -64,7 +64,7 @@ #endif #elif __GNUC__*10 + __GNUC_MINOR__ >= 42 - #if !defined WIN32 && (defined __i486__ || defined __i586__ || \ + #if !(defined WIN32 || defined _WIN32) && (defined __i486__ || defined __i586__ || \ defined __i686__ || defined __MMX__ || defined __SSE__ || defined __ppc__) #define CV_XADD __sync_fetch_and_add #else From ee144852f2c742ea77e2ef92f15cf517eb160030 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Thu, 20 Dec 2012 16:44:56 +0400 Subject: [PATCH 17/21] Hardware platform detection for non arm devices fixed. --- .../NativeService/CommonPackageManager.cpp | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/android/service/engine/jni/NativeService/CommonPackageManager.cpp b/android/service/engine/jni/NativeService/CommonPackageManager.cpp index e99d9b2293..164b415a74 100644 --- a/android/service/engine/jni/NativeService/CommonPackageManager.cpp +++ b/android/service/engine/jni/NativeService/CommonPackageManager.cpp @@ -134,7 +134,7 @@ bool CommonPackageManager::IsVersionCompatible(const std::string& target_version // major version is the same and minor package version is above or the same as target. if ((package_version[0] == target_version[0]) && (package_version[1] == target_version[1]) && (package_version[2] >= target_version[2])) { - result = true; + result = true; } return result; @@ -144,13 +144,21 @@ int CommonPackageManager::GetHardwareRating(int platform, int cpu_id, const std: { int result = -1; - for (size_t i = 0; i < group.size(); i++) + if ((cpu_id & ARCH_X86) || (cpu_id & ARCH_X64) || (cpu_id & ARCH_MIPS)) + // Note: No raiting for x86, x64 and MIPS + // only one package is used + result = 0; + else { - if (group[i] == std::pair(platform, cpu_id)) - { - result = i; - break; - } + // Calculate rating for Arm + for (size_t i = 0; i < group.size(); i++) + { + if (group[i] == std::pair(platform, cpu_id)) + { + result = i; + break; + } + } } return result; From aaf779a3a2780dfef2c64ef1db1e3f6ad483f9fc Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Thu, 20 Dec 2012 17:19:34 +0400 Subject: [PATCH 18/21] Adjust OpenCV version to 2.4.3.2 --- cmake/OpenCVVersion.cmake | 2 +- modules/core/include/opencv2/core/version.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVVersion.cmake b/cmake/OpenCVVersion.cmake index 86638ad594..8ffcf01f6b 100644 --- a/cmake/OpenCVVersion.cmake +++ b/cmake/OpenCVVersion.cmake @@ -5,7 +5,7 @@ string(REGEX REPLACE ".+CV_MAJOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MAJ string(REGEX REPLACE ".+CV_MINOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MINOR "${OPENCV_VERSION_PARTS}") string(REGEX REPLACE ".+CV_SUBMINOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_PATCH "${OPENCV_VERSION_PARTS}") -set(OPENCV_VERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}.1") +set(OPENCV_VERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}.2") set(OPENCV_SOVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}") # create a dependency on version file diff --git a/modules/core/include/opencv2/core/version.hpp b/modules/core/include/opencv2/core/version.hpp index 1aed6747be..78f8109e18 100644 --- a/modules/core/include/opencv2/core/version.hpp +++ b/modules/core/include/opencv2/core/version.hpp @@ -53,6 +53,6 @@ #define CVAUX_STR_EXP(__A) #__A #define CVAUX_STR(__A) CVAUX_STR_EXP(__A) -#define CV_VERSION CVAUX_STR(CV_MAJOR_VERSION) "." CVAUX_STR(CV_MINOR_VERSION) "." CVAUX_STR(CV_SUBMINOR_VERSION) ".1" +#define CV_VERSION CVAUX_STR(CV_MAJOR_VERSION) "." CVAUX_STR(CV_MINOR_VERSION) "." CVAUX_STR(CV_SUBMINOR_VERSION) ".2" #endif From 9526907cba46063ea9b9358b66d8a944ee9e213f Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Thu, 20 Dec 2012 18:46:54 +0400 Subject: [PATCH 19/21] Use .yml.gz format to reduce space requirement from ~260Mb to ~17Mb for ml tests The size of temporary files is an issue on mobile platforms. --- modules/ml/test/test_save_load.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ml/test/test_save_load.cpp b/modules/ml/test/test_save_load.cpp index 707ba911c1..889b98b62b 100644 --- a/modules/ml/test/test_save_load.cpp +++ b/modules/ml/test/test_save_load.cpp @@ -64,11 +64,11 @@ int CV_SLMLTest::run_test_case( int testCaseIdx ) if( code == cvtest::TS::OK ) { get_error( testCaseIdx, CV_TEST_ERROR, &test_resps1 ); - fname1 = tempfile(); + fname1 = tempfile(".yml.gz"); save( fname1.c_str() ); load( fname1.c_str() ); get_error( testCaseIdx, CV_TEST_ERROR, &test_resps2 ); - fname2 = tempfile(); + fname2 = tempfile(".yml.gz"); save( fname2.c_str() ); } else From b6efec5f8b18443a3ae94b2dc5c2d1c072e75711 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Fri, 21 Dec 2012 15:39:23 +0400 Subject: [PATCH 20/21] Add support for Android NDK r8d --- android/android.toolchain.cmake | 15 +++++++++++---- cmake/OpenCVPCHSupport.cmake | 2 +- modules/ts/include/opencv2/ts/ts_gtest.h | 4 ++-- modules/ts/src/ts_gtest.cpp | 1 + 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/android/android.toolchain.cmake b/android/android.toolchain.cmake index 494bbaebc4..b3c8d83fc1 100644 --- a/android/android.toolchain.cmake +++ b/android/android.toolchain.cmake @@ -280,6 +280,9 @@ # - November 2012 # [+] updated for NDK r8c # [+] added support for clang compiler +# - December 2012 +# [~] fixed ccache full path search +# [+] updated for NDK r8d # ------------------------------------------------------------------------------ cmake_minimum_required( VERSION 2.6.3 ) @@ -302,7 +305,7 @@ set( CMAKE_SYSTEM_VERSION 1 ) # rpath makes low sence for Android set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." ) -set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) +set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS) if( CMAKE_HOST_WIN32 ) file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS ) @@ -962,7 +965,11 @@ if( BUILD_WITH_ANDROID_NDK ) set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/gabi++/include" ) set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gabi++/libs/${ANDROID_NDK_ABI_NAME}/libgabi++_static.a" ) elseif( ANDROID_STL MATCHES "stlport" ) - set( ANDROID_EXCEPTIONS OFF ) + if( NOT ANDROID_NDK_RELEASE STRLESS "r8d" ) + set( ANDROID_EXCEPTIONS ON ) + else() + set( ANDROID_EXCEPTIONS OFF ) + endif() if( ANDROID_NDK_RELEASE STRLESS "r7" ) set( ANDROID_RTTI OFF ) else() @@ -1263,7 +1270,7 @@ endif() if( ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" ) if( ANDROID_GOLD_LINKER AND (CMAKE_HOST_UNIX OR ANDROID_NDK_RELEASE STRGREATER "r8b") AND (ARMEABI OR ARMEABI_V7A OR X86) ) set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" ) - elseif( ANDROID_NDK_RELEASE STREQUAL "r8c") + elseif( ANDROID_NDK_RELEASE STRGREATER "r8b") set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=bfd" ) elseif( ANDROID_NDK_RELEASE STREQUAL "r8b" AND ARMEABI AND NOT _CMAKE_IN_TRY_COMPILE ) message( WARNING "The default bfd linker from arm GCC 4.6 toolchain can fail with 'unresolvable R_ARM_THM_CALL relocation' error message. See https://code.google.com/p/android/issues/detail?id=35342 @@ -1523,7 +1530,7 @@ endif() # BUILD_WITH_STANDALONE_TOOLCHAIN : TRUE if standalone toolchain is used # ANDROID_NDK_HOST_SYSTEM_NAME : "windows", "linux-x86" or "darwin-x86" depending on host platform # ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a", "x86" or "mips" depending on ANDROID_ABI -# ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c; set only for NDK +# ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c, r8d; set only for NDK # ANDROID_ARCH_NAME : "arm" or "x86" or "mips" depending on ANDROID_ABI # ANDROID_SYSROOT : path to the compiler sysroot # TOOL_OS_SUFFIX : "" or ".exe" depending on host platform diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake index fac6bd409b..cfc4bfa724 100644 --- a/cmake/OpenCVPCHSupport.cmake +++ b/cmake/OpenCVPCHSupport.cmake @@ -19,7 +19,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX) ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion OUTPUT_VARIABLE gcc_compiler_version) #MESSAGE("GCC Version: ${gcc_compiler_version}") - IF(gcc_compiler_version MATCHES "4\\.[0,2-9]\\.[0-9x]") + IF(gcc_compiler_version VERSION_GREATER "4.2.-1") SET(PCHSupport_FOUND TRUE) ENDIF() diff --git a/modules/ts/include/opencv2/ts/ts_gtest.h b/modules/ts/include/opencv2/ts/ts_gtest.h index 3d61a0eac9..585650ff03 100644 --- a/modules/ts/include/opencv2/ts/ts_gtest.h +++ b/modules/ts/include/opencv2/ts/ts_gtest.h @@ -433,8 +433,8 @@ // Defines this to true iff Google Test can use POSIX regular expressions. #ifndef GTEST_HAS_POSIX_RE # if GTEST_OS_LINUX_ANDROID -// On Android, is only available starting with Gingerbread. -# define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9) +// On Android, is only available starting with Froyo. +# define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 8) # else # define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS) #endif diff --git a/modules/ts/src/ts_gtest.cpp b/modules/ts/src/ts_gtest.cpp index 2e58194708..a718fc036b 100644 --- a/modules/ts/src/ts_gtest.cpp +++ b/modules/ts/src/ts_gtest.cpp @@ -1340,6 +1340,7 @@ GTEST_API_ bool IsAsciiWhiteSpace(char ch); GTEST_API_ bool IsAsciiWordChar(char ch); GTEST_API_ bool IsValidEscape(char ch); GTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch); +GTEST_API_ std::string FormatRegexSyntaxError(const char* regex, int index); GTEST_API_ bool ValidateRegex(const char* regex); GTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str); GTEST_API_ bool MatchRepetitionAndRegexAtHead( From f22ee7f0dff17aaab98035d1cf17a6a899d26cfb Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Fri, 21 Dec 2012 16:44:54 +0400 Subject: [PATCH 21/21] Workaround "Segmentation fault" when built with gcc 4.7 from NDK r8d --- android/android.toolchain.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/android/android.toolchain.cmake b/android/android.toolchain.cmake index b3c8d83fc1..f5daf307f7 100644 --- a/android/android.toolchain.cmake +++ b/android/android.toolchain.cmake @@ -981,7 +981,13 @@ if( BUILD_WITH_ANDROID_NDK ) set( ANDROID_EXCEPTIONS ON ) set( ANDROID_RTTI ON ) if( EXISTS "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" ) - set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" ) + if( ARMEABI_V7A AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.7" AND ANDROID_NDK_RELEASE STREQUAL "r8d" ) + # gnustl binary for 4.7 compiler is buggy :( + # TODO: look for right fix + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.6" ) + else() + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" ) + endif() else() set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++" ) endif()