Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.4' into merge-2.4
Browse files Browse the repository at this point in the history
Conflicts:
	doc/tutorials/introduction/linux_install/linux_install.rst
	modules/core/doc/operations_on_arrays.rst
	modules/core/include/opencv2/core/core.hpp
	modules/core/src/system.cpp
	modules/gpu/src/cuda/resize.cu
	modules/imgproc/doc/miscellaneous_transformations.rst
	modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst
	modules/video/src/bgfg_gaussmix2.cpp
  • Loading branch information
Roman Donchenko committed May 19, 2014
2 parents c6113c6 + 0b4eb6a commit 3d7a457
Show file tree
Hide file tree
Showing 26 changed files with 248 additions and 96 deletions.
10 changes: 7 additions & 3 deletions cmake/templates/OpenCVConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ set(OpenCV_USE_CUFFT @HAVE_CUFFT@)
set(OpenCV_USE_NVCUVID @HAVE_NVCUVID@)

# Android API level from which OpenCV has been compiled is remembered
set(OpenCV_ANDROID_NATIVE_API_LEVEL @OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE@)
if(ANDROID)
set(OpenCV_ANDROID_NATIVE_API_LEVEL @OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE@)
else()
set(OpenCV_ANDROID_NATIVE_API_LEVEL 0)
endif()

# Some additional settings are required if OpenCV is built as static libs
set(OpenCV_SHARED @BUILD_SHARED_LIBS@)
Expand All @@ -75,8 +79,8 @@ set(OpenCV_USE_MANGLED_PATHS @OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE@)
# Extract the directory where *this* file has been installed (determined at cmake run-time)
get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE)

if(NOT WIN32 OR OpenCV_ANDROID_NATIVE_API_LEVEL GREATER 0)
if(OpenCV_ANDROID_NATIVE_API_LEVEL GREATER 0)
if(NOT WIN32 OR ANDROID)
if(ANDROID)
set(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../../..")
else()
set(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../..")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Explanation
image.convertTo(new_image, -1, alpha, beta);
where :convert_to:`convertTo <>` would effectively perform *new_image = a*image + beta*. However, we wanted to show you how to access each pixel. In any case, both methods give the same result.
where :convert_to:`convertTo <>` would effectively perform *new_image = a*image + beta*. However, we wanted to show you how to access each pixel. In any case, both methods give the same result but convertTo is more optimized and works a lot faster.

Result
=======
Expand Down
28 changes: 15 additions & 13 deletions doc/tutorials/introduction/linux_install/linux_install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ These steps have been tested for Ubuntu 10.04 but should work with other distros
Required Packages
=================

* GCC 4.4.x or later. This can be installed with:
* GCC 4.4.x or later
* CMake 2.8.7 or higher
* Git
* GTK+2.x or higher, including headers (libgtk2.0-dev)
* pkg-config
* Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)
* ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
* [optional] libtbb2 libtbb-dev
* [optional] libdc1394 2.x
* [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev

The packages can be installed using a terminal and the following commands or by using Synaptic Manager:

.. code-block:: bash
sudo apt-get install build-essential
* CMake 2.8.7 or higher;
* Git;
* GTK+2.x or higher, including headers (libgtk2.0-dev);
* pkg-config;
* Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy);
* ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev;
* [optional] libdc1394 2.x;
* [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev.

All the libraries above can be installed via Terminal or by using Synaptic Manager.
[compiler] sudo apt-get install build-essential
[required] sudo apt-get install cmake git libgtk2-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
[optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
Getting OpenCV Source Code
==========================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ Make sure your active solution configuration (:menuselection:`Build --> Configur

Build your solution (:menuselection:`Build --> Build Solution`, or press *F7*).

Before continuing, do not forget to add the command line argument of your input image to your project (:menuselection:`Right click on project --> Properties --> Configuration Properties --> Debugging` and then set the field ``Command Arguments`` with the location of the image).

Now set a breakpoint on the source line that says

.. code-block:: c++
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorials/ml/introduction_to_svm/introduction_to_svm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ Explanation

.. code-block:: cpp
Mat trainingDataMat(3, 2, CV_32FC1, trainingData);
Mat labelsMat (3, 1, CV_32FC1, labels);
Mat trainingDataMat(4, 2, CV_32FC1, trainingData);
Mat labelsMat (4, 1, CV_32FC1, labels);
2. **Set up SVM's parameters**

Expand Down
12 changes: 9 additions & 3 deletions modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,25 @@ Computes useful camera characteristics from the camera matrix.

:param imageSize: Input image size in pixels.

:param apertureWidth: Physical width of the sensor.
:param apertureWidth: Physical width in mm of the sensor.

:param apertureHeight: Physical height of the sensor.
:param apertureHeight: Physical height in mm of the sensor.

:param fovx: Output field of view in degrees along the horizontal sensor axis.

:param fovy: Output field of view in degrees along the vertical sensor axis.

:param focalLength: Focal length of the lens in mm.

:param principalPoint: Principal point in pixels.
:param principalPoint: Principal point in mm.

:param aspectRatio: :math:`f_y/f_x`

The function computes various useful camera characteristics from the previously estimated camera matrix.

.. note::

Do keep in mind that the unity measure 'mm' stands for whatever unit of measure one chooses for the chessboard pitch (it can thus be any value).

composeRT
-------------
Expand Down Expand Up @@ -1490,6 +1492,10 @@ Reconstructs points by triangulation.

The function reconstructs 3-dimensional points (in homogeneous coordinates) by using their observations with a stereo camera. Projections matrices can be obtained from :ocv:func:`stereoRectify`.

.. note::

Keep in mind that all input data should be of float type in order for this function to work.

.. seealso::

:ocv:func:`reprojectImageTo3D`
Expand Down
2 changes: 1 addition & 1 deletion modules/core/doc/drawing_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ Draws a text string.
:param font: ``CvFont`` structure initialized using :ocv:cfunc:`InitFont`.

:param fontFace: Font type. One of ``FONT_HERSHEY_SIMPLEX``, ``FONT_HERSHEY_PLAIN``, ``FONT_HERSHEY_DUPLEX``, ``FONT_HERSHEY_COMPLEX``, ``FONT_HERSHEY_TRIPLEX``, ``FONT_HERSHEY_COMPLEX_SMALL``, ``FONT_HERSHEY_SCRIPT_SIMPLEX``, or ``FONT_HERSHEY_SCRIPT_COMPLEX``,
where each of the font ID's can be combined with ``FONT_HERSHEY_ITALIC`` to get the slanted letters.
where each of the font ID's can be combined with ``FONT_ITALIC`` to get the slanted letters.

:param fontScale: Font scale factor that is multiplied by the font-specific base size.

Expand Down
4 changes: 2 additions & 2 deletions modules/core/doc/operations_on_arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1216,9 +1216,9 @@ gemm
----
Performs generalized matrix multiplication.

.. ocv:function:: void gemm( InputArray src1, InputArray src2, double alpha, InputArray src3, double gamma, OutputArray dst, int flags=0 )
.. ocv:function:: void gemm( InputArray src1, InputArray src2, double alpha, InputArray src3, double beta, OutputArray dst, int flags=0 )
.. ocv:pyfunction:: cv2.gemm(src1, src2, alpha, src3, gamma[, dst[, flags]]) -> dst
.. ocv:pyfunction:: cv2.gemm(src1, src2, alpha, src3, beta[, dst[, flags]]) -> dst
.. ocv:cfunction:: void cvGEMM( const CvArr* src1, const CvArr* src2, double alpha, const CvArr* src3, double beta, CvArr* dst, int tABC=0)
Expand Down
2 changes: 1 addition & 1 deletion modules/core/include/opencv2/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ CV_EXPORTS_W void patchNaNs(InputOutputArray a, double val = 0);

//! implements generalized matrix product algorithm GEMM from BLAS
CV_EXPORTS_W void gemm(InputArray src1, InputArray src2, double alpha,
InputArray src3, double gamma, OutputArray dst, int flags = 0);
InputArray src3, double beta, OutputArray dst, int flags = 0);

//! multiplies matrix by its transposition from the left or from the right
CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa,
Expand Down
14 changes: 8 additions & 6 deletions modules/core/src/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4050,16 +4050,18 @@ double cv::kmeans( InputArray _data, int K,
int flags, OutputArray _centers )
{
const int SPP_TRIALS = 3;
Mat data = _data.getMat();
bool isrow = data.rows == 1 && data.channels() > 1;
int N = !isrow ? data.rows : data.cols;
int dims = (!isrow ? data.cols : 1)*data.channels();
int type = data.depth();
Mat data0 = _data.getMat();
bool isrow = data0.rows == 1 && data0.channels() > 1;
int N = !isrow ? data0.rows : data0.cols;
int dims = (!isrow ? data0.cols : 1)*data0.channels();
int type = data0.depth();

attempts = std::max(attempts, 1);
CV_Assert( data.dims <= 2 && type == CV_32F && K > 0 );
CV_Assert( data0.dims <= 2 && type == CV_32F && K > 0 );
CV_Assert( N >= K );

Mat data(N, dims, CV_32F, data0.data, isrow ? dims * sizeof(float) : static_cast<size_t>(data0.step));

_bestLabels.create(N, 1, CV_32S, -1, true);

Mat _labels, best_labels = _bestLabels.getMat();
Expand Down
91 changes: 81 additions & 10 deletions modules/core/test/test_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2627,14 +2627,23 @@ TEST(Core_SVD, flt)

// TODO: eigenvv, invsqrt, cbrt, fastarctan, (round, floor, ceil(?)),

enum
{
MAT_N_DIM_C1,
MAT_N_1_CDIM,
MAT_1_N_CDIM,
MAT_N_DIM_C1_NONCONT,
MAT_N_1_CDIM_NONCONT,
VECTOR
};

class CV_KMeansSingularTest : public cvtest::BaseTest
{
public:
CV_KMeansSingularTest() {}
~CV_KMeansSingularTest() {}
protected:
void run(int)
void run(int inVariant)
{
int i, iter = 0, N = 0, N0 = 0, K = 0, dims = 0;
Mat labels;
Expand All @@ -2646,20 +2655,70 @@ class CV_KMeansSingularTest : public cvtest::BaseTest
for( iter = 0; iter < maxIter; iter++ )
{
ts->update_context(this, iter, true);
dims = rng.uniform(1, MAX_DIM+1);
dims = rng.uniform(inVariant == MAT_1_N_CDIM ? 2 : 1, MAX_DIM+1);
N = rng.uniform(1, MAX_POINTS+1);
N0 = rng.uniform(1, MAX(N/10, 2));
K = rng.uniform(1, N+1);

Mat data0(N0, dims, CV_32F);
rng.fill(data0, RNG::UNIFORM, -1, 1);
if (inVariant == VECTOR)
{
dims = 2;

Mat data(N, dims, CV_32F);
for( i = 0; i < N; i++ )
data0.row(rng.uniform(0, N0)).copyTo(data.row(i));
std::vector<cv::Point2f> data0(N0);
rng.fill(data0, RNG::UNIFORM, -1, 1);

std::vector<cv::Point2f> data(N);
for( i = 0; i < N; i++ )
data[i] = data0[rng.uniform(0, N0)];

kmeans(data, K, labels, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 30, 0),
5, KMEANS_PP_CENTERS);
}
else
{
Mat data0(N0, dims, CV_32F);
rng.fill(data0, RNG::UNIFORM, -1, 1);

kmeans(data, K, labels, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 30, 0),
5, KMEANS_PP_CENTERS);
Mat data;

switch (inVariant)
{
case MAT_N_DIM_C1:
data.create(N, dims, CV_32F);
for( i = 0; i < N; i++ )
data0.row(rng.uniform(0, N0)).copyTo(data.row(i));
break;

case MAT_N_1_CDIM:
data.create(N, 1, CV_32FC(dims));
for( i = 0; i < N; i++ )
memcpy(data.ptr(i), data0.ptr(rng.uniform(0, N0)), dims * sizeof(float));
break;

case MAT_1_N_CDIM:
data.create(1, N, CV_32FC(dims));
for( i = 0; i < N; i++ )
memcpy(data.data + i * dims * sizeof(float), data0.ptr(rng.uniform(0, N0)), dims * sizeof(float));
break;

case MAT_N_DIM_C1_NONCONT:
data.create(N, dims + 5, CV_32F);
data = data(Range(0, N), Range(0, dims));
for( i = 0; i < N; i++ )
data0.row(rng.uniform(0, N0)).copyTo(data.row(i));
break;

case MAT_N_1_CDIM_NONCONT:
data.create(N, 3, CV_32FC(dims));
data = data.colRange(0, 1);
for( i = 0; i < N; i++ )
memcpy(data.ptr(i), data0.ptr(rng.uniform(0, N0)), dims * sizeof(float));
break;
}

kmeans(data, K, labels, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 30, 0),
5, KMEANS_PP_CENTERS);
}

Mat hist(K, 1, CV_32S, Scalar(0));
for( i = 0; i < N; i++ )
Expand All @@ -2683,7 +2742,19 @@ class CV_KMeansSingularTest : public cvtest::BaseTest
}
};

TEST(Core_KMeans, singular) { CV_KMeansSingularTest test; test.safe_run(); }
TEST(Core_KMeans, singular) { CV_KMeansSingularTest test; test.safe_run(MAT_N_DIM_C1); }

CV_ENUM(KMeansInputVariant, MAT_N_DIM_C1, MAT_N_1_CDIM, MAT_1_N_CDIM, MAT_N_DIM_C1_NONCONT, MAT_N_1_CDIM_NONCONT, VECTOR)

typedef testing::TestWithParam<KMeansInputVariant> Core_KMeans_InputVariants;

TEST_P(Core_KMeans_InputVariants, singular)
{
CV_KMeansSingularTest test;
test.safe_run(GetParam());
}

INSTANTIATE_TEST_CASE_P(AllVariants, Core_KMeans_InputVariants, KMeansInputVariant::all());

TEST(CovariationMatrixVectorOfMat, accuracy)
{
Expand Down
2 changes: 1 addition & 1 deletion modules/cudawarping/src/cuda/resize.cu
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ namespace cv { namespace cuda { namespace device
const dim3 block(32, 8);
const dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y));

resize_linear<<<grid, block>>>(src, dst, fy, fx);
resize_linear<<<grid, block, 0, stream>>>(src, dst, fy, fx);
cudaSafeCall( cudaGetLastError() );

if (stream == 0)
Expand Down
8 changes: 6 additions & 2 deletions modules/flann/include/opencv2/flann/autotuned_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,22 @@ class AutotunedIndex : public NNIndex<Distance>
*/
virtual void buildIndex()
{
std::ostringstream stream;
bestParams_ = estimateBuildParams();
print_params(bestParams_, stream);
Logger::info("----------------------------------------------------\n");
Logger::info("Autotuned parameters:\n");
print_params(bestParams_);
Logger::info("%s", stream.str().c_str());
Logger::info("----------------------------------------------------\n");

bestIndex_ = create_index_by_type(dataset_, bestParams_, distance_);
bestIndex_->buildIndex();
speedup_ = estimateSearchParams(bestSearchParams_);
stream.str(std::string());
print_params(bestSearchParams_, stream);
Logger::info("----------------------------------------------------\n");
Logger::info("Search parameters:\n");
print_params(bestSearchParams_);
Logger::info("%s", stream.str().c_str());
Logger::info("----------------------------------------------------\n");
}

Expand Down
9 changes: 6 additions & 3 deletions modules/flann/include/opencv2/flann/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,19 @@ T get_param(const IndexParams& params, cv::String name)
}
}

inline void print_params(const IndexParams& params)
inline void print_params(const IndexParams& params, std::ostream& stream)
{
IndexParams::const_iterator it;

for(it=params.begin(); it!=params.end(); ++it) {
std::cout << it->first << " : " << it->second << std::endl;
stream << it->first << " : " << it->second << std::endl;
}
}


inline void print_params(const IndexParams& params)
{
print_params(params, std::cout);
}

}

Expand Down
4 changes: 2 additions & 2 deletions modules/highgui/src/cap_giganetix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,13 +711,13 @@ CvCaptureCAM_Giganetix::setProperty( int property_id, double value )
INT64 w, wmax, val = (INT64)value;
if((b_ret = m_device->GetIntegerNodeValue ("Width", w)))
if((b_ret = m_device->GetIntegerNodeValue ("WidthMax", wmax)))
b_ret = m_device->SetIntegerNodeValue ("OffsetX", val w > wmax ? wmax - w : val);
b_ret = m_device->SetIntegerNodeValue ("OffsetX", (val + w) > wmax ? (wmax - w) : val);
} break;
case CV_CAP_PROP_GIGA_FRAME_OFFSET_Y: {
INT64 h, hmax, val = (INT64)value;
if((b_ret = m_device->GetIntegerNodeValue ("Height", h)))
if((b_ret = m_device->GetIntegerNodeValue ("HeightMax", hmax)))
b_ret = m_device->SetIntegerNodeValue ("OffsetY", val h > hmax ? hmax - h : val);
b_ret = m_device->SetIntegerNodeValue ("OffsetY", (val + h) > hmax ? (hmax - h) : val);
b_ret = m_device->SetIntegerNodeValue ("OffsetY", (INT64)value);
}
break;
Expand Down
1 change: 1 addition & 0 deletions modules/highgui/src/cap_gstreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ bool CvCapture_GStreamer::open( int type, const char* filename )

#if GST_VERSION_MAJOR == 0
caps = gst_caps_new_simple("video/x-raw-rgb",
"bpp", G_TYPE_INT, 24,
"red_mask", G_TYPE_INT, 0x0000FF,
"green_mask", G_TYPE_INT, 0x00FF00,
"blue_mask", G_TYPE_INT, 0xFF0000,
Expand Down
Loading

0 comments on commit 3d7a457

Please sign in to comment.