From 91b713b8c90f2ce9902a4b78021d43a7ed0d4bb4 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 2 Jul 2013 12:58:59 +0400 Subject: [PATCH 01/14] JavaCameraView delivers same frame twice (Bug #3123) fixed. --- .../generator/src/java/android+JavaCameraView.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/java/generator/src/java/android+JavaCameraView.java b/modules/java/generator/src/java/android+JavaCameraView.java index 3bef2e0c382a..f864e5370b1e 100644 --- a/modules/java/generator/src/java/android+JavaCameraView.java +++ b/modules/java/generator/src/java/android+JavaCameraView.java @@ -38,7 +38,7 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb private boolean mStopThread; protected Camera mCamera; - protected JavaCameraFrame mCameraFrame; + protected JavaCameraFrame[] mCameraFrame; private SurfaceTexture mSurfaceTexture; public static class JavaCameraSizeAccessor implements ListItemAccessor { @@ -180,7 +180,9 @@ protected boolean initializeCamera(int width, int height) { AllocateCache(); - mCameraFrame = new JavaCameraFrame(mFrameChain[mChainIdx], mFrameWidth, mFrameHeight); + mCameraFrame = new JavaCameraFrame[2]; + mCameraFrame[0] = new JavaCameraFrame(mFrameChain[0], mFrameWidth, mFrameHeight); + mCameraFrame[1] = new JavaCameraFrame(mFrameChain[1], mFrameWidth, mFrameHeight); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mSurfaceTexture = new SurfaceTexture(MAGIC_TEXTURE_ID); @@ -216,8 +218,10 @@ protected void releaseCamera() { mFrameChain[0].release(); mFrameChain[1].release(); } - if (mCameraFrame != null) - mCameraFrame.release(); + if (mCameraFrame != null) { + mCameraFrame[0].release(); + mCameraFrame[1].release(); + } } } @@ -318,7 +322,7 @@ public void run() { if (!mStopThread) { if (!mFrameChain[mChainIdx].empty()) - deliverAndDrawFrame(mCameraFrame); + deliverAndDrawFrame(mCameraFrame[mChainIdx]); mChainIdx = 1 - mChainIdx; } } while (!mStopThread); From b524e275c1db2f09f2a3a5f6ccc7ad6fc5d4bc2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Tue, 2 Jul 2013 18:08:12 +0200 Subject: [PATCH 02/14] allow QtKit capture in secondary threads [NSRunLoop currentRunLoop] is not the same as in the main thread. see https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/F oundation/Classes/nsrunloop_Class/Reference/Reference.html "If no input sources or timers are attached to the run loop, this method exits immediately" The old code caused grabFrame() to return immediately if the capture was not done in the main thread. This code works correctly, even in secondary threads, provided that all capture functions are called in the *same* thread --- modules/highgui/src/cap_qtkit.mm | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/highgui/src/cap_qtkit.mm b/modules/highgui/src/cap_qtkit.mm index c7afffa075a7..207f01b525ee 100644 --- a/modules/highgui/src/cap_qtkit.mm +++ b/modules/highgui/src/cap_qtkit.mm @@ -277,11 +277,8 @@ - (IplImage*)getOutput; double sleepTime = 0.005; double total = 0; - NSDate *loopUntil = [NSDate dateWithTimeIntervalSinceNow:sleepTime]; - while (![capture updateImage] && (total += sleepTime)<=timeOut && - [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode - beforeDate:loopUntil]) - loopUntil = [NSDate dateWithTimeIntervalSinceNow:sleepTime]; + while (![capture updateImage] && (total += sleepTime)<=timeOut) + usleep((int)(sleepTime*1000)); [localpool drain]; From 8045093cfb4f95f2ceed974fb7d9c0cd5a9c4269 Mon Sep 17 00:00:00 2001 From: Alexander Mordvintsev Date: Wed, 3 Jul 2013 22:26:18 +0400 Subject: [PATCH 03/14] GFTT wrapped to python --- modules/features2d/include/opencv2/features2d/features2d.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index 8d644a30ee69..eeca9020d74c 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -589,10 +589,10 @@ class CV_EXPORTS_W FastFeatureDetector : public FeatureDetector }; -class CV_EXPORTS GFTTDetector : public FeatureDetector +class CV_EXPORTS_W GFTTDetector : public FeatureDetector { public: - GFTTDetector( int maxCorners=1000, double qualityLevel=0.01, double minDistance=1, + CV_WRAP GFTTDetector( int maxCorners=1000, double qualityLevel=0.01, double minDistance=1, int blockSize=3, bool useHarrisDetector=false, double k=0.04 ); AlgorithmInfo* info() const; From f2333e90f63f80d833aa4a50254c645da25c4e4b Mon Sep 17 00:00:00 2001 From: yao Date: Thu, 4 Jul 2013 14:46:38 +0800 Subject: [PATCH 04/14] optimize stereoBP kernel --- modules/ocl/src/opencl/stereobp.cl | 201 ++++++++++++++++------------- modules/ocl/src/stereobp.cpp | 6 +- 2 files changed, 111 insertions(+), 96 deletions(-) diff --git a/modules/ocl/src/opencl/stereobp.cl b/modules/ocl/src/opencl/stereobp.cl index 4d13f807bbd4..8a71629f872f 100644 --- a/modules/ocl/src/opencl/stereobp.cl +++ b/modules/ocl/src/opencl/stereobp.cl @@ -56,8 +56,10 @@ #ifdef T_FLOAT #define T float +#define T4 float4 #else #define T short +#define T4 short4 #endif /////////////////////////////////////////////////////////////// @@ -71,6 +73,14 @@ T saturate_cast(float v){ #endif } +T4 saturate_cast4(float4 v){ +#ifdef T_SHORT + return convert_short4_sat_rte(v); +#else + return v; +#endif +} + #define FLOAT_MAX 3.402823466e+38f typedef struct { @@ -84,29 +94,14 @@ typedef struct ////////////////////////// comp data ////////////////////////// /////////////////////////////////////////////////////////////// -float pix_diff_1(__global const uchar *ls, __global const uchar *rs) +inline float pix_diff_1(const uchar4 l, __global const uchar *rs) { - return abs((int)(*ls) - *rs); + return abs((int)(l.x) - *rs); } -float pix_diff_3(__global const uchar *ls, __global const uchar *rs) +float pix_diff_4(const uchar4 l, __global const uchar *rs) { - const float tr = 0.299f; - const float tg = 0.587f; - const float tb = 0.114f; - - float val; - - val = tb * abs((int)ls[0] - rs[0]); - val += tg * abs((int)ls[1] - rs[1]); - val += tr * abs((int)ls[2] - rs[2]); - - return val; -} -float pix_diff_4(__global const uchar *ls, __global const uchar *rs) -{ - uchar4 l, r; - l = *((__global uchar4 *)ls); + uchar4 r; r = *((__global uchar4 *)rs); const float tr = 0.299f; @@ -122,11 +117,19 @@ float pix_diff_4(__global const uchar *ls, __global const uchar *rs) return val; } +inline float pix_diff_3(const uchar4 l, __global const uchar *rs) +{ + return pix_diff_4(l, rs); +} #ifndef CN #define CN 4 #endif +#ifndef CNDISP +#define CNDISP 64 +#endif + #define CAT(X,Y) X##Y #define CAT2(X,Y) CAT(X,Y) @@ -149,19 +152,20 @@ __kernel void comp_data(__global uchar *left, int left_rows, int left_cols, i __global T *ds = data + y * data_step + x; const unsigned int disp_step = data_step * left_rows; + const float weightXterm = con_st -> cdata_weight * con_st -> cmax_data_term; + const uchar4 ls_data = vload4(0, ls); for (int disp = 0; disp < con_st -> cndisp; disp++) { if (x - disp >= 1) { float val = 0; - val = PIX_DIFF(ls, rs - disp * CN); - ds[disp * disp_step] = saturate_cast(fmin(con_st -> cdata_weight * val, - con_st -> cdata_weight * con_st -> cmax_data_term)); + val = PIX_DIFF(ls_data, rs - disp * CN); + ds[disp * disp_step] = saturate_cast(fmin(con_st -> cdata_weight * val, weightXterm)); } else { - ds[disp * disp_step] = saturate_cast(con_st -> cdata_weight * con_st -> cmax_data_term); + ds[disp * disp_step] = saturate_cast(weightXterm); } } } @@ -182,13 +186,20 @@ __kernel void data_step_down(__global T *src, int src_rows, { src_step /= sizeof(T); dst_step /= sizeof(T); + int4 coor_step = (int4)(src_rows * src_step); + int4 coor = (int4)(min(2*y+0, src_rows-1) * src_step + 2*x+0, + min(2*y+1, src_rows-1) * src_step + 2*x+0, + min(2*y+0, src_rows-1) * src_step + 2*x+1, + min(2*y+1, src_rows-1) * src_step + 2*x+1); + for (int d = 0; d < cndisp; ++d) { float dst_reg; - dst_reg = src[(d * src_rows + min(2*y+0, src_rows-1)) * src_step + 2*x+0]; - dst_reg += src[(d * src_rows + min(2*y+1, src_rows-1)) * src_step + 2*x+0]; - dst_reg += src[(d * src_rows + min(2*y+0, src_rows-1)) * src_step + 2*x+1]; - dst_reg += src[(d * src_rows + min(2*y+1, src_rows-1)) * src_step + 2*x+1]; + dst_reg = src[coor.x]; + dst_reg += src[coor.y]; + dst_reg += src[coor.z]; + dst_reg += src[coor.w]; + coor += coor_step; dst[(d * dst_rows + y) * dst_step + x] = saturate_cast(dst_reg); } @@ -224,85 +235,95 @@ __kernel void level_up_message(__global T *src, int src_rows, int src_step, /////////////////////////////////////////////////////////////// //////////////////// calc all iterations ///////////////////// /////////////////////////////////////////////////////////////// -void calc_min_linear_penalty(__global T * dst, int disp_step, - int cndisp, float cdisc_single_jump) +void message(__global T *us_, __global T *ds_, __global T *ls_, __global T *rs_, + const __global T *dt, + int u_step, int msg_disp_step, int data_disp_step, + float4 cmax_disc_term, float4 cdisc_single_jump) { - float prev = dst[0]; - float cur; + __global T *us = us_ + u_step; + __global T *ds = ds_ - u_step; + __global T *ls = ls_ + 1; + __global T *rs = rs_ - 1; - for (int disp = 1; disp < cndisp; ++disp) - { - prev += cdisc_single_jump; - cur = dst[disp_step * disp]; + float4 minimum = (float4)(FLOAT_MAX); - if (prev < cur) - { - cur = prev; - dst[disp_step * disp] = saturate_cast(prev); - } + T4 t_dst[CNDISP]; + float4 dst_reg; + float4 prev; + float4 cur; - prev = cur; - } + T t_us = us[0]; + T t_ds = ds[0]; + T t_ls = ls[0]; + T t_rs = rs[0]; + T t_dt = dt[0]; + + prev = (float4)(t_us + t_ls + t_rs + t_dt, + t_ds + t_ls + t_rs + t_dt, + t_us + t_ds + t_rs + t_dt, + t_us + t_ds + t_ls + t_dt); + + minimum = min(prev, minimum); + + t_dst[0] = saturate_cast4(prev); - prev = dst[(cndisp - 1) * disp_step]; - for (int disp = cndisp - 2; disp >= 0; disp--) + for(int i = 1, idx = msg_disp_step; i < CNDISP; ++i, idx+=msg_disp_step) { + t_us = us[idx]; + t_ds = ds[idx]; + t_ls = ls[idx]; + t_rs = rs[idx]; + t_dt = dt[data_disp_step * i]; + + dst_reg = (float4)(t_us + t_ls + t_rs + t_dt, + t_ds + t_ls + t_rs + t_dt, + t_us + t_ds + t_rs + t_dt, + t_us + t_ds + t_ls + t_dt); + + minimum = min(dst_reg, minimum); + prev += cdisc_single_jump; - cur = dst[disp_step * disp]; + prev = min(prev, dst_reg); - if (prev < cur) - { - cur = prev; - dst[disp_step * disp] = saturate_cast(prev); - } - prev = cur; + t_dst[i] = saturate_cast4(prev); } -} -void message(const __global T *msg1, const __global T *msg2, - const __global T *msg3, const __global T *data, __global T *dst, - int msg_disp_step, int data_disp_step, int cndisp, float cmax_disc_term, float cdisc_single_jump) -{ - float minimum = FLOAT_MAX; - for(int i = 0; i < cndisp; ++i) + minimum += cmax_disc_term; + + float4 sum = 0; + prev = convert_float4(t_dst[CNDISP - 1]); + for (int disp = CNDISP - 2; disp >= 0; disp--) { - float dst_reg; - dst_reg = msg1[msg_disp_step * i]; - dst_reg += msg2[msg_disp_step * i]; - dst_reg += msg3[msg_disp_step * i]; - dst_reg += data[data_disp_step * i]; - - if (dst_reg < minimum) - minimum = dst_reg; + prev += cdisc_single_jump; + cur = convert_float4(t_dst[disp]); + prev = min(prev, cur); + cur = min(prev, minimum); + sum += cur; - dst[msg_disp_step * i] = saturate_cast(dst_reg); + t_dst[disp] = saturate_cast4(cur); } - calc_min_linear_penalty(dst, msg_disp_step, cndisp, cdisc_single_jump); + dst_reg = convert_float4(t_dst[CNDISP - 1]); + dst_reg = min(dst_reg, minimum); + t_dst[CNDISP - 1] = saturate_cast4(dst_reg); + sum += dst_reg; - minimum += cmax_disc_term; - - float sum = 0; - for(int i = 0; i < cndisp; ++i) + sum /= CNDISP; +#pragma unroll + for(int i = 0, idx = 0; i < CNDISP; ++i, idx+=msg_disp_step) { - float dst_reg = dst[msg_disp_step * i]; - if (dst_reg > minimum) - { - dst_reg = minimum; - dst[msg_disp_step * i] = saturate_cast(minimum); - } - sum += dst_reg; + T4 dst = t_dst[i]; + us_[idx] = dst.x - sum.x; + ds_[idx] = dst.y - sum.y; + rs_[idx] = dst.z - sum.z; + ls_[idx] = dst.w - sum.w; } - sum /= cndisp; - - for(int i = 0; i < cndisp; ++i) - dst[msg_disp_step * i] -= sum; } __kernel void one_iteration(__global T *u, int u_step, __global T *data, int data_step, __global T *d, __global T *l, __global T *r, int t, int cols, int rows, - int cndisp, float cmax_disc_term, float cdisc_single_jump) + float cmax_disc_term, float cdisc_single_jump) { const int y = get_global_id(1); const int x = ((get_global_id(0)) << 1) + ((y + t) & 1); @@ -321,15 +342,9 @@ __kernel void one_iteration(__global T *u, int u_step, int msg_disp_step = u_step * rows; int data_disp_step = data_step * rows; - message(us + u_step, ls + 1, rs - 1, dt, us, msg_disp_step, data_disp_step, cndisp, - cmax_disc_term, cdisc_single_jump); - message(ds - u_step, ls + 1, rs - 1, dt, ds, msg_disp_step, data_disp_step, cndisp, - cmax_disc_term, cdisc_single_jump); - - message(us + u_step, ds - u_step, rs - 1, dt, rs, msg_disp_step, data_disp_step, cndisp, - cmax_disc_term, cdisc_single_jump); - message(us + u_step, ds - u_step, ls + 1, dt, ls, msg_disp_step, data_disp_step, cndisp, - cmax_disc_term, cdisc_single_jump); + message(us, ds, ls, rs, dt, + u_step, msg_disp_step, data_disp_step, + (float4)(cmax_disc_term), (float4)(cdisc_single_jump)); } } diff --git a/modules/ocl/src/stereobp.cpp b/modules/ocl/src/stereobp.cpp index bd88ec0470df..cca1db349913 100644 --- a/modules/ocl/src/stereobp.cpp +++ b/modules/ocl/src/stereobp.cpp @@ -236,13 +236,13 @@ namespace cv args.push_back( make_pair( sizeof(cl_int) , (void *)&t)); args.push_back( make_pair( sizeof(cl_int) , (void *)&cols)); args.push_back( make_pair( sizeof(cl_int) , (void *)&rows)); - args.push_back( make_pair( sizeof(cl_int) , (void *)&cndisp)); args.push_back( make_pair( sizeof(cl_float) , (void *)&cmax_disc_term)); args.push_back( make_pair( sizeof(cl_float) , (void *)&cdisc_single_jump)); size_t gt[3] = {cols, rows, 1}, lt[3] = {16, 16, 1}; - const char* t_opt = data_type == CV_16S ? "-D T_SHORT":"-D T_FLOAT"; - openCLExecuteKernel(clCxt, &stereobp, kernelName, gt, lt, args, -1, -1, t_opt); + char opt[80] = ""; + sprintf(opt, "-D %s -D CNDISP=%d", data_type == CV_16S ? "T_SHORT":"T_FLOAT", cndisp); + openCLExecuteKernel(clCxt, &stereobp, kernelName, gt, lt, args, -1, -1, opt); } static void calc_all_iterations_calls(int cols, int rows, int iters, oclMat &u, From 97e620b8f3ead7e2843fbd3b8f6d7b9c34bad1cd Mon Sep 17 00:00:00 2001 From: Jin Ma Date: Thu, 4 Jul 2013 16:14:55 +0800 Subject: [PATCH 05/14] Fix oclMat constructor when roi is provided. --- modules/ocl/include/opencv2/ocl/matrix_operations.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ocl/include/opencv2/ocl/matrix_operations.hpp b/modules/ocl/include/opencv2/ocl/matrix_operations.hpp index fcd847cb6b54..55f2fc9fa106 100644 --- a/modules/ocl/include/opencv2/ocl/matrix_operations.hpp +++ b/modules/ocl/include/opencv2/ocl/matrix_operations.hpp @@ -211,8 +211,8 @@ namespace cv { flags &= roi.width < m.cols ? ~Mat::CONTINUOUS_FLAG : -1; offset += roi.y * step + roi.x * elemSize(); - CV_Assert( 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && - 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows ); + CV_Assert( 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.wholecols && + 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.wholerows ); if( refcount ) CV_XADD(refcount, 1); if( rows <= 0 || cols <= 0 ) From 3677a66403af5ca468320399dd5606effd9fde05 Mon Sep 17 00:00:00 2001 From: Alexander Mordvintsev Date: Thu, 4 Jul 2013 17:43:38 +0400 Subject: [PATCH 06/14] line realign --- modules/features2d/include/opencv2/features2d/features2d.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index eeca9020d74c..c1967f813c9f 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -593,7 +593,7 @@ class CV_EXPORTS_W GFTTDetector : public FeatureDetector { public: CV_WRAP GFTTDetector( int maxCorners=1000, double qualityLevel=0.01, double minDistance=1, - int blockSize=3, bool useHarrisDetector=false, double k=0.04 ); + int blockSize=3, bool useHarrisDetector=false, double k=0.04 ); AlgorithmInfo* info() const; protected: From 83fd385bbdc581d6aac631005fe2a5c652cff7b3 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 4 Jul 2013 18:03:03 +0400 Subject: [PATCH 07/14] xls-report.py: don't eat all errors when reading sheet.conf --- modules/ts/misc/xls-report.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ts/misc/xls-report.py b/modules/ts/misc/xls-report.py index e911314e9216..4e2d8c63b286 100755 --- a/modules/ts/misc/xls-report.py +++ b/modules/ts/misc/xls-report.py @@ -67,6 +67,7 @@ from __future__ import division import ast +import errno import fnmatch import logging import numbers @@ -176,7 +177,8 @@ def main(): try: with open(os.path.join(sheet_path, 'sheet.conf')) as sheet_conf_file: sheet_conf = ast.literal_eval(sheet_conf_file.read()) - except Exception: + except IOError as ioe: + if ioe.errno != errno.ENOENT: raise sheet_conf = {} logging.debug('no sheet.conf for %s', sheet_path) From c2e6668414852e1c5d75321f0bdd2dff16b1c456 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Thu, 4 Jul 2013 18:51:17 +0400 Subject: [PATCH 08/14] Bug #3124 libopencv_java.so v 2.4.6 hangs on some Android 4.0.3 devices fixed. Downgrade TBB to 4.1u2 for all platforms, except WinRT. --- 3rdparty/tbb/CMakeLists.txt | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/3rdparty/tbb/CMakeLists.txt b/3rdparty/tbb/CMakeLists.txt index 03183d1c2a94..ce081959689c 100644 --- a/3rdparty/tbb/CMakeLists.txt +++ b/3rdparty/tbb/CMakeLists.txt @@ -5,14 +5,23 @@ if (WIN32 AND NOT ARM) message(FATAL_ERROR "BUILD_TBB option supports Windows on ARM only!\nUse regular official TBB build instead of the BUILD_TBB option!") endif() -# 4.1 update 4 - works fine -set(tbb_ver "tbb41_20130613oss") -set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130613oss_src.tgz") -set(tbb_md5 "108c8c1e481b0aaea61878289eb28b6a") -set(tbb_version_file "version_string.ver") -ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused-parameter) - -# 4.1 update 3 dev - works fine +if (WIN32 AND ARM) + # 4.1 update 4 - The first release that supports Windows RT. Hangs on some Android devices + set(tbb_ver "tbb41_20130613oss") + set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130613oss_src.tgz") + set(tbb_md5 "108c8c1e481b0aaea61878289eb28b6a") + set(tbb_version_file "version_string.ver") + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused-parameter) +else() + # 4.1 update 2 - works fine + set(tbb_ver "tbb41_20130116oss") + set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130116oss_src.tgz") + set(tbb_md5 "3809790e1001a1b32d59c9fee590ee85") + set(tbb_version_file "version_string.ver") + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow) +endif() + +# 4.1 update 3 dev - Hangs on some Android devices #set(tbb_ver "tbb41_20130401oss") #set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130401oss_src.tgz") #set(tbb_md5 "f2f591a0d2ca8f801e221ce7d9ea84bb") From 4e939e2fce267caa944663d2578a93b807123a0f Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 4 Jul 2013 18:19:33 +0400 Subject: [PATCH 09/14] xls-report.py: added an option to include data from unrecognized XMLs --- modules/ts/misc/xls-report.py | 54 +++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/modules/ts/misc/xls-report.py b/modules/ts/misc/xls-report.py index 4e2d8c63b286..24891ff7c046 100755 --- a/modules/ts/misc/xls-report.py +++ b/modules/ts/misc/xls-report.py @@ -40,9 +40,15 @@ Corollary 2: an empty 'properties' dictionary matches every property set. 3) If a matching matcher is found, its 'name' string is presumed to be the name - of the configuration the XML file corresponds to. Otherwise, a warning is - printed. A warning is also printed if two different property sets match to the - same configuration name. + of the configuration the XML file corresponds to. A warning is printed if + two different property sets match to the same configuration name. + + 4) If a such a matcher isn't found, if --include-unmatched was specified, the + configuration name is assumed to be the relative path from the sheet's + directory to the XML file's containing directory. If the XML file isinstance + directly inside the sheet's directory, the configuration name is instead + a dump of all its properties. If --include-unmatched wasn't specified, + the XML file is ignored and a warning is printed. * 'configurations': [string] List of names for compile-time and runtime configurations of OpenCV. @@ -97,18 +103,25 @@ header_style = xlwt.easyxf('font: bold true; alignment: horizontal centre, vertical top, wrap True') class Collector(object): - def __init__(self, config_match_func): + def __init__(self, config_match_func, include_unmatched): self.__config_cache = {} self.config_match_func = config_match_func + self.include_unmatched = include_unmatched self.tests = {} + self.extra_configurations = set() # Format a sorted sequence of pairs as if it was a dictionary. # We can't just use a dictionary instead, since we want to preserve the sorted order of the keys. @staticmethod - def __format_config_cache_key(pairs): - return '{' + ', '.join(repr(k) + ': ' + repr(v) for (k, v) in pairs) + '}' - - def collect_from(self, xml_path): + def __format_config_cache_key(pairs, multiline=False): + return ( + ('{\n' if multiline else '{') + + (',\n' if multiline else ', ').join( + (' ' if multiline else '') + repr(k) + ': ' + repr(v) for (k, v) in pairs) + + ('\n}\n' if multiline else '}') + ) + + def collect_from(self, xml_path, default_configuration): run = parseLogFile(xml_path) module = run.properties['module_name'] @@ -124,8 +137,17 @@ def collect_from(self, xml_path): configuration = self.config_match_func(properties) if configuration is None: - logging.warning('failed to match properties to a configuration: %s', - Collector.__format_config_cache_key(props_key)) + if self.include_unmatched: + if default_configuration is not None: + configuration = default_configuration + else: + configuration = Collector.__format_config_cache_key(props_key, multiline=True) + + self.extra_configurations.add(configuration) + else: + logging.warning('failed to match properties to a configuration: %s', + Collector.__format_config_cache_key(props_key)) + else: same_config_props = [it[0] for it in self.__config_cache.iteritems() if it[1] == configuration] if len(same_config_props) > 0: @@ -160,6 +182,8 @@ def main(): arg_parser.add_argument('sheet_dirs', nargs='+', metavar='DIR', help='directory containing perf test logs') arg_parser.add_argument('-o', '--output', metavar='XLS', default='report.xls', help='name of output file') arg_parser.add_argument('-c', '--config', metavar='CONF', help='global configuration file') + arg_parser.add_argument('--include-unmatched', action='store_true', + help='include results from XML files that were not recognized by configuration matchers') args = arg_parser.parse_args() @@ -187,12 +211,18 @@ def main(): config_names = sheet_conf.get('configurations', []) config_matchers = sheet_conf.get('configuration_matchers', []) - collector = Collector(make_match_func(config_matchers)) + collector = Collector(make_match_func(config_matchers), args.include_unmatched) for root, _, filenames in os.walk(sheet_path): logging.info('looking in %s', root) for filename in fnmatch.filter(filenames, '*.xml'): - collector.collect_from(os.path.join(root, filename)) + if os.path.normpath(sheet_path) == os.path.normpath(root): + default_conf = None + else: + default_conf = os.path.relpath(root, sheet_path) + collector.collect_from(os.path.join(root, filename), default_conf) + + config_names.extend(sorted(collector.extra_configurations - set(config_names))) sheet = wb.add_sheet(sheet_conf.get('sheet_name', os.path.basename(os.path.abspath(sheet_path)))) From ea054e28885e1190fb81df3fa791a54142553172 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 4 Jul 2013 18:44:56 +0400 Subject: [PATCH 10/14] xls-report.py: made most columns a little wider --- modules/ts/misc/xls-report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ts/misc/xls-report.py b/modules/ts/misc/xls-report.py index 24891ff7c046..39e587a46569 100755 --- a/modules/ts/misc/xls-report.py +++ b/modules/ts/misc/xls-report.py @@ -235,7 +235,7 @@ def main(): sheet_comparisons = sheet_conf.get('comparisons', []) for i, w in enumerate([2000, 15000, 2500, 2000, 15000] - + (len(config_names) + 1 + len(sheet_comparisons)) * [3000]): + + (len(config_names) + 1 + len(sheet_comparisons)) * [4000]): sheet.col(i).width = w for i, caption in enumerate(['Module', 'Test', 'Image\nsize', 'Data\ntype', 'Parameters'] From 0732905cff6ebad5afb86303355221b8817ec182 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 4 Jul 2013 18:52:10 +0400 Subject: [PATCH 11/14] xls-report.py: write tests in sorted order --- modules/ts/misc/xls-report.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/ts/misc/xls-report.py b/modules/ts/misc/xls-report.py index 39e587a46569..0aeb1c3c0bd6 100755 --- a/modules/ts/misc/xls-report.py +++ b/modules/ts/misc/xls-report.py @@ -81,7 +81,6 @@ import re from argparse import ArgumentParser -from collections import OrderedDict from glob import glob from itertools import ifilter @@ -160,7 +159,7 @@ def collect_from(self, xml_path, default_configuration): if configuration is None: return - module_tests = self.tests.setdefault(module, OrderedDict()) + module_tests = self.tests.setdefault(module, {}) for test in run.tests: test_results = module_tests.setdefault((test.shortName(), test.param()), {}) @@ -250,7 +249,7 @@ def main(): for module, color in module_colors.iteritems()} for module, tests in sorted(collector.tests.iteritems()): - for ((test, param), configs) in tests.iteritems(): + for ((test, param), configs) in sorted(tests.iteritems()): sheet.write(row, 0, module, module_styles.get(module, xlwt.Style.default_style)) sheet.write(row, 1, test) From 2b441720265f2e1f530394ac072169a7960cd96b Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 4 Jul 2013 19:59:26 +0400 Subject: [PATCH 12/14] xls-report.py: make behaviour more intelligent in case of repeated results --- modules/ts/misc/xls-report.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/ts/misc/xls-report.py b/modules/ts/misc/xls-report.py index 0aeb1c3c0bd6..131f3fab59d3 100755 --- a/modules/ts/misc/xls-report.py +++ b/modules/ts/misc/xls-report.py @@ -163,7 +163,13 @@ def collect_from(self, xml_path, default_configuration): for test in run.tests: test_results = module_tests.setdefault((test.shortName(), test.param()), {}) - test_results[configuration] = test.get("gmean") if test.status == 'run' else test.status + new_result = test.get("gmean") if test.status == 'run' else test.status + test_results[configuration] = min( + test_results.get(configuration), new_result, + key=lambda r: (1, r) if isinstance(r, numbers.Number) else + (2,) if r is not None else + (3,) + ) # prefer lower result; prefer numbers to errors and errors to nothing def make_match_func(matchers): def match_func(properties): From e905c81cccd996ac195ba45491fa833aca8bd7f2 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Fri, 5 Jul 2013 12:07:04 +0400 Subject: [PATCH 13/14] OpenCV Manager version++. --- .../introduction/android_binary_package/O4A_SDK.rst | 4 ++-- platforms/android/service/engine/AndroidManifest.xml | 4 ++-- platforms/android/service/readme.txt | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/tutorials/introduction/android_binary_package/O4A_SDK.rst b/doc/tutorials/introduction/android_binary_package/O4A_SDK.rst index d2d38ab9433b..78566e7d28ef 100644 --- a/doc/tutorials/introduction/android_binary_package/O4A_SDK.rst +++ b/doc/tutorials/introduction/android_binary_package/O4A_SDK.rst @@ -51,7 +51,7 @@ The structure of package contents looks as follows: OpenCV-2.4.6-android-sdk |_ apk | |_ OpenCV_2.4.6_binary_pack_armv7a.apk - | |_ OpenCV_2.4.6_Manager_2.8_XXX.apk + | |_ OpenCV_2.4.6_Manager_2.9_XXX.apk | |_ doc |_ samples @@ -295,7 +295,7 @@ Well, running samples from Eclipse is very simple: .. code-block:: sh :linenos: - /platform-tools/adb install /apk/OpenCV_2.4.6_Manager_2.8_armv7a-neon.apk + /platform-tools/adb install /apk/OpenCV_2.4.6_Manager_2.9_armv7a-neon.apk .. note:: ``armeabi``, ``armv7a-neon``, ``arm7a-neon-android8``, ``mips`` and ``x86`` stand for platform targets: diff --git a/platforms/android/service/engine/AndroidManifest.xml b/platforms/android/service/engine/AndroidManifest.xml index b2141e0ce3d6..8eb06689c75d 100644 --- a/platforms/android/service/engine/AndroidManifest.xml +++ b/platforms/android/service/engine/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="29@ANDROID_PLATFORM_VERSION_CODE@" + android:versionName="2.9" > diff --git a/platforms/android/service/readme.txt b/platforms/android/service/readme.txt index e68bf5249ce1..6255df5e932e 100644 --- a/platforms/android/service/readme.txt +++ b/platforms/android/service/readme.txt @@ -14,20 +14,20 @@ manually using adb tool: .. code-block:: sh - adb install OpenCV-2.4.6-android-sdk/apk/OpenCV_2.4.6_Manager_2.8_.apk + adb install OpenCV-2.4.6-android-sdk/apk/OpenCV_2.4.6_Manager_2.9_.apk Use the table below to determine proper OpenCV Manager package for your device: +------------------------------+--------------+---------------------------------------------------+ | Hardware Platform | Android ver. | Package name | +==============================+==============+===================================================+ -| armeabi-v7a (ARMv7-A + NEON) | >= 2.3 | OpenCV_2.4.6_Manager_2.8_armv7a-neon.apk | +| armeabi-v7a (ARMv7-A + NEON) | >= 2.3 | OpenCV_2.4.6_Manager_2.9_armv7a-neon.apk | +------------------------------+--------------+---------------------------------------------------+ -| armeabi-v7a (ARMv7-A + NEON) | = 2.2 | OpenCV_2.4.6_Manager_2.8_armv7a-neon-android8.apk | +| armeabi-v7a (ARMv7-A + NEON) | = 2.2 | OpenCV_2.4.6_Manager_2.9_armv7a-neon-android8.apk | +------------------------------+--------------+---------------------------------------------------+ -| armeabi (ARMv5, ARMv6) | >= 2.3 | OpenCV_2.4.6_Manager_2.8_armeabi.apk | +| armeabi (ARMv5, ARMv6) | >= 2.3 | OpenCV_2.4.6_Manager_2.9_armeabi.apk | +------------------------------+--------------+---------------------------------------------------+ -| Intel x86 | >= 2.3 | OpenCV_2.4.6_Manager_2.8_x86.apk | +| Intel x86 | >= 2.3 | OpenCV_2.4.6_Manager_2.9_x86.apk | +------------------------------+--------------+---------------------------------------------------+ -| MIPS | >= 2.3 | OpenCV_2.4.6_Manager_2.8_mips.apk | +| MIPS | >= 2.3 | OpenCV_2.4.6_Manager_2.9_mips.apk | +------------------------------+--------------+---------------------------------------------------+ From 69b308a36881c6a46e25b1825cd466ad9540e4da Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Fri, 5 Jul 2013 14:08:37 +0400 Subject: [PATCH 14/14] Various fixes in android sample NativeActivity. --- samples/android/native-activity/.cproject | 2 +- .../native-activity/AndroidManifest.xml | 5 ++++- .../android/native-activity/jni/Android.mk | 2 +- .../android/native-activity/jni/native.cpp | 21 ++++++++++++++----- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/samples/android/native-activity/.cproject b/samples/android/native-activity/.cproject index 44aadfe9afb4..83ca04b55b96 100644 --- a/samples/android/native-activity/.cproject +++ b/samples/android/native-activity/.cproject @@ -20,7 +20,7 @@ - + diff --git a/samples/android/native-activity/AndroidManifest.xml b/samples/android/native-activity/AndroidManifest.xml index 369bc75027a1..55b696ba471a 100644 --- a/samples/android/native-activity/AndroidManifest.xml +++ b/samples/android/native-activity/AndroidManifest.xml @@ -10,6 +10,7 @@ @@ -17,7 +18,9 @@ + android:label="@string/app_name" + android:screenOrientation="landscape" + android:configChanges="keyboardHidden|orientation"> diff --git a/samples/android/native-activity/jni/Android.mk b/samples/android/native-activity/jni/Android.mk index fd4fd2bfbb06..7ae31e24cac1 100644 --- a/samples/android/native-activity/jni/Android.mk +++ b/samples/android/native-activity/jni/Android.mk @@ -7,7 +7,7 @@ include ../../sdk/native/jni/OpenCV.mk LOCAL_MODULE := native_activity LOCAL_SRC_FILES := native.cpp LOCAL_LDLIBS += -lm -llog -landroid -LOCAL_STATIC_LIBRARIES := android_native_app_glue +LOCAL_STATIC_LIBRARIES += android_native_app_glue include $(BUILD_SHARED_LIBRARY) diff --git a/samples/android/native-activity/jni/native.cpp b/samples/android/native-activity/jni/native.cpp index 5cfb3a961130..0054da9da2dc 100644 --- a/samples/android/native-activity/jni/native.cpp +++ b/samples/android/native-activity/jni/native.cpp @@ -78,18 +78,29 @@ static void engine_draw_frame(Engine* engine, const cv::Mat& frame) return; } - void* pixels = buffer.bits; + int32_t* pixels = (int32_t*)buffer.bits; int left_indent = (buffer.width-frame.cols)/2; int top_indent = (buffer.height-frame.rows)/2; - for (int yy = top_indent; yy < std::min(frame.rows+top_indent, buffer.height); yy++) + if (top_indent > 0) { - unsigned char* line = (unsigned char*)pixels + left_indent*4*sizeof(unsigned char); - size_t line_size = std::min(frame.cols, buffer.width)*4*sizeof(unsigned char); + memset(pixels, 0, top_indent*buffer.stride*sizeof(int32_t)); + pixels += top_indent*buffer.stride; + } + + for (int yy = 0; yy < frame.rows; yy++) + { + if (left_indent > 0) + { + memset(pixels, 0, left_indent*sizeof(int32_t)); + memset(pixels+left_indent+frame.cols, 0, (buffer.stride-frame.cols-left_indent)*sizeof(int32_t)); + } + int32_t* line = pixels + left_indent; + size_t line_size = frame.cols*4*sizeof(unsigned char); memcpy(line, frame.ptr(yy), line_size); // go to next line - pixels = (int32_t*)pixels + buffer.stride; + pixels += buffer.stride; } ANativeWindow_unlockAndPost(engine->app->window); }