1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-25 05:13:04 +04:00

Compare commits

...

16 Commits

Author SHA1 Message Date
Alexander Alekhin 82f8176b06 Merge pull request #14676 from 103yiran:103yiran-clang 2019-05-30 14:19:14 +03:00
103yiran a03b7575ba make it compatible with clang 2019-05-30 14:04:40 +08:00
Alexander Alekhin 8bae39ce8a Merge pull request #13669 from alalek:test_eigen_relax_eps_2.4 2019-01-21 18:32:22 +03:00
Alexander Alekhin aa89881321 Merge pull request #13665 from alalek:backport_8294_flann_rand 2019-01-21 15:33:37 +03:00
Alexander Alekhin 30b01a2d29 core(test): relax eigen eps value: 0.01 -> 0.02 2019-01-21 15:18:10 +03:00
Alexander Alekhin dc328451eb flann: use OpenCV theRNG()
std::rand() has no thread-safe guarantee.

backport commit: 147f3ebf0a
2019-01-21 13:45:08 +03:00
Alexander Alekhin a49600cb24 Merge pull request #13510 from knsong:2.4 2018-12-25 13:08:02 +03:00
Kangning Song 0157ff0bc3 fix initial values bug 2018-12-23 11:29:42 +08:00
Alexander Alekhin 7e71666a0b Merge pull request #13448 from alalek:issue_13445_2.4 2018-12-16 00:17:39 +03:00
Alexander Alekhin 7b677bb017 videoio(dc1394): use lazy initialization on demand
backport eb1f3733ee into 2.4
2018-12-15 08:09:22 +00:00
Alexander Alekhin 9b954de175 Merge pull request #13265 from xusiwei:2.4 2018-11-25 12:12:09 +00:00
Siwei Xu 7f3af2b2d9 androidcamera: add a missing header.
fix #11699 Missing std header
2018-11-24 01:31:50 +08:00
Alexander Alekhin fd63c60418 Merge pull request #12181 from alalek:fix_gpu_sparse_multi_definition 2018-08-08 18:38:30 +03:00
Alexander Alekhin 1c34941537 Merge pull request #12179 from alalek:fix_gpu_samples_2.4 2018-08-08 18:37:12 +03:00
Alexander Alekhin b0f0194595 gpu(sparse_multi): fix definition without TBB 2018-08-08 16:26:55 +03:00
Alexander Alekhin 8484c8af7c samples(gpu): fix build (invalid access to cvconfig.h from sample)
via find_package(OpenCV)
2018-08-08 16:26:18 +03:00
11 changed files with 69 additions and 21 deletions
@@ -5,8 +5,10 @@
#include <android/log.h>
#include <cctype>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <opencv2/core/version.hpp>
#include "camera_activity.hpp"
#include "camera_wrapper.h"
+1 -1
View File
@@ -164,7 +164,7 @@ void Core_EigenTest_32::run(int) { check_full(CV_32FC1); }
void Core_EigenTest_64::run(int) { check_full(CV_64FC1); }
Core_EigenTest::Core_EigenTest()
: eps_val_32(1e-3f), eps_vec_32(1e-2f),
: eps_val_32(1e-3f), eps_vec_32(2e-2f),
eps_val_64(1e-4f), eps_vec_64(1e-3f), ntests(100) {}
Core_EigenTest::~Core_EigenTest() {}
@@ -132,7 +132,12 @@ public:
/* Construct the randomized trees. */
for (int i = 0; i < trees_; i++) {
/* Randomize the order of vectors to allow for unbiased sampling. */
#ifndef OPENCV_FLANN_USE_STD_RAND
cv::randShuffle(vind_);
#else
std::random_shuffle(vind_.begin(), vind_.end());
#endif
tree_roots_[i] = divideTree(&vind_[0], int(size_) );
}
}
@@ -136,7 +136,12 @@ public:
indices.resize( feature_size_ * CHAR_BIT );
for (size_t j = 0; j < feature_size_ * CHAR_BIT; ++j)
indices[j] = j;
#ifndef OPENCV_FLANN_USE_STD_RAND
cv::randShuffle(indices);
#else
std::random_shuffle(indices.begin(), indices.end());
#endif
}
lsh::LshTable<ElementType>& table = tables_[i];
+25 -3
View File
@@ -40,13 +40,31 @@
namespace cvflann
{
inline int rand()
{
#ifndef OPENCV_FLANN_USE_STD_RAND
# if INT_MAX == RAND_MAX
int v = cv::theRNG().next() & INT_MAX;
# else
int v = cv::theRNG().uniform(0, RAND_MAX + 1);
# endif
#else
int v = std::rand();
#endif // OPENCV_FLANN_USE_STD_RAND
return v;
}
/**
* Seeds the random number generator
* @param seed Random seed
*/
inline void seed_random(unsigned int seed)
{
srand(seed);
#ifndef OPENCV_FLANN_USE_STD_RAND
cv::theRNG() = cv::RNG(seed);
#else
std::srand(seed);
#endif
}
/*
@@ -60,7 +78,7 @@ inline void seed_random(unsigned int seed)
*/
inline double rand_double(double high = 1.0, double low = 0)
{
return low + ((high-low) * (std::rand() / (RAND_MAX + 1.0)));
return low + ((high-low) * (rand() / (RAND_MAX + 1.0)));
}
/**
@@ -71,7 +89,7 @@ inline double rand_double(double high = 1.0, double low = 0)
*/
inline int rand_int(int high = RAND_MAX, int low = 0)
{
return low + (int) ( double(high-low) * (std::rand() / (RAND_MAX + 1.0)));
return low + (int) ( double(high-low) * (rand() / (RAND_MAX + 1.0)));
}
/**
@@ -107,7 +125,11 @@ public:
for (int i = 0; i < size_; ++i) vals_[i] = i;
// shuffle the elements in the array
#ifndef OPENCV_FLANN_USE_STD_RAND
cv::randShuffle(vals_);
#else
std::random_shuffle(vals_.begin(), vals_.end());
#endif
counter_ = 0;
}
-9
View File
@@ -60,10 +60,6 @@
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#if !defined(HAVE_TBB)
#define throw_notbb() CV_Error(CV_StsNotImplemented, "The library is compiled without TBB support")
#endif
namespace cv { namespace gpu {
//////////////////////////////// CudaMem ////////////////////////////////
@@ -1828,13 +1824,8 @@ public:
void sparse(const GpuMat& prevImg, const GpuMat& nextImg, const GpuMat& prevPts, GpuMat& nextPts,
GpuMat& status, GpuMat* err = 0);
#if !defined(HAVE_TBB)
void sparse_multi(const GpuMat&, const GpuMat&, const GpuMat&, GpuMat&,
GpuMat&, Stream&, GpuMat*) {throw_notbb();}
#else
void sparse_multi(const GpuMat& prevImg, const GpuMat& nextImg, const GpuMat& prevPts, GpuMat& nextPts,
GpuMat& status, Stream& stream, GpuMat* err = 0);
#endif
void dense(const GpuMat& prevImg, const GpuMat& nextImg, GpuMat& u, GpuMat& v, GpuMat* err = 0);
+1 -1
View File
@@ -306,7 +306,7 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse
//////////////////////////////////////////////////////
// PyrLKOpticalFlowSparseMulti
#ifdef HAVE_TBB
#if defined(HAVE_TBB) && defined(HAVE_CUDA)
DEF_PARAM_TEST(ImagePair_Gray_NPts_WinSz_Levels_Iters, pair_string, bool, int, int, int, int);
+9
View File
@@ -53,6 +53,7 @@ using namespace cv::gpu;
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
cv::gpu::PyrLKOpticalFlow::PyrLKOpticalFlow() { throw_nogpu(); }
void cv::gpu::PyrLKOpticalFlow::sparse(const GpuMat&, const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, GpuMat*) { throw_nogpu(); }
void cv::gpu::PyrLKOpticalFlow::dense(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, GpuMat*) { throw_nogpu(); }
@@ -71,6 +72,7 @@ namespace pyrlk
#if !defined(HAVE_TBB)
#define throw_notbb() CV_Error(CV_StsNotImplemented, "The library is compiled without TBB support")
void loadConstants_multi(int2, int, int, cudaStream_t) { throw_notbb(); }
void sparse1_multi(PtrStepSzf, PtrStepSzf, const float2*, float2*, uchar*, float*, int,
int, dim3, dim3, cudaStream_t, int) { throw_notbb(); }
@@ -326,6 +328,13 @@ void cv::gpu::PyrLKOpticalFlow::sparse_multi(const GpuMat& prevImg,
index_vector_use[index] = true;
s_PyrLKOpticalFlow_ConditionVariable.notify_one();
}
#else
void cv::gpu::PyrLKOpticalFlow::sparse_multi(const GpuMat& /*prevImg*/,
const GpuMat& /*nextImg*/, const GpuMat& /*prevPts*/, GpuMat& /*nextPts*/,
GpuMat& /*status*/, Stream& /*stream*/, GpuMat* /*err*/)
{
throw_notbb();
}
#endif
void cv::gpu::PyrLKOpticalFlow::dense(const GpuMat& prevImg, const GpuMat& nextImg, GpuMat& u, GpuMat& v, GpuMat* err)
+11 -7
View File
@@ -192,7 +192,11 @@ CvDC1394::~CvDC1394()
dc = 0;
}
static CvDC1394 dc1394;
static CvDC1394& getDC1394()
{
static CvDC1394 dc1394;
return dc1394;
}
class CvCaptureCAM_DC1394_v2_CPP : public CvCapture
{
@@ -451,7 +455,7 @@ bool CvCaptureCAM_DC1394_v2_CPP::startCapture()
code = dc1394_capture_setup(dcCam, nDMABufs, DC1394_CAPTURE_FLAGS_DEFAULT);
if (code >= 0)
{
FD_SET(dc1394_capture_get_fileno(dcCam), &dc1394.camFds);
FD_SET(dc1394_capture_get_fileno(dcCam), &getDC1394().camFds);
dc1394_video_set_transmission(dcCam, DC1394_ON);
if (cameraId == VIDERE)
{
@@ -477,15 +481,15 @@ bool CvCaptureCAM_DC1394_v2_CPP::open(int index)
close();
if (!dc1394.dc)
if (!getDC1394().dc)
goto _exit_;
err = dc1394_camera_enumerate(dc1394.dc, &cameraList);
err = dc1394_camera_enumerate(getDC1394().dc, &cameraList);
if (err < 0 || !cameraList || (unsigned)index >= (unsigned)cameraList->num)
goto _exit_;
guid = cameraList->ids[index].guid;
dcCam = dc1394_camera_new(dc1394.dc, guid);
dcCam = dc1394_camera_new(getDC1394().dc, guid);
if (!dcCam)
goto _exit_;
@@ -510,8 +514,8 @@ void CvCaptureCAM_DC1394_v2_CPP::close()
// check for fileno valid before using
int fileno=dc1394_capture_get_fileno(dcCam);
if (fileno>=0 && FD_ISSET(fileno, &dc1394.camFds))
FD_CLR(fileno, &dc1394.camFds);
if (fileno>=0 && FD_ISSET(fileno, &getDC1394().camFds))
FD_CLR(fileno, &getDC1394().camFds);
dc1394_video_set_transmission(dcCam, DC1394_OFF);
dc1394_capture_stop(dcCam);
dc1394_camera_free(dcCam);
+1
View File
@@ -543,6 +543,7 @@ void FeaturesMatcher::operator ()(const vector<ImageFeatures> &features, vector<
if (features[i].keypoints.size() > 0 && features[j].keypoints.size() > 0 && mask_(i, j))
near_pairs.push_back(make_pair(i, j));
pairwise_matches.clear(); // clear history values
pairwise_matches.resize(num_images * num_images);
MatchPairsBody body(*this, features, pairwise_matches, near_pairs);
+9
View File
@@ -90,6 +90,12 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
list(REMOVE_ITEM all_samples "driver_api_multi.cpp")
list(REMOVE_ITEM all_samples "driver_api_stereo_multi.cpp")
endif()
if(NOT HAVE_CUDA
OR NOT HAVE_TBB
OR OpenCV_FOUND # via find_package() there is no access to cvconfig.h
)
list(REMOVE_ITEM all_samples "pyrlk_optical_flow_multithreading.cpp")
endif()
foreach(sample_filename ${all_samples})
get_filename_component(sample ${sample_filename} NAME_WE)
@@ -111,6 +117,9 @@ if (OCV_DEPENDENCIES_FOUND AND INSTALL_C_EXAMPLES AND NOT WIN32)
list_filterout(install_list ".*driver_api_multi.cpp")
list_filterout(install_list ".*driver_api_stereo_multi.cpp")
endif()
if(NOT HAVE_CUDA OR NOT HAVE_TBB)
list(REMOVE_ITEM install_list "pyrlk_optical_flow_multithreading.cpp")
endif()
install(FILES ${install_list}
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/gpu"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT samples)