Commit 85cf2d96 authored by Roman Donchenko's avatar Roman Donchenko Committed by OpenCV Buildbot

Merge pull request #2524 from SpecLad:merge-2.4

parents 9e1124d2 cc054937
...@@ -438,7 +438,6 @@ include(cmake/OpenCVFindLibsGUI.cmake) ...@@ -438,7 +438,6 @@ include(cmake/OpenCVFindLibsGUI.cmake)
include(cmake/OpenCVFindLibsVideo.cmake) include(cmake/OpenCVFindLibsVideo.cmake)
include(cmake/OpenCVFindLibsPerf.cmake) include(cmake/OpenCVFindLibsPerf.cmake)
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Detect other 3rd-party libraries/tools # Detect other 3rd-party libraries/tools
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
......
...@@ -217,3 +217,42 @@ else() ...@@ -217,3 +217,42 @@ else()
unset(CUDA_ARCH_BIN CACHE) unset(CUDA_ARCH_BIN CACHE)
unset(CUDA_ARCH_PTX CACHE) unset(CUDA_ARCH_PTX CACHE)
endif() endif()
if(HAVE_CUDA)
set(CUDA_LIBS_PATH "")
foreach(p ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
get_filename_component(_tmp ${p} PATH)
list(APPEND CUDA_LIBS_PATH ${_tmp})
endforeach()
if(HAVE_CUBLAS)
foreach(p ${CUDA_cublas_LIBRARY})
get_filename_component(_tmp ${p} PATH)
list(APPEND CUDA_LIBS_PATH ${_tmp})
endforeach()
endif()
if(HAVE_CUFFT)
foreach(p ${CUDA_cufft_LIBRARY})
get_filename_component(_tmp ${p} PATH)
list(APPEND CUDA_LIBS_PATH ${_tmp})
endforeach()
endif()
list(REMOVE_DUPLICATES CUDA_LIBS_PATH)
link_directories(${CUDA_LIBS_PATH})
set(CUDA_LIBRARIES_ABS ${CUDA_LIBRARIES})
ocv_convert_to_lib_name(CUDA_LIBRARIES ${CUDA_LIBRARIES})
set(CUDA_npp_LIBRARY_ABS ${CUDA_npp_LIBRARY})
ocv_convert_to_lib_name(CUDA_npp_LIBRARY ${CUDA_npp_LIBRARY})
if(HAVE_CUBLAS)
set(CUDA_cublas_LIBRARY_ABS ${CUDA_cublas_LIBRARY})
ocv_convert_to_lib_name(CUDA_cublas_LIBRARY ${CUDA_cublas_LIBRARY})
endif()
if(HAVE_CUFFT)
set(CUDA_cufft_LIBRARY_ABS ${CUDA_cufft_LIBRARY})
ocv_convert_to_lib_name(CUDA_cufft_LIBRARY ${CUDA_cufft_LIBRARY})
endif()
endif()
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
# The verbose template for OpenCV module: # The verbose template for OpenCV module:
# #
# ocv_add_module(modname <dependencies>) # ocv_add_module(modname <dependencies>)
# ocv_glob_module_sources() or glob them manually and ocv_set_module_sources(...) # ocv_glob_module_sources(([EXCLUDE_CUDA] <extra sources&headers>)
# or glob them manually and ocv_set_module_sources(...)
# ocv_module_include_directories(<extra include directories>) # ocv_module_include_directories(<extra include directories>)
# ocv_create_module() # ocv_create_module()
# <add extra link dependencies, compiler options, etc> # <add extra link dependencies, compiler options, etc>
...@@ -478,9 +479,15 @@ endmacro() ...@@ -478,9 +479,15 @@ endmacro()
# finds and sets headers and sources for the standard OpenCV module # finds and sets headers and sources for the standard OpenCV module
# Usage: # Usage:
# ocv_glob_module_sources(<extra sources&headers in the same format as used in ocv_set_module_sources>) # ocv_glob_module_sources([EXCLUDE_CUDA] <extra sources&headers in the same format as used in ocv_set_module_sources>)
macro(ocv_glob_module_sources) macro(ocv_glob_module_sources)
file(GLOB_RECURSE lib_srcs "src/*.cpp") set(_argn ${ARGN})
list(FIND _argn "EXCLUDE_CUDA" exclude_cuda)
if(NOT exclude_cuda EQUAL -1)
list(REMOVE_AT _argn ${exclude_cuda})
endif()
file(GLOB_RECURSE lib_srcs "src/*.cpp")
file(GLOB_RECURSE lib_int_hdrs "src/*.hpp" "src/*.h") file(GLOB_RECURSE lib_int_hdrs "src/*.hpp" "src/*.h")
file(GLOB lib_hdrs "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h") file(GLOB lib_hdrs "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
file(GLOB lib_hdrs_detail "include/opencv2/${name}/detail/*.hpp" "include/opencv2/${name}/detail/*.h") file(GLOB lib_hdrs_detail "include/opencv2/${name}/detail/*.hpp" "include/opencv2/${name}/detail/*.h")
...@@ -492,15 +499,21 @@ macro(ocv_glob_module_sources) ...@@ -492,15 +499,21 @@ macro(ocv_glob_module_sources)
ocv_source_group("Src" DIRBASE "${CMAKE_CURRENT_SOURCE_DIR}/src" FILES ${lib_srcs} ${lib_int_hdrs}) ocv_source_group("Src" DIRBASE "${CMAKE_CURRENT_SOURCE_DIR}/src" FILES ${lib_srcs} ${lib_int_hdrs})
ocv_source_group("Include" DIRBASE "${CMAKE_CURRENT_SOURCE_DIR}/include" FILES ${lib_hdrs} ${lib_hdrs_detail}) ocv_source_group("Include" DIRBASE "${CMAKE_CURRENT_SOURCE_DIR}/include" FILES ${lib_hdrs} ${lib_hdrs_detail})
file(GLOB lib_cuda_srcs "src/cuda/*.cu") if (exclude_cuda EQUAL -1)
set(cuda_objs "") file(GLOB lib_cuda_srcs "src/cuda/*.cu")
set(lib_cuda_hdrs "") set(cuda_objs "")
if(HAVE_CUDA AND lib_cuda_srcs) set(lib_cuda_hdrs "")
ocv_include_directories(${CUDA_INCLUDE_DIRS}) if(HAVE_CUDA)
file(GLOB lib_cuda_hdrs "src/cuda/*.hpp") ocv_include_directories(${CUDA_INCLUDE_DIRS})
file(GLOB lib_cuda_hdrs "src/cuda/*.hpp")
ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs}) ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs})
source_group("Src\\Cuda" FILES ${lib_cuda_srcs} ${lib_cuda_hdrs}) source_group("Src\\Cuda" FILES ${lib_cuda_srcs} ${lib_cuda_hdrs})
endif()
else()
set(cuda_objs "")
set(lib_cuda_srcs "")
set(lib_cuda_hdrs "")
endif() endif()
file(GLOB cl_kernels "src/opencl/*.cl") file(GLOB cl_kernels "src/opencl/*.cl")
...@@ -516,8 +529,8 @@ macro(ocv_glob_module_sources) ...@@ -516,8 +529,8 @@ macro(ocv_glob_module_sources)
list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp") list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
endif() endif()
ocv_set_module_sources(${ARGN} HEADERS ${lib_hdrs} ${lib_hdrs_detail} ocv_set_module_sources(${_argn} HEADERS ${lib_hdrs} ${lib_hdrs_detail}
SOURCES ${lib_srcs} ${lib_int_hdrs} ${cuda_objs} ${lib_cuda_srcs} ${lib_cuda_hdrs}) SOURCES ${lib_srcs} ${lib_int_hdrs} ${cuda_objs} ${lib_cuda_srcs} ${lib_cuda_hdrs})
endmacro() endmacro()
# creates OpenCV module in current folder # creates OpenCV module in current folder
...@@ -622,11 +635,20 @@ endmacro() ...@@ -622,11 +635,20 @@ endmacro()
# short command for adding simple OpenCV module # short command for adding simple OpenCV module
# see ocv_add_module for argument details # see ocv_add_module for argument details
# Usage: # Usage:
# ocv_define_module(module_name [INTERNAL] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>]) # ocv_define_module(module_name [INTERNAL] [EXCLUDE_CUDA] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>])
macro(ocv_define_module module_name) macro(ocv_define_module module_name)
ocv_add_module(${module_name} ${ARGN}) set(_argn ${ARGN})
set(exclude_cuda "")
foreach(arg ${_argn})
if("${arg}" STREQUAL "EXCLUDE_CUDA")
set(exclude_cuda "${arg}")
list(REMOVE_ITEM _argn ${arg})
endif()
endforeach()
ocv_add_module(${module_name} ${_argn})
ocv_module_include_directories() ocv_module_include_directories()
ocv_glob_module_sources() ocv_glob_module_sources(${exclude_cuda})
ocv_create_module() ocv_create_module()
ocv_add_precompiled_headers(${the_module}) ocv_add_precompiled_headers(${the_module})
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
# This file will define the following variables: # This file will define the following variables:
# - OpenCV_LIBS : The list of all imported targets for OpenCV modules. # - OpenCV_LIBS : The list of all imported targets for OpenCV modules.
# - OpenCV_INCLUDE_DIRS : The OpenCV include directories. # - OpenCV_INCLUDE_DIRS : The OpenCV include directories.
# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability # - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability.
# - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API # - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API.
# - OpenCV_VERSION : The version of this OpenCV build: "@OPENCV_VERSION_PLAIN@" # - OpenCV_VERSION : The version of this OpenCV build: "@OPENCV_VERSION_PLAIN@"
# - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION: "@OPENCV_VERSION_MAJOR@" # - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION: "@OPENCV_VERSION_MAJOR@"
# - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION: "@OPENCV_VERSION_MINOR@" # - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION: "@OPENCV_VERSION_MINOR@"
...@@ -28,25 +28,29 @@ ...@@ -28,25 +28,29 @@
# - OpenCV_VERSION_STATUS : Development status of this build: "@OPENCV_VERSION_STATUS@" # - OpenCV_VERSION_STATUS : Development status of this build: "@OPENCV_VERSION_STATUS@"
# #
# Advanced variables: # Advanced variables:
# - OpenCV_SHARED # - OpenCV_SHARED : Use OpenCV as shared library
# - OpenCV_CONFIG_PATH # - OpenCV_CONFIG_PATH : Path to this OpenCVConfig.cmake
# - OpenCV_INSTALL_PATH (not set on Windows) # - OpenCV_INSTALL_PATH : OpenCV location (not set on Windows)
# - OpenCV_LIB_COMPONENTS # - OpenCV_LIB_COMPONENTS : Present OpenCV modules list
# - OpenCV_USE_MANGLED_PATHS # - OpenCV_USE_MANGLED_PATHS : Mangled OpenCV path flag
# - OpenCV_HAVE_ANDROID_CAMERA # - OpenCV_MODULES_SUFFIX : The suffix for OpenCVModules-XXX.cmake file
# - OpenCV_HAVE_ANDROID_CAMERA : Presence of Android native camera wrappers
# #
# Deprecated variables: # Deprecated variables:
# - OpenCV_VERSION_TWEAK : Always "0" # - OpenCV_VERSION_TWEAK : Always "0"
# #
# =================================================================================== # ===================================================================================
set(modules_file_suffix "") if(NOT DEFINED OpenCV_MODULES_SUFFIX)
if(ANDROID) if(ANDROID)
string(REPLACE - _ modules_file_suffix "_${ANDROID_NDK_ABI_NAME}") string(REPLACE - _ OpenCV_MODULES_SUFFIX "_${ANDROID_NDK_ABI_NAME}")
else()
set(OpenCV_MODULES_SUFFIX "")
endif()
endif() endif()
if(NOT TARGET opencv_core) if(NOT TARGET opencv_core)
include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${modules_file_suffix}.cmake) include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake)
endif() endif()
# TODO All things below should be reviewed. What is about of moving this code into related modules (special vars/hooks/files) # TODO All things below should be reviewed. What is about of moving this code into related modules (special vars/hooks/files)
......
...@@ -6,12 +6,12 @@ Adding (blending) two images using OpenCV ...@@ -6,12 +6,12 @@ Adding (blending) two images using OpenCV
Goal Goal
===== =====
In this tutorial you will learn how to: In this tutorial you will learn:
.. container:: enumeratevisibleitemswithsquare .. container:: enumeratevisibleitemswithsquare
* What is *linear blending* and why it is useful. * what is *linear blending* and why it is useful;
* Add two images using :add_weighted:`addWeighted <>` * how to add two images using :add_weighted:`addWeighted <>`
Theory Theory
======= =======
......
...@@ -18,7 +18,7 @@ We'll seek answers for the following questions: ...@@ -18,7 +18,7 @@ We'll seek answers for the following questions:
Our test case Our test case
============= =============
Let us consider a simple color reduction method. Using the unsigned char C and C++ type for matrix item storing a channel of pixel may have up to 256 different values. For a three channel image this can allow the formation of way too many colors (16 million to be exact). Working with so many color shades may give a heavy blow to our algorithm performance. However, sometimes it is enough to work with a lot less of them to get the same final result. Let us consider a simple color reduction method. By using the unsigned char C and C++ type for matrix item storing, a channel of pixel may have up to 256 different values. For a three channel image this can allow the formation of way too many colors (16 million to be exact). Working with so many color shades may give a heavy blow to our algorithm performance. However, sometimes it is enough to work with a lot less of them to get the same final result.
In this cases it's common that we make a *color space reduction*. This means that we divide the color space current value with a new input value to end up with fewer colors. For instance every value between zero and nine takes the new value zero, every value between ten and nineteen the value ten and so on. In this cases it's common that we make a *color space reduction*. This means that we divide the color space current value with a new input value to end up with fewer colors. For instance every value between zero and nine takes the new value zero, every value between ten and nineteen the value ten and so on.
......
...@@ -84,88 +84,10 @@ Code ...@@ -84,88 +84,10 @@ Code
* **Code at glance:** * **Code at glance:**
.. code-block:: cpp .. literalinclude:: ../../../../../samples/cpp/tutorial_code/Histograms_Matching/compareHist_Demo.cpp
:language: cpp
#include "opencv2/highgui.hpp" :tab-width: 4
#include "opencv2/imgproc.hpp"
#include <iostream>
#include <stdio.h>
using namespace std;
using namespace cv;
/** @function main */
int main( int argc, char** argv )
{
Mat src_base, hsv_base;
Mat src_test1, hsv_test1;
Mat src_test2, hsv_test2;
Mat hsv_half_down;
/// Load three images with different environment settings
if( argc < 4 )
{ printf("** Error. Usage: ./compareHist_Demo <image_settings0> <image_setting1> <image_settings2>\n");
return -1;
}
src_base = imread( argv[1], 1 );
src_test1 = imread( argv[2], 1 );
src_test2 = imread( argv[3], 1 );
/// Convert to HSV
cvtColor( src_base, hsv_base, CV_BGR2HSV );
cvtColor( src_test1, hsv_test1, CV_BGR2HSV );
cvtColor( src_test2, hsv_test2, CV_BGR2HSV );
hsv_half_down = hsv_base( Range( hsv_base.rows/2, hsv_base.rows - 1 ), Range( 0, hsv_base.cols - 1 ) );
/// Using 30 bins for hue and 32 for saturation
int h_bins = 50; int s_bins = 60;
int histSize[] = { h_bins, s_bins };
// hue varies from 0 to 256, saturation from 0 to 180
float h_ranges[] = { 0, 256 };
float s_ranges[] = { 0, 180 };
const float* ranges[] = { h_ranges, s_ranges };
// Use the o-th and 1-st channels
int channels[] = { 0, 1 };
/// Histograms
MatND hist_base;
MatND hist_half_down;
MatND hist_test1;
MatND hist_test2;
/// Calculate the histograms for the HSV images
calcHist( &hsv_base, 1, channels, Mat(), hist_base, 2, histSize, ranges, true, false );
normalize( hist_base, hist_base, 0, 1, NORM_MINMAX, -1, Mat() );
calcHist( &hsv_half_down, 1, channels, Mat(), hist_half_down, 2, histSize, ranges, true, false );
normalize( hist_half_down, hist_half_down, 0, 1, NORM_MINMAX, -1, Mat() );
calcHist( &hsv_test1, 1, channels, Mat(), hist_test1, 2, histSize, ranges, true, false );
normalize( hist_test1, hist_test1, 0, 1, NORM_MINMAX, -1, Mat() );
calcHist( &hsv_test2, 1, channels, Mat(), hist_test2, 2, histSize, ranges, true, false );
normalize( hist_test2, hist_test2, 0, 1, NORM_MINMAX, -1, Mat() );
/// Apply the histogram comparison methods
for( int i = 0; i < 4; i++ )
{ int compare_method = i;
double base_base = compareHist( hist_base, hist_base, compare_method );
double base_half = compareHist( hist_base, hist_half_down, compare_method );
double base_test1 = compareHist( hist_base, hist_test1, compare_method );
double base_test2 = compareHist( hist_base, hist_test2, compare_method );
printf( " Method [%d] Perfect, Base-Half, Base-Test(1), Base-Test(2) : %f, %f, %f, %f \n", i, base_base, base_half , base_test1, base_test2 );
}
printf( "Done \n" );
return 0;
}
Explanation Explanation
...@@ -211,11 +133,11 @@ Explanation ...@@ -211,11 +133,11 @@ Explanation
.. code-block:: cpp .. code-block:: cpp
int h_bins = 50; int s_bins = 32; int h_bins = 50; int s_bins = 60;
int histSize[] = { h_bins, s_bins }; int histSize[] = { h_bins, s_bins };
float h_ranges[] = { 0, 256 }; float h_ranges[] = { 0, 180 };
float s_ranges[] = { 0, 180 }; float s_ranges[] = { 0, 256 };
const float* ranges[] = { h_ranges, s_ranges }; const float* ranges[] = { h_ranges, s_ranges };
......
...@@ -58,7 +58,7 @@ SET_TARGET_PROPERTIES(${the_target} PROPERTIES ...@@ -58,7 +58,7 @@ SET_TARGET_PROPERTIES(${the_target} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
) )
if (NOT (CMAKE_BUILD_TYPE MATCHES "debug")) if (NOT (CMAKE_BUILD_TYPE MATCHES "Debug"))
ADD_CUSTOM_COMMAND( TARGET ${the_target} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${LIBRARY_OUTPUT_PATH}/lib${the_target}.so" ) ADD_CUSTOM_COMMAND( TARGET ${the_target} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${LIBRARY_OUTPUT_PATH}/lib${the_target}.so" )
endif() endif()
......
...@@ -15,7 +15,9 @@ enum { ...@@ -15,7 +15,9 @@ enum {
ANDROID_CAMERA_PROPERTY_FOCAL_LENGTH = 105, ANDROID_CAMERA_PROPERTY_FOCAL_LENGTH = 105,
ANDROID_CAMERA_PROPERTY_FOCUS_DISTANCE_NEAR = 106, ANDROID_CAMERA_PROPERTY_FOCUS_DISTANCE_NEAR = 106,
ANDROID_CAMERA_PROPERTY_FOCUS_DISTANCE_OPTIMAL = 107, ANDROID_CAMERA_PROPERTY_FOCUS_DISTANCE_OPTIMAL = 107,
ANDROID_CAMERA_PROPERTY_FOCUS_DISTANCE_FAR = 108 ANDROID_CAMERA_PROPERTY_FOCUS_DISTANCE_FAR = 108,
ANDROID_CAMERA_PROPERTY_EXPOSE_LOCK = 109,
ANDROID_CAMERA_PROPERTY_WHITEBALANCE_LOCK = 110
}; };
...@@ -30,12 +32,12 @@ enum { ...@@ -30,12 +32,12 @@ enum {
enum { enum {
ANDROID_CAMERA_FOCUS_MODE_AUTO = 0, ANDROID_CAMERA_FOCUS_MODE_AUTO = 0,
ANDROID_CAMERA_FOCUS_MODE_CONTINUOUS_PICTURE,
ANDROID_CAMERA_FOCUS_MODE_CONTINUOUS_VIDEO, ANDROID_CAMERA_FOCUS_MODE_CONTINUOUS_VIDEO,
ANDROID_CAMERA_FOCUS_MODE_EDOF, ANDROID_CAMERA_FOCUS_MODE_EDOF,
ANDROID_CAMERA_FOCUS_MODE_FIXED, ANDROID_CAMERA_FOCUS_MODE_FIXED,
ANDROID_CAMERA_FOCUS_MODE_INFINITY, ANDROID_CAMERA_FOCUS_MODE_INFINITY,
ANDROID_CAMERA_FOCUS_MODE_MACRO, ANDROID_CAMERA_FOCUS_MODE_MACRO,
ANDROID_CAMERA_FOCUS_MODE_CONTINUOUS_PICTURE,
ANDROID_CAMERA_FOCUS_MODES_NUM ANDROID_CAMERA_FOCUS_MODES_NUM
}; };
......
...@@ -4824,7 +4824,7 @@ cvRegisterType( const CvTypeInfo* _info ) ...@@ -4824,7 +4824,7 @@ cvRegisterType( const CvTypeInfo* _info )
"Type name should contain only letters, digits, - and _" ); "Type name should contain only letters, digits, - and _" );
} }
info = (CvTypeInfo*)malloc( sizeof(*info) + len + 1 ); info = (CvTypeInfo*)cvAlloc( sizeof(*info) + len + 1 );
*info = *_info; *info = *_info;
info->type_name = (char*)(info + 1); info->type_name = (char*)(info + 1);
...@@ -4862,7 +4862,7 @@ cvUnregisterType( const char* type_name ) ...@@ -4862,7 +4862,7 @@ cvUnregisterType( const char* type_name )
if( !CvType::first || !CvType::last ) if( !CvType::first || !CvType::last )
CvType::first = CvType::last = 0; CvType::first = CvType::last = 0;
free( info ); cvFree( &info );
} }
} }
......
...@@ -163,7 +163,7 @@ namespace cv { namespace cuda { namespace device ...@@ -163,7 +163,7 @@ namespace cv { namespace cuda { namespace device
{ {
//need only weight if fit is found //need only weight if fit is found
float weight = alpha1 * gmm_weight(mode * frame.rows + y, x) + prune; float weight = alpha1 * gmm_weight(mode * frame.rows + y, x) + prune;
int swap_count = 0;
//fit not found yet //fit not found yet
if (!fitsPDF) if (!fitsPDF)
{ {
...@@ -214,6 +214,7 @@ namespace cv { namespace cuda { namespace device ...@@ -214,6 +214,7 @@ namespace cv { namespace cuda { namespace device
if (weight < gmm_weight((i - 1) * frame.rows + y, x)) if (weight < gmm_weight((i - 1) * frame.rows + y, x))
break; break;
swap_count++;
//swap one up //swap one up
swap(gmm_weight, x, y, i - 1, frame.rows); swap(gmm_weight, x, y, i - 1, frame.rows);
swap(gmm_variance, x, y, i - 1, frame.rows); swap(gmm_variance, x, y, i - 1, frame.rows);
...@@ -231,7 +232,7 @@ namespace cv { namespace cuda { namespace device ...@@ -231,7 +232,7 @@ namespace cv { namespace cuda { namespace device
nmodes--; nmodes--;
} }
gmm_weight(mode * frame.rows + y, x) = weight; //update weight by the calculated value gmm_weight((mode - swap_count) * frame.rows + y, x) = weight; //update weight by the calculated value
totalWeight += weight; totalWeight += weight;
} }
......
...@@ -758,10 +758,13 @@ private: ...@@ -758,10 +758,13 @@ private:
for (int k=0; k<indices_length; ++k) { for (int k=0; k<indices_length; ++k) {
if (belongs_to[k]==j) { if (belongs_to[k]==j) {
belongs_to[k] = i; // for cluster j, we move the furthest element from the center to the empty cluster i
count[j]--; if ( distance_(dataset_[indices[k]], dcenters[j], veclen_) == radiuses[j] ) {
count[i]++; belongs_to[k] = i;
break; count[j]--;
count[i]++;
break;
}
} }
} }
converged = false; converged = false;
......
...@@ -483,7 +483,7 @@ VideoWriter constructors ...@@ -483,7 +483,7 @@ VideoWriter constructors
:param filename: Name of the output video file. :param filename: Name of the output video file.
:param fourcc: 4-character code of codec used to compress the frames. For example, ``CV_FOURCC('P','I','M,'1')`` is a MPEG-1 codec, ``CV_FOURCC('M','J','P','G')`` is a motion-jpeg codec etc. List of codes can be obtained at `Video Codecs by FOURCC <http://www.fourcc.org/codecs.php>`_ page. :param fourcc: 4-character code of codec used to compress the frames. For example, ``CV_FOURCC('P','I','M','1')`` is a MPEG-1 codec, ``CV_FOURCC('M','J','P','G')`` is a motion-jpeg codec etc. List of codes can be obtained at `Video Codecs by FOURCC <http://www.fourcc.org/codecs.php>`_ page.
:param fps: Framerate of the created video stream. :param fps: Framerate of the created video stream.
......
...@@ -463,6 +463,8 @@ enum ...@@ -463,6 +463,8 @@ enum
CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_NEAR = 8006, CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_NEAR = 8006,
CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_OPTIMAL = 8007, CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_OPTIMAL = 8007,
CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_FAR = 8008, CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_FAR = 8008,
CV_CAP_PROP_ANDROID_EXPOSE_LOCK = 8009,
CV_CAP_PROP_ANDROID_WHITEBALANCE_LOCK = 8010,
// Properties of cameras available through AVFOUNDATION interface // Properties of cameras available through AVFOUNDATION interface
CV_CAP_PROP_IOS_DEVICE_FOCUS = 9001, CV_CAP_PROP_IOS_DEVICE_FOCUS = 9001,
...@@ -543,6 +545,7 @@ enum ...@@ -543,6 +545,7 @@ enum
enum enum
{ {
CV_CAP_ANDROID_FOCUS_MODE_AUTO = 0, CV_CAP_ANDROID_FOCUS_MODE_AUTO = 0,
CV_CAP_ANDROID_FOCUS_MODE_CONTINUOUS_PICTURE,
CV_CAP_ANDROID_FOCUS_MODE_CONTINUOUS_VIDEO, CV_CAP_ANDROID_FOCUS_MODE_CONTINUOUS_VIDEO,
CV_CAP_ANDROID_FOCUS_MODE_EDOF, CV_CAP_ANDROID_FOCUS_MODE_EDOF,
CV_CAP_ANDROID_FOCUS_MODE_FIXED, CV_CAP_ANDROID_FOCUS_MODE_FIXED,
......
...@@ -289,6 +289,10 @@ double CvCapture_Android::getProperty( int propIdx ) ...@@ -289,6 +289,10 @@ double CvCapture_Android::getProperty( int propIdx )
return (double)m_activity->getProperty(ANDROID_CAMERA_PROPERTY_FOCUS_DISTANCE_OPTIMAL); return (double)m_activity->getProperty(ANDROID_CAMERA_PROPERTY_FOCUS_DISTANCE_OPTIMAL);
case CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_FAR: case CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_FAR:
return (double)m_activity->getProperty(ANDROID_CAMERA_PROPERTY_FOCUS_DISTANCE_FAR); return (double)m_activity->getProperty(ANDROID_CAMERA_PROPERTY_FOCUS_DISTANCE_FAR);
case CV_CAP_PROP_ANDROID_EXPOSE_LOCK:
return (double)m_activity->getProperty(ANDROID_CAMERA_PROPERTY_EXPOSE_LOCK);
case CV_CAP_PROP_ANDROID_WHITEBALANCE_LOCK:
return (double)m_activity->getProperty(ANDROID_CAMERA_PROPERTY_WHITEBALANCE_LOCK);
default: default:
CV_Error( CV_StsOutOfRange, "Failed attempt to GET unsupported camera property." ); CV_Error( CV_StsOutOfRange, "Failed attempt to GET unsupported camera property." );
break; break;
...@@ -327,14 +331,23 @@ bool CvCapture_Android::setProperty( int propIdx, double propValue ) ...@@ -327,14 +331,23 @@ bool CvCapture_Android::setProperty( int propIdx, double propValue )
case CV_CAP_PROP_ANDROID_ANTIBANDING: case CV_CAP_PROP_ANDROID_ANTIBANDING:
m_activity->setProperty(ANDROID_CAMERA_PROPERTY_ANTIBANDING, propValue); m_activity->setProperty(ANDROID_CAMERA_PROPERTY_ANTIBANDING, propValue);
break; break;
case CV_CAP_PROP_ANDROID_EXPOSE_LOCK:
m_activity->setProperty(ANDROID_CAMERA_PROPERTY_EXPOSE_LOCK, propValue);
break;
case CV_CAP_PROP_ANDROID_WHITEBALANCE_LOCK:
m_activity->setProperty(ANDROID_CAMERA_PROPERTY_WHITEBALANCE_LOCK, propValue);
break;
default: default:
CV_Error( CV_StsOutOfRange, "Failed attempt to SET unsupported camera property." ); CV_Error( CV_StsOutOfRange, "Failed attempt to SET unsupported camera property." );
return false; return false;
} }
if (propIdx != CV_CAP_PROP_AUTOGRAB) {// property for highgui class CvCapture_Android only // Only changes in frame size require camera restart
if ((propIdx == CV_CAP_PROP_FRAME_WIDTH) || (propIdx == CV_CAP_PROP_FRAME_HEIGHT))
{ // property for highgui class CvCapture_Android only
m_CameraParamsChanged = true; m_CameraParamsChanged = true;
} }
res = true; res = true;
} }
......
...@@ -175,7 +175,6 @@ public class NativeCameraView extends CameraBridgeViewBase { ...@@ -175,7 +175,6 @@ public class NativeCameraView extends CameraBridgeViewBase {
} }
deliverAndDrawFrame(mFrame); deliverAndDrawFrame(mFrame);
} while (!mStopThread); } while (!mStopThread);
} }
} }
......
...@@ -9,12 +9,13 @@ ...@@ -9,12 +9,13 @@
#ifndef __OPENCV_PERF_PRECOMP_HPP__ #ifndef __OPENCV_PERF_PRECOMP_HPP__
#define __OPENCV_PERF_PRECOMP_HPP__ #define __OPENCV_PERF_PRECOMP_HPP__
#include "cvconfig.h"
#include "opencv2/ts.hpp" #include "opencv2/ts.hpp"
#include "opencv2/nonfree.hpp" #include "opencv2/nonfree.hpp"
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
#include "opencv2/opencv_modules.hpp" #include "opencv2/opencv_modules.hpp"
#include "cvconfig.h"
#ifdef HAVE_OPENCV_OCL #ifdef HAVE_OPENCV_OCL
# include "opencv2/nonfree/ocl.hpp" # include "opencv2/nonfree/ocl.hpp"
......
if(ANDROID OR IOS) if(IOS)
ocv_module_disable(superres) ocv_module_disable(superres)
endif() endif()
......
...@@ -578,7 +578,7 @@ public: ...@@ -578,7 +578,7 @@ public:
for( int mode = 0; mode < nmodes; mode++, mean_m += nchannels ) for( int mode = 0; mode < nmodes; mode++, mean_m += nchannels )
{ {
float weight = alpha1*gmm[mode].weight + prune;//need only weight if fit is found float weight = alpha1*gmm[mode].weight + prune;//need only weight if fit is found
int swap_count = 0;
//// ////
//fit not found yet //fit not found yet
if( !fitsPDF ) if( !fitsPDF )
...@@ -643,6 +643,7 @@ public: ...@@ -643,6 +643,7 @@ public:
if( weight < gmm[i-1].weight ) if( weight < gmm[i-1].weight )
break; break;
swap_count++;
//swap one up //swap one up
std::swap(gmm[i], gmm[i-1]); std::swap(gmm[i], gmm[i-1]);
for( int c = 0; c < nchannels; c++ ) for( int c = 0; c < nchannels; c++ )
...@@ -660,7 +661,7 @@ public: ...@@ -660,7 +661,7 @@ public:
nmodes--; nmodes--;
} }
gmm[mode].weight = weight;//update weight by the calculated value gmm[mode-swap_count].weight = weight;//update weight by the calculated value
totalWeight += weight; totalWeight += weight;
} }
//go through all modes //go through all modes
...@@ -918,4 +919,4 @@ Ptr<BackgroundSubtractorMOG2> createBackgroundSubtractorMOG2(int _history, doubl ...@@ -918,4 +919,4 @@ Ptr<BackgroundSubtractorMOG2> createBackgroundSubtractorMOG2(int _history, doubl
} }
/* End of file. */ /* End of file. */
\ No newline at end of file
...@@ -102,7 +102,7 @@ __kernel void mog2_kernel(__global const uchar* frame, int frame_step, int frame ...@@ -102,7 +102,7 @@ __kernel void mog2_kernel(__global const uchar* frame, int frame_step, int frame
{ {
float c_weight = alpha1 * _weight[(mode * frame_row + y) * weight_step + x] + prune; float c_weight = alpha1 * _weight[(mode * frame_row + y) * weight_step + x] + prune;
int swap_count = 0;
if (!fitsPDF) if (!fitsPDF)
{ {
float c_var = _variance[(mode * frame_row + y) * var_step + x]; float c_var = _variance[(mode * frame_row + y) * var_step + x];
...@@ -132,6 +132,7 @@ __kernel void mog2_kernel(__global const uchar* frame, int frame_step, int frame ...@@ -132,6 +132,7 @@ __kernel void mog2_kernel(__global const uchar* frame, int frame_step, int frame
{ {
if (c_weight < _weight[((i - 1) * frame_row + y) * weight_step + x]) if (c_weight < _weight[((i - 1) * frame_row + y) * weight_step + x])
break; break;
swap_count++;
swap(_weight, x, y, i - 1, frame_row, weight_step); swap(_weight, x, y, i - 1, frame_row, weight_step);
swap(_variance, x, y, i - 1, frame_row, var_step); swap(_variance, x, y, i - 1, frame_row, var_step);
#if (CN==1) #if (CN==1)
...@@ -149,7 +150,7 @@ __kernel void mog2_kernel(__global const uchar* frame, int frame_step, int frame ...@@ -149,7 +150,7 @@ __kernel void mog2_kernel(__global const uchar* frame, int frame_step, int frame
nmodes--; nmodes--;
} }
_weight[(mode * frame_row + y) * weight_step + x] = c_weight; //update weight by the calculated value _weight[((mode - swap_count) * frame_row + y) * weight_step + x] = c_weight; //update weight by the calculated value
totalWeight += c_weight; totalWeight += c_weight;
} }
......
...@@ -1050,7 +1050,7 @@ viz::WWidgetMerger::WWidgetMerger ...@@ -1050,7 +1050,7 @@ viz::WWidgetMerger::WWidgetMerger
--------------------------------------- ---------------------------------------
Constructs a WWidgetMerger. Constructs a WWidgetMerger.
.. ocv:WWidgetMerger:: WWidgetMerger() .. ocv:function:: WWidgetMerger()
viz::WWidgetMerger::addCloud viz::WWidgetMerger::addCloud
------------------------------- -------------------------------
......
...@@ -40,13 +40,13 @@ int main( int argc, char** argv ) ...@@ -40,13 +40,13 @@ int main( int argc, char** argv )
hsv_half_down = hsv_base( Range( hsv_base.rows/2, hsv_base.rows - 1 ), Range( 0, hsv_base.cols - 1 ) ); hsv_half_down = hsv_base( Range( hsv_base.rows/2, hsv_base.rows - 1 ), Range( 0, hsv_base.cols - 1 ) );
/// Using 30 bins for hue and 32 for saturation /// Using 50 bins for hue and 60 for saturation
int h_bins = 50; int s_bins = 60; int h_bins = 50; int s_bins = 60;
int histSize[] = { h_bins, s_bins }; int histSize[] = { h_bins, s_bins };
// hue varies from 0 to 256, saturation from 0 to 180 // hue varies from 0 to 179, saturation from 0 to 255
float s_ranges[] = { 0, 256 };
float h_ranges[] = { 0, 180 }; float h_ranges[] = { 0, 180 };
float s_ranges[] = { 0, 256 };
const float* ranges[] = { h_ranges, s_ranges }; const float* ranges[] = { h_ranges, s_ranges };
......
...@@ -49,8 +49,8 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) ...@@ -49,8 +49,8 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS}) target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
if(HAVE_CUDA) if(HAVE_CUDA AND NOT ANDROID)
target_link_libraries(${the_target} ${CUDA_CUDA_LIBRARY}) target_link_libraries(${the_target} ${CUDA_CUDA_LIBRARY})
endif() endif()
if(HAVE_opencv_nonfree) if(HAVE_opencv_nonfree)
......
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <string> #include <string>
#include <cctype> #include <ctype.h>
#include "opencv2/core.hpp" #include "opencv2/core.hpp"
#include "opencv2/core/utility.hpp" #include "opencv2/core/utility.hpp"
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include <exception> #include <exception>
#include <ctime> #include <ctime>
#include <ctype.h>
#include "cvconfig.h" #include "cvconfig.h"
#include <iostream> #include <iostream>
......
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <string> #include <string>
#include <ctype.h>
#include "opencv2/core.hpp" #include "opencv2/core.hpp"
#include "opencv2/core/utility.hpp" #include "opencv2/core/utility.hpp"
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment