mirror of
https://github.com/opencv/opencv.git
synced 2026-07-25 13:23:02 +04:00
Compare commits
89 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e6f3f3c029 | |||
| 7746d9b7cc | |||
| 3494d640df | |||
| c22cc67ba8 | |||
| 558054a53d | |||
| c7b471f10f | |||
| f4ffcae8d9 | |||
| 0422054aa1 | |||
| a81f0a5123 | |||
| c36582d2df | |||
| d50c07e303 | |||
| 54693b3fa7 | |||
| 3c3bc123fc | |||
| ac33cd688c | |||
| b5e42d8cc1 | |||
| 7e4e8921bc | |||
| 6dcd455ac4 | |||
| 1d58e1a14a | |||
| d122510c4f | |||
| 6613d14261 | |||
| a14e524b32 | |||
| 226ff93917 | |||
| d28e6c9b36 | |||
| c16f465ff5 | |||
| 3231c2f995 | |||
| 16bcc30e42 | |||
| 69c50e0181 | |||
| 486c40f578 | |||
| 08e38e9ff9 | |||
| ba3b902da7 | |||
| bf94e6a91c | |||
| ecc53dd7a4 | |||
| fc0e0239b8 | |||
| d0210f510e | |||
| 34aa4e4578 | |||
| 447b8bf58a | |||
| e9539061db | |||
| ba7bf1ef68 | |||
| 5a53f41622 | |||
| 80844fd554 | |||
| a96a6bf149 | |||
| b7c9aaa471 | |||
| 00d9f690f6 | |||
| ae79fe10dc | |||
| 62fc342d35 | |||
| 36924d6dbb | |||
| e49e75da06 | |||
| 1d40946959 | |||
| 2598392295 | |||
| 17cc5e2c40 | |||
| 4b14400976 | |||
| 4704a254f7 | |||
| 7708e9882e | |||
| fe1bd0cc2f | |||
| a752f25944 | |||
| a984da911b | |||
| df55be3c3d | |||
| 55339de684 | |||
| f08dd510fa | |||
| d308ed3712 | |||
| 6d0f8aa893 | |||
| bea98bd22a | |||
| 4539607ab1 | |||
| b320138dba | |||
| 95ea12588e | |||
| bcd08b5d18 | |||
| 19298ae3cb | |||
| 5e06da3050 | |||
| 17ac18a7b9 | |||
| c259590b26 | |||
| 3f3ca85103 | |||
| 05ddc16eaa | |||
| 2ba77614aa | |||
| ef347aa6a4 | |||
| b1cdb91139 | |||
| a09ad35d98 | |||
| 1b5835cd35 | |||
| 9932bbad3a | |||
| 39ac84ff04 | |||
| fcbefaff86 | |||
| bf2256fb89 | |||
| b0b2fc9e3f | |||
| 1ccd64e102 | |||
| 23bf3e337a | |||
| 3cf265992f | |||
| 67635c6d65 | |||
| a26e496d00 | |||
| d579d3e596 | |||
| 5a77176654 |
@@ -1,8 +1,51 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*****************************************************************************************************
|
||||
USAGE:
|
||||
./opencv_annotation -images <folder location> -annotations <ouput file>
|
||||
|
||||
Created by: Puttemans Steven
|
||||
Created by: Puttemans Steven - February 2015
|
||||
*****************************************************************************************************/
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
@@ -12,6 +55,12 @@ Created by: Puttemans Steven
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
@@ -176,8 +225,33 @@ int main( int argc, const char** argv )
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the folder actually exists
|
||||
// If -1 is returned then the folder actually exists, and thus you can continue
|
||||
// In all other cases there was a folder creation and thus the folder did not exist
|
||||
#if defined(_WIN32)
|
||||
if(_mkdir(image_folder.c_str()) != -1){
|
||||
// Generate an error message
|
||||
cerr << "The image folder given does not exist. Please check again!" << endl;
|
||||
// Remove the created folder again, to ensure a second run with same code fails again
|
||||
_rmdir(image_folder.c_str());
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
if(mkdir(image_folder.c_str(), 0777) != -1){
|
||||
// Generate an error message
|
||||
cerr << "The image folder given does not exist. Please check again!" << endl;
|
||||
// Remove the created folder again, to ensure a second run with same code fails again
|
||||
remove(image_folder.c_str());
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Create the outputfilestream
|
||||
ofstream output(annotations.c_str());
|
||||
if ( !output.is_open() ){
|
||||
cerr << "The path for the output file contains an error and could not be opened. Please check again!" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Return the image filenames inside the image folder
|
||||
vector<String> filenames;
|
||||
@@ -191,6 +265,12 @@ int main( int argc, const char** argv )
|
||||
// Read in an image
|
||||
Mat current_image = imread(filenames[i]);
|
||||
|
||||
// Check if the image is actually read - avoid other files in the folder, because glob() takes them all
|
||||
// If not then simply skip this iteration
|
||||
if(current_image.empty()){
|
||||
continue;
|
||||
}
|
||||
|
||||
// Perform annotations & generate corresponding output
|
||||
stringstream output_stream;
|
||||
get_annotations(current_image, &output_stream);
|
||||
|
||||
@@ -49,6 +49,8 @@ foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MOD
|
||||
if(HAVE_${mod})
|
||||
unset(HAVE_${mod} CACHE)
|
||||
endif()
|
||||
unset(OPENCV_MODULE_${mod}_DEPS CACHE)
|
||||
unset(OPENCV_MODULE_${mod}_DEPS_EXT CACHE)
|
||||
unset(OPENCV_MODULE_${mod}_REQ_DEPS CACHE)
|
||||
unset(OPENCV_MODULE_${mod}_OPT_DEPS CACHE)
|
||||
unset(OPENCV_MODULE_${mod}_PRIVATE_REQ_DEPS CACHE)
|
||||
@@ -488,7 +490,7 @@ macro(ocv_glob_module_sources)
|
||||
|
||||
file(GLOB_RECURSE lib_srcs "src/*.cpp")
|
||||
file(GLOB_RECURSE lib_int_hdrs "src/*.hpp" "src/*.h")
|
||||
file(GLOB lib_hdrs "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_RECURSE lib_srcs_apple "src/*.mm")
|
||||
if (APPLE)
|
||||
@@ -629,7 +631,7 @@ macro(ocv_create_module)
|
||||
if(OPENCV_MODULE_${the_module}_HEADERS AND ";${OPENCV_MODULES_PUBLIC};" MATCHES ";${the_module};")
|
||||
foreach(hdr ${OPENCV_MODULE_${the_module}_HEADERS})
|
||||
string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}")
|
||||
if(hdr2 MATCHES "^(opencv2/.*)/[^/]+.h(..)?$")
|
||||
if(hdr2 MATCHES "^(opencv2/?.*)/[^/]+.h(..)?$")
|
||||
install(FILES ${hdr} DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT dev)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@@ -115,15 +115,16 @@ if(HAVE_TBB AND NOT BUILD_TBB)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(STD_OPENCV_LIBS opencv-data libopencv-calib3d2.4 libopencv-contrib2.4 libopencv-core2.4
|
||||
libopencv-features2d2.4 libopencv-flann2.4 libopencv-gpu2.4 libopencv-imgproc2.4
|
||||
libopencv-ml2.4 libopencv-ocl2.4 libopencv-stitching2.4 libopencv-ts2.4 libopencv-videostab2.4)
|
||||
set(STD_OPENCV_LIBS opencv-data)
|
||||
set(STD_OPENCV_DEV libopencv-dev)
|
||||
|
||||
set(STD_OPENCV_DEV libopencv-calib3d-dev libopencv-contrib-dev libopencv-core-dev
|
||||
libopencv-dev libopencv-features2d-dev libopencv-flann-dev libopencv-gpu-dev
|
||||
libopencv-highgui-dev libopencv-imgproc-dev libopencv-legacy-dev libopencv-ml-dev
|
||||
libopencv-objdetect-dev libopencv-ocl-dev libopencv-photo-dev libopencv-stitching-dev
|
||||
libopencv-superres-dev libopencv-ts-dev libopencv-video-dev libopencv-videostab-dev)
|
||||
foreach(module calib3d contrib core features2d flann gpu highgui imgproc legacy
|
||||
ml objdetect ocl photo stitching superres ts video videostab)
|
||||
if(HAVE_opencv_${module})
|
||||
list(APPEND STD_OPENCV_LIBS "libopencv-${module}2.4")
|
||||
list(APPEND STD_OPENCV_DEV "libopencv-${module}-dev")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_CONFLICTS "${STD_OPENCV_LIBS}")
|
||||
string(REPLACE ";" ", " CPACK_COMPONENT_LIBS_PROVIDES "${STD_OPENCV_LIBS}")
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/*! \file core.hpp
|
||||
\brief The Core Functionality
|
||||
*/
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/*! \file core.hpp
|
||||
\brief The Core Functionality
|
||||
*/
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#define CV_VERSION_EPOCH 2
|
||||
#define CV_VERSION_MAJOR 4
|
||||
#define CV_VERSION_MINOR 12
|
||||
#define CV_VERSION_REVISION 0
|
||||
#define CV_VERSION_REVISION 2
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
|
||||
|
||||
@@ -346,6 +346,7 @@ CV_IMPL CvString
|
||||
cvMemStorageAllocString( CvMemStorage* storage, const char* ptr, int len )
|
||||
{
|
||||
CvString str;
|
||||
memset(&str, 0, sizeof(CvString));
|
||||
|
||||
str.len = len >= 0 ? len : (int)strlen(ptr);
|
||||
str.ptr = (char*)cvMemStorageAlloc( storage, str.len + 1 );
|
||||
@@ -1688,6 +1689,9 @@ cvSeqRemoveSlice( CvSeq* seq, CvSlice slice )
|
||||
|
||||
slice.end_index = slice.start_index + length;
|
||||
|
||||
if ( slice.start_index == slice.end_index )
|
||||
return;
|
||||
|
||||
if( slice.end_index < total )
|
||||
{
|
||||
CvSeqReader reader_to, reader_from;
|
||||
|
||||
@@ -2216,6 +2216,7 @@ void cv::polylines(InputOutputArray _img, InputArrayOfArrays pts,
|
||||
Mat p = pts.getMat(manyContours ? i : -1);
|
||||
if( p.total() == 0 )
|
||||
{
|
||||
ptsptr[i] = NULL;
|
||||
npts[i] = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -493,6 +493,7 @@ class Core_SeqBaseTest : public Core_DynStructBaseTest
|
||||
{
|
||||
public:
|
||||
Core_SeqBaseTest();
|
||||
virtual ~Core_SeqBaseTest();
|
||||
void clear();
|
||||
void run( int );
|
||||
|
||||
@@ -503,11 +504,14 @@ protected:
|
||||
int test_seq_ops( int iters );
|
||||
};
|
||||
|
||||
|
||||
Core_SeqBaseTest::Core_SeqBaseTest()
|
||||
{
|
||||
}
|
||||
|
||||
Core_SeqBaseTest::~Core_SeqBaseTest()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void Core_SeqBaseTest::clear()
|
||||
{
|
||||
@@ -1208,6 +1212,7 @@ class Core_SetTest : public Core_DynStructBaseTest
|
||||
{
|
||||
public:
|
||||
Core_SetTest();
|
||||
virtual ~Core_SetTest();
|
||||
void clear();
|
||||
void run( int );
|
||||
|
||||
@@ -1221,6 +1226,10 @@ Core_SetTest::Core_SetTest()
|
||||
{
|
||||
}
|
||||
|
||||
Core_SetTest::~Core_SetTest()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void Core_SetTest::clear()
|
||||
{
|
||||
@@ -1419,6 +1428,7 @@ class Core_GraphTest : public Core_DynStructBaseTest
|
||||
{
|
||||
public:
|
||||
Core_GraphTest();
|
||||
virtual ~Core_GraphTest();
|
||||
void clear();
|
||||
void run( int );
|
||||
|
||||
@@ -1432,6 +1442,10 @@ Core_GraphTest::Core_GraphTest()
|
||||
{
|
||||
}
|
||||
|
||||
Core_GraphTest::~Core_GraphTest()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void Core_GraphTest::clear()
|
||||
{
|
||||
@@ -2044,6 +2058,8 @@ void Core_GraphScanTest::run( int )
|
||||
CV_TS_SEQ_CHECK_CONDITION( vtx_count == 0 && edge_count == 0,
|
||||
"Not every vertex/edge has been visited" );
|
||||
update_progressbar();
|
||||
|
||||
cvReleaseGraphScanner( &scanner );
|
||||
}
|
||||
|
||||
// for a random graph the test just checks that every graph vertex and
|
||||
@@ -2108,8 +2124,6 @@ void Core_GraphScanTest::run( int )
|
||||
catch(int)
|
||||
{
|
||||
}
|
||||
|
||||
cvReleaseGraphScanner( &scanner );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ static void writeMatInBin( const Mat& mat, const string& filename )
|
||||
fwrite( (void*)&mat.rows, sizeof(int), 1, f );
|
||||
fwrite( (void*)&mat.cols, sizeof(int), 1, f );
|
||||
fwrite( (void*)&type, sizeof(int), 1, f );
|
||||
int dataSize = (int)(mat.step * mat.rows * mat.channels());
|
||||
int dataSize = (int)(mat.step * mat.rows);
|
||||
fwrite( (void*)&dataSize, sizeof(int), 1, f );
|
||||
fwrite( (void*)mat.data, 1, dataSize, f );
|
||||
fclose(f);
|
||||
@@ -80,12 +80,15 @@ static Mat readMatFromBin( const string& filename )
|
||||
size_t elements_read4 = fread( (void*)&dataSize, sizeof(int), 1, f );
|
||||
CV_Assert(elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1);
|
||||
|
||||
uchar* data = (uchar*)cvAlloc(dataSize);
|
||||
size_t elements_read = fread( (void*)data, 1, dataSize, f );
|
||||
Mat returnMat(rows, cols, type);
|
||||
CV_Assert(returnMat.step * returnMat.rows == (size_t)(dataSize));
|
||||
|
||||
size_t elements_read = fread( (void*)returnMat.data, 1, dataSize, f );
|
||||
CV_Assert(elements_read == (size_t)(dataSize));
|
||||
|
||||
fclose(f);
|
||||
|
||||
return Mat( rows, cols, type, data );
|
||||
return returnMat;
|
||||
}
|
||||
return Mat();
|
||||
}
|
||||
|
||||
@@ -303,7 +303,8 @@ public:
|
||||
//
|
||||
// constructor
|
||||
//
|
||||
CV_FeatureDetectorMatcherBaseTest(testparam* _tp, double _accuracy_margin, cv::Feature2D* _fe, cv::DescriptorMatcher *_flmatcher, string _flmatchername, int norm_type_for_bfmatcher) :
|
||||
CV_FeatureDetectorMatcherBaseTest(testparam* _tp, double _accuracy_margin, cv::Feature2D* _fe,
|
||||
cv::DescriptorMatcher *_flmatcher, string _flmatchername, int norm_type_for_bfmatcher) :
|
||||
tp(_tp),
|
||||
target_accuracy_margin_from_bfmatcher(_accuracy_margin),
|
||||
fe(_fe),
|
||||
@@ -318,6 +319,15 @@ public:
|
||||
bfmatcher = new cv::BFMatcher(norm_type_for_bfmatcher);
|
||||
}
|
||||
|
||||
virtual ~CV_FeatureDetectorMatcherBaseTest()
|
||||
{
|
||||
if (bfmatcher)
|
||||
{
|
||||
delete bfmatcher;
|
||||
bfmatcher = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Main Test method
|
||||
//
|
||||
|
||||
@@ -65,13 +65,13 @@ protected:
|
||||
virtual void run( int start_from );
|
||||
virtual void createModel( const Mat& data ) = 0;
|
||||
virtual int findNeighbors( Mat& points, Mat& neighbors ) = 0;
|
||||
virtual int checkGetPoins( const Mat& data );
|
||||
virtual int checkGetPoints( const Mat& data );
|
||||
virtual int checkFindBoxed();
|
||||
virtual int checkFind( const Mat& data );
|
||||
virtual void releaseModel() = 0;
|
||||
};
|
||||
|
||||
int NearestNeighborTest::checkGetPoins( const Mat& )
|
||||
int NearestNeighborTest::checkGetPoints( const Mat& )
|
||||
{
|
||||
return cvtest::TS::OK;
|
||||
}
|
||||
@@ -125,11 +125,11 @@ int NearestNeighborTest::checkFind( const Mat& data )
|
||||
void NearestNeighborTest::run( int /*start_from*/ ) {
|
||||
int code = cvtest::TS::OK, tempCode;
|
||||
Mat desc( featuresCount, dims, CV_32FC1 );
|
||||
randu( desc, Scalar(minValue), Scalar(maxValue) );
|
||||
ts->get_rng().fill( desc, RNG::UNIFORM, minValue, maxValue );
|
||||
|
||||
createModel( desc );
|
||||
|
||||
tempCode = checkGetPoins( desc );
|
||||
tempCode = checkGetPoints( desc );
|
||||
if( tempCode != cvtest::TS::OK )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "bad accuracy of GetPoints \n" );
|
||||
@@ -159,10 +159,10 @@ void NearestNeighborTest::run( int /*start_from*/ ) {
|
||||
class CV_KDTreeTest_CPP : public NearestNeighborTest
|
||||
{
|
||||
public:
|
||||
CV_KDTreeTest_CPP() {}
|
||||
CV_KDTreeTest_CPP() : NearestNeighborTest(), tr(NULL) {}
|
||||
protected:
|
||||
virtual void createModel( const Mat& data );
|
||||
virtual int checkGetPoins( const Mat& data );
|
||||
virtual int checkGetPoints( const Mat& data );
|
||||
virtual int findNeighbors( Mat& points, Mat& neighbors );
|
||||
virtual int checkFindBoxed();
|
||||
virtual void releaseModel();
|
||||
@@ -175,7 +175,7 @@ void CV_KDTreeTest_CPP::createModel( const Mat& data )
|
||||
tr = new KDTree( data, false );
|
||||
}
|
||||
|
||||
int CV_KDTreeTest_CPP::checkGetPoins( const Mat& data )
|
||||
int CV_KDTreeTest_CPP::checkGetPoints( const Mat& data )
|
||||
{
|
||||
Mat res1( data.size(), data.type() ),
|
||||
res3( data.size(), data.type() );
|
||||
@@ -244,7 +244,7 @@ void CV_KDTreeTest_CPP::releaseModel()
|
||||
class CV_FlannTest : public NearestNeighborTest
|
||||
{
|
||||
public:
|
||||
CV_FlannTest() {}
|
||||
CV_FlannTest() : NearestNeighborTest(), index(NULL) { }
|
||||
protected:
|
||||
void createIndex( const Mat& data, const IndexParams& params );
|
||||
int knnSearch( Mat& points, Mat& neighbors );
|
||||
@@ -255,6 +255,9 @@ protected:
|
||||
|
||||
void CV_FlannTest::createIndex( const Mat& data, const IndexParams& params )
|
||||
{
|
||||
// release previously allocated index
|
||||
releaseModel();
|
||||
|
||||
index = new Index( data, params );
|
||||
}
|
||||
|
||||
@@ -321,7 +324,11 @@ int CV_FlannTest::radiusSearch( Mat& points, Mat& neighbors )
|
||||
|
||||
void CV_FlannTest::releaseModel()
|
||||
{
|
||||
delete index;
|
||||
if (index)
|
||||
{
|
||||
delete index;
|
||||
index = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
@@ -384,6 +384,8 @@ public:
|
||||
}
|
||||
|
||||
root_ = pool_.allocate<KMeansNode>();
|
||||
std::memset(root_, 0, sizeof(KMeansNode));
|
||||
|
||||
computeNodeStatistics(root_, indices_, (int)size_);
|
||||
computeClustering(root_, indices_, (int)size_, branching_,0);
|
||||
}
|
||||
@@ -823,11 +825,11 @@ private:
|
||||
variance -= distance_(centers[c], ZeroIterator<ElementType>(), veclen_);
|
||||
|
||||
node->childs[c] = pool_.allocate<KMeansNode>();
|
||||
std::memset(node->childs[c], 0, sizeof(KMeansNode));
|
||||
node->childs[c]->radius = radiuses[c];
|
||||
node->childs[c]->pivot = centers[c];
|
||||
node->childs[c]->variance = variance;
|
||||
node->childs[c]->mean_radius = mean_radius;
|
||||
node->childs[c]->indices = NULL;
|
||||
computeClustering(node->childs[c],indices+start, end-start, branching, level+1);
|
||||
start=end;
|
||||
}
|
||||
|
||||
@@ -318,12 +318,14 @@ buildIndex_(void*& index, const Mat& wholedata, const Mat& data, const IndexPara
|
||||
|
||||
::cvflann::Matrix<ElementType> dataset((ElementType*)data.data, data.rows, data.cols);
|
||||
|
||||
IndexType* _index = NULL;
|
||||
if( !index || getParam<flann_algorithm_t>(params, "algorithm", FLANN_INDEX_LINEAR) != FLANN_INDEX_LSH) // currently, additional index support is the lsh algorithm only.
|
||||
// currently, additional index support is the lsh algorithm only.
|
||||
if( !index || getParam<flann_algorithm_t>(params, "algorithm", FLANN_INDEX_LINEAR) != FLANN_INDEX_LSH)
|
||||
{
|
||||
_index = new IndexType(dataset, get_params(params), dist);
|
||||
Ptr<IndexType> _index = makePtr<IndexType>(dataset, get_params(params), dist);
|
||||
_index->buildIndex();
|
||||
index = _index;
|
||||
// HACK to prevent object destruction
|
||||
_index.obj = NULL;
|
||||
}
|
||||
else // build additional lsh index
|
||||
{
|
||||
|
||||
@@ -255,7 +255,7 @@ namespace cv { namespace gpu { namespace device
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename T>
|
||||
__global__ void data_step_down(int dst_cols, int dst_rows, int src_rows, const PtrStep<T> src, PtrStep<T> dst)
|
||||
__global__ void data_step_down(int dst_cols, int dst_rows, int src_cols, int src_rows, const PtrStep<T> src, PtrStep<T> dst)
|
||||
{
|
||||
const int x = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
const int y = blockIdx.y * blockDim.y + threadIdx.y;
|
||||
@@ -264,10 +264,10 @@ namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
for (int d = 0; d < cndisp; ++d)
|
||||
{
|
||||
float dst_reg = src.ptr(d * src_rows + (2*y+0))[(2*x+0)];
|
||||
dst_reg += src.ptr(d * src_rows + (2*y+1))[(2*x+0)];
|
||||
dst_reg += src.ptr(d * src_rows + (2*y+0))[(2*x+1)];
|
||||
dst_reg += src.ptr(d * src_rows + (2*y+1))[(2*x+1)];
|
||||
float dst_reg = src.ptr(d * src_rows + ::min(2*y+0, src_rows-1))[::min(2*x+0, src_cols-1)];
|
||||
dst_reg += src.ptr(d * src_rows + ::min(2*y+1, src_rows-1))[::min(2*x+0, src_cols-1)];
|
||||
dst_reg += src.ptr(d * src_rows + ::min(2*y+0, src_rows-1))[::min(2*x+1, src_cols-1)];
|
||||
dst_reg += src.ptr(d * src_rows + ::min(2*y+1, src_rows-1))[::min(2*x+1, src_cols-1)];
|
||||
|
||||
dst.ptr(d * dst_rows + y)[x] = saturate_cast<T>(dst_reg);
|
||||
}
|
||||
@@ -275,7 +275,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void data_step_down_gpu(int dst_cols, int dst_rows, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream)
|
||||
void data_step_down_gpu(int dst_cols, int dst_rows, int src_cols, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream)
|
||||
{
|
||||
dim3 threads(32, 8, 1);
|
||||
dim3 grid(1, 1, 1);
|
||||
@@ -283,15 +283,15 @@ namespace cv { namespace gpu { namespace device
|
||||
grid.x = divUp(dst_cols, threads.x);
|
||||
grid.y = divUp(dst_rows, threads.y);
|
||||
|
||||
data_step_down<T><<<grid, threads, 0, stream>>>(dst_cols, dst_rows, src_rows, (PtrStepSz<T>)src, (PtrStepSz<T>)dst);
|
||||
data_step_down<T><<<grid, threads, 0, stream>>>(dst_cols, dst_rows, src_cols, src_rows, (PtrStepSz<T>)src, (PtrStepSz<T>)dst);
|
||||
cudaSafeCall( cudaGetLastError() );
|
||||
|
||||
if (stream == 0)
|
||||
cudaSafeCall( cudaDeviceSynchronize() );
|
||||
}
|
||||
|
||||
template void data_step_down_gpu<short>(int dst_cols, int dst_rows, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream);
|
||||
template void data_step_down_gpu<float>(int dst_cols, int dst_rows, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream);
|
||||
template void data_step_down_gpu<short>(int dst_cols, int dst_rows, int src_cols, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream);
|
||||
template void data_step_down_gpu<float>(int dst_cols, int dst_rows, int src_cols, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream);
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
/////////////////// level up messages ////////////////////////
|
||||
|
||||
@@ -2804,7 +2804,7 @@ void cv::gpu::bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask, St
|
||||
}
|
||||
else
|
||||
{
|
||||
const int elem_size = src.elemSize1();
|
||||
const int elem_size = static_cast<int>(src.elemSize1());
|
||||
const int num_channels = src.channels();
|
||||
const int bcols = src.cols * num_channels;
|
||||
|
||||
@@ -2895,7 +2895,7 @@ void cv::gpu::bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, c
|
||||
}
|
||||
else
|
||||
{
|
||||
const int elem_size = src1.elemSize1();
|
||||
const int elem_size = static_cast<int>(src1.elemSize1());
|
||||
const int num_channels = src1.channels();
|
||||
const int bcols = src1.cols * num_channels;
|
||||
|
||||
@@ -2979,7 +2979,7 @@ void cv::gpu::bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, co
|
||||
}
|
||||
else
|
||||
{
|
||||
const int elem_size = src1.elemSize1();
|
||||
const int elem_size = static_cast<int>(src1.elemSize1());
|
||||
const int num_channels = src1.channels();
|
||||
const int bcols = src1.cols * num_channels;
|
||||
|
||||
@@ -3063,7 +3063,7 @@ void cv::gpu::bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, c
|
||||
}
|
||||
else
|
||||
{
|
||||
const int elem_size = src1.elemSize1();
|
||||
const int elem_size = static_cast<int>(src1.elemSize1());
|
||||
const int num_channels = src1.channels();
|
||||
const int bcols = src1.cols * num_channels;
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace cv { namespace gpu { namespace device
|
||||
template<typename T, typename D>
|
||||
void comp_data_gpu(const PtrStepSzb& left, const PtrStepSzb& right, const PtrStepSzb& data, cudaStream_t stream);
|
||||
template<typename T>
|
||||
void data_step_down_gpu(int dst_cols, int dst_rows, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream);
|
||||
void data_step_down_gpu(int dst_cols, int dst_rows, int src_cols, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream);
|
||||
template <typename T>
|
||||
void level_up_messages_gpu(int dst_idx, int dst_cols, int dst_rows, int src_rows, PtrStepSzb* mus, PtrStepSzb* mds, PtrStepSzb* mls, PtrStepSzb* mrs, cudaStream_t stream);
|
||||
template <typename T>
|
||||
@@ -158,7 +158,7 @@ namespace
|
||||
|
||||
init(stream);
|
||||
|
||||
datas[0].create(rows * rthis.ndisp, cols, rthis.msg_type);
|
||||
createContinuous(rows * rthis.ndisp, cols, rthis.msg_type, datas[0]);
|
||||
|
||||
comp_data_callers[rthis.msg_type == CV_32F][left.channels()](left, right, datas[0], StreamAccessor::getStream(stream));
|
||||
|
||||
@@ -187,10 +187,10 @@ namespace
|
||||
private:
|
||||
void init(Stream& stream)
|
||||
{
|
||||
u.create(rows * rthis.ndisp, cols, rthis.msg_type);
|
||||
d.create(rows * rthis.ndisp, cols, rthis.msg_type);
|
||||
l.create(rows * rthis.ndisp, cols, rthis.msg_type);
|
||||
r.create(rows * rthis.ndisp, cols, rthis.msg_type);
|
||||
createContinuous(rows * rthis.ndisp, cols, rthis.msg_type, u);
|
||||
createContinuous(rows * rthis.ndisp, cols, rthis.msg_type, d);
|
||||
createContinuous(rows * rthis.ndisp, cols, rthis.msg_type, l);
|
||||
createContinuous(rows * rthis.ndisp, cols, rthis.msg_type, r);
|
||||
|
||||
if (rthis.levels & 1)
|
||||
{
|
||||
@@ -216,10 +216,10 @@ namespace
|
||||
int less_rows = (rows + 1) / 2;
|
||||
int less_cols = (cols + 1) / 2;
|
||||
|
||||
u2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type);
|
||||
d2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type);
|
||||
l2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type);
|
||||
r2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type);
|
||||
createContinuous(less_rows * rthis.ndisp, less_cols, rthis.msg_type, u2);
|
||||
createContinuous(less_rows * rthis.ndisp, less_cols, rthis.msg_type, d2);
|
||||
createContinuous(less_rows * rthis.ndisp, less_cols, rthis.msg_type, l2);
|
||||
createContinuous(less_rows * rthis.ndisp, less_cols, rthis.msg_type, r2);
|
||||
|
||||
if ((rthis.levels & 1) == 0)
|
||||
{
|
||||
@@ -253,7 +253,7 @@ namespace
|
||||
|
||||
void calcBP(GpuMat& disp, Stream& stream)
|
||||
{
|
||||
typedef void (*data_step_down_t)(int dst_cols, int dst_rows, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream);
|
||||
typedef void (*data_step_down_t)(int dst_cols, int dst_rows, int src_cols, int src_rows, const PtrStepSzb& src, const PtrStepSzb& dst, cudaStream_t stream);
|
||||
static const data_step_down_t data_step_down_callers[2] =
|
||||
{
|
||||
data_step_down_gpu<short>, data_step_down_gpu<float>
|
||||
@@ -286,9 +286,9 @@ namespace
|
||||
cols_all[i] = (cols_all[i-1] + 1) / 2;
|
||||
rows_all[i] = (rows_all[i-1] + 1) / 2;
|
||||
|
||||
datas[i].create(rows_all[i] * rthis.ndisp, cols_all[i], rthis.msg_type);
|
||||
createContinuous(rows_all[i] * rthis.ndisp, cols_all[i], rthis.msg_type, datas[i]);
|
||||
|
||||
data_step_down_callers[funcIdx](cols_all[i], rows_all[i], rows_all[i-1], datas[i-1], datas[i], cudaStream);
|
||||
data_step_down_callers[funcIdx](cols_all[i], rows_all[i], cols_all[i-1], rows_all[i-1], datas[i-1], datas[i], cudaStream);
|
||||
}
|
||||
|
||||
PtrStepSzb mus[] = {u, u2};
|
||||
|
||||
@@ -114,7 +114,9 @@ GPU_TEST_P(StereoBeliefPropagation, Regression)
|
||||
cv::Mat h_disp(disp);
|
||||
h_disp.convertTo(h_disp, disp_gold.depth());
|
||||
|
||||
EXPECT_MAT_NEAR(disp_gold, h_disp, 0.0);
|
||||
cv::Rect roi(0, 0, disp_gold.cols - 20, disp_gold.rows - 20);
|
||||
|
||||
EXPECT_MAT_NEAR(disp_gold(roi), h_disp(roi), 0.0);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Calib3D, StereoBeliefPropagation, ALL_DEVICES);
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/*! \file imgproc.hpp
|
||||
\brief The Image Processing
|
||||
*/
|
||||
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/*! \file imgproc.hpp
|
||||
\brief The Image Processing
|
||||
*/
|
||||
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
|
||||
@@ -548,7 +548,7 @@ void referenceRGB2YUV(const Mat& rgb, Mat& yuv, RGBreader* rgbReader, YUVwriter*
|
||||
|
||||
struct ConversionYUV
|
||||
{
|
||||
ConversionYUV( const int code )
|
||||
explicit ConversionYUV( const int code )
|
||||
{
|
||||
yuvReader_ = YUVreader :: getReader(code);
|
||||
yuvWriter_ = YUVwriter :: getWriter(code);
|
||||
@@ -557,6 +557,24 @@ struct ConversionYUV
|
||||
grayWriter_ = GRAYwriter:: getWriter(code);
|
||||
}
|
||||
|
||||
~ConversionYUV()
|
||||
{
|
||||
if (yuvReader_)
|
||||
delete yuvReader_;
|
||||
|
||||
if (yuvWriter_)
|
||||
delete yuvWriter_;
|
||||
|
||||
if (rgbReader_)
|
||||
delete rgbReader_;
|
||||
|
||||
if (rgbWriter_)
|
||||
delete rgbWriter_;
|
||||
|
||||
if (grayWriter_)
|
||||
delete grayWriter_;
|
||||
}
|
||||
|
||||
int getDcn()
|
||||
{
|
||||
return (rgbWriter_ != 0) ? rgbWriter_->channels() : ((grayWriter_ != 0) ? grayWriter_->channels() : yuvWriter_->channels());
|
||||
|
||||
@@ -501,6 +501,8 @@ _exit_:
|
||||
comp[6] = s1;
|
||||
comp[7] = s2;
|
||||
comp[8] = 0;
|
||||
|
||||
cvReleaseMemStorage(&st);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1372,17 +1372,65 @@ void CV_GetQuadSubPixTest::prepare_to_validation( int /*test_case_idx*/ )
|
||||
dst.convertTo(dst0, dst0.depth());
|
||||
}
|
||||
|
||||
////////////////////////////// resizeArea /////////////////////////////////
|
||||
|
||||
template <typename T>
|
||||
static void check_resize_area(const Mat& expected, const Mat& actual, double tolerance = 1.0)
|
||||
{
|
||||
ASSERT_EQ(actual.type(), expected.type());
|
||||
ASSERT_EQ(actual.size(), expected.size());
|
||||
|
||||
Mat diff;
|
||||
absdiff(actual, expected, diff);
|
||||
|
||||
Mat one_channel_diff = diff; //.reshape(1);
|
||||
|
||||
Size dsize = actual.size();
|
||||
bool next = true;
|
||||
for (int dy = 0; dy < dsize.height && next; ++dy)
|
||||
{
|
||||
const T* eD = expected.ptr<T>(dy);
|
||||
const T* aD = actual.ptr<T>(dy);
|
||||
|
||||
for (int dx = 0; dx < dsize.width && next; ++dx)
|
||||
if (fabs(static_cast<double>(aD[dx] - eD[dx])) > tolerance)
|
||||
{
|
||||
cvtest::TS::ptr()->printf(cvtest::TS::SUMMARY, "Inf norm: %f\n", static_cast<float>(norm(actual, expected, NORM_INF)));
|
||||
cvtest::TS::ptr()->printf(cvtest::TS::SUMMARY, "Error in : (%d, %d)\n", dx, dy);
|
||||
|
||||
const int radius = 3;
|
||||
int rmin = MAX(dy - radius, 0), rmax = MIN(dy + radius, dsize.height);
|
||||
int cmin = MAX(dx - radius, 0), cmax = MIN(dx + radius, dsize.width);
|
||||
|
||||
std::cout << "Abs diff:" << std::endl << diff << std::endl;
|
||||
std::cout << "actual result:\n" << actual(Range(rmin, rmax), Range(cmin, cmax)) << std::endl;
|
||||
std::cout << "expected result:\n" << expected(Range(rmin, rmax), Range(cmin, cmax)) << std::endl;
|
||||
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_EQ(norm(one_channel_diff, cv::NORM_INF), 0);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TEST(Imgproc_cvWarpAffine, regression)
|
||||
{
|
||||
IplImage* src = cvCreateImage(cvSize(100, 100), IPL_DEPTH_8U, 1);
|
||||
IplImage* dst = cvCreateImage(cvSize(100, 100), IPL_DEPTH_8U, 1);
|
||||
|
||||
cvZero(src);
|
||||
|
||||
float m[6];
|
||||
CvMat M = cvMat( 2, 3, CV_32F, m );
|
||||
int w = src->width;
|
||||
int h = src->height;
|
||||
cv2DRotationMatrix(cvPoint2D32f(w*0.5f, h*0.5f), 45.0, 1.0, &M);
|
||||
cvWarpAffine(src, dst, &M);
|
||||
|
||||
cvReleaseImage(&src);
|
||||
cvReleaseImage(&dst);
|
||||
}
|
||||
|
||||
TEST(Imgproc_fitLine_vector_3d, regression)
|
||||
@@ -1496,41 +1544,45 @@ TEST(Imgproc_resize_area, regression)
|
||||
|
||||
cv::resize(src, actual, cv::Size(), 0.3, 0.3, INTER_AREA);
|
||||
|
||||
ASSERT_EQ(actual.type(), expected.type());
|
||||
ASSERT_EQ(actual.size(), expected.size());
|
||||
check_resize_area<ushort>(expected, actual, 1.0);
|
||||
}
|
||||
|
||||
Mat diff;
|
||||
absdiff(actual, expected, diff);
|
||||
TEST(Imgproc_resize_area, regression_half_round)
|
||||
{
|
||||
static uchar input_data[32 * 32];
|
||||
for(int i = 0; i < 32 * 32; ++i)
|
||||
input_data[i] = (uchar)(i % 2 + 253 + i / (16 * 32));
|
||||
|
||||
Mat one_channel_diff = diff; //.reshape(1);
|
||||
static uchar expected_data[16 * 16];
|
||||
for(int i = 0; i < 16 * 16; ++i)
|
||||
expected_data[i] = (uchar)(254 + i / (16 * 8));
|
||||
|
||||
float elem_diff = 1.0f;
|
||||
Size dsize = actual.size();
|
||||
bool next = true;
|
||||
for (int dy = 0; dy < dsize.height && next; ++dy)
|
||||
{
|
||||
ushort* eD = expected.ptr<ushort>(dy);
|
||||
ushort* aD = actual.ptr<ushort>(dy);
|
||||
cv::Mat src(32, 32, CV_8UC1, input_data);
|
||||
cv::Mat expected(16, 16, CV_8UC1, expected_data);
|
||||
cv::Mat actual(expected.size(), expected.type());
|
||||
|
||||
for (int dx = 0; dx < dsize.width && next; ++dx)
|
||||
if (fabs(static_cast<float>(aD[dx] - eD[dx])) > elem_diff)
|
||||
{
|
||||
cvtest::TS::ptr()->printf(cvtest::TS::SUMMARY, "Inf norm: %f\n", static_cast<float>(norm(actual, expected, NORM_INF)));
|
||||
cvtest::TS::ptr()->printf(cvtest::TS::SUMMARY, "Error in : (%d, %d)\n", dx, dy);
|
||||
cv::resize(src, actual, cv::Size(), 0.5, 0.5, INTER_AREA);
|
||||
|
||||
const int radius = 3;
|
||||
int rmin = MAX(dy - radius, 0), rmax = MIN(dy + radius, dsize.height);
|
||||
int cmin = MAX(dx - radius, 0), cmax = MIN(dx + radius, dsize.width);
|
||||
check_resize_area<uchar>(expected, actual, 0.5);
|
||||
}
|
||||
|
||||
std::cout << "Abs diff:" << std::endl << diff << std::endl;
|
||||
std::cout << "actual result:\n" << actual(Range(rmin, rmax), Range(cmin, cmax)) << std::endl;
|
||||
std::cout << "expected result:\n" << expected(Range(rmin, rmax), Range(cmin, cmax)) << std::endl;
|
||||
TEST(Imgproc_resize_area, regression_quarter_round)
|
||||
{
|
||||
static uchar input_data[32 * 32];
|
||||
for(int i = 0; i < 32 * 32; ++i)
|
||||
input_data[i] = (uchar)(i % 2 + 253 + i / (16 * 32));
|
||||
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
static uchar expected_data[8 * 8];
|
||||
for(int i = 0; i < 8 * 8; ++i)
|
||||
expected_data[i] = 254;
|
||||
|
||||
ASSERT_EQ(norm(one_channel_diff, cv::NORM_INF), 0);
|
||||
cv::Mat src(32, 32, CV_8UC1, input_data);
|
||||
cv::Mat expected(8, 8, CV_8UC1, expected_data);
|
||||
cv::Mat actual(expected.size(), expected.type());
|
||||
|
||||
cv::resize(src, actual, cv::Size(), 0.25, 0.25, INTER_AREA);
|
||||
|
||||
check_resize_area<uchar>(expected, actual, 0.5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -644,8 +644,7 @@ private:
|
||||
};
|
||||
|
||||
CV_Remap_Test::CV_Remap_Test() :
|
||||
CV_ImageWarpBaseTest(), mapx(), mapy(),
|
||||
borderType(-1), borderValue()
|
||||
CV_ImageWarpBaseTest(), borderType(-1)
|
||||
{
|
||||
funcs[0] = &CV_Remap_Test::remap_nearest;
|
||||
funcs[1] = &CV_Remap_Test::remap_generic;
|
||||
@@ -666,7 +665,7 @@ void CV_Remap_Test::generate_test_data()
|
||||
// generating the mapx, mapy matrices
|
||||
static const int mapx_types[] = { CV_16SC2, CV_32FC1, CV_32FC2 };
|
||||
mapx.create(dst.size(), mapx_types[rng.uniform(0, sizeof(mapx_types) / sizeof(int))]);
|
||||
mapy = Mat();
|
||||
mapy.release();
|
||||
|
||||
const int n = std::min(std::min(src.cols, src.rows) / 10 + 1, 2);
|
||||
float _n = 0; //static_cast<float>(-n);
|
||||
@@ -693,7 +692,7 @@ void CV_Remap_Test::generate_test_data()
|
||||
{
|
||||
MatIterator_<ushort> begin_y = mapy.begin<ushort>(), end_y = mapy.end<ushort>();
|
||||
for ( ; begin_y != end_y; ++begin_y)
|
||||
begin_y[0] = static_cast<short>(rng.uniform(0, 1024));
|
||||
*begin_y = static_cast<ushort>(rng.uniform(0, 1024));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -701,7 +700,7 @@ void CV_Remap_Test::generate_test_data()
|
||||
{
|
||||
MatIterator_<short> begin_y = mapy.begin<short>(), end_y = mapy.end<short>();
|
||||
for ( ; begin_y != end_y; ++begin_y)
|
||||
begin_y[0] = static_cast<short>(rng.uniform(0, 1024));
|
||||
*begin_y = static_cast<short>(rng.uniform(0, 1024));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -718,8 +717,8 @@ void CV_Remap_Test::generate_test_data()
|
||||
MatIterator_<float> begin_y = mapy.begin<float>();
|
||||
for ( ; begin_x != end_x; ++begin_x, ++begin_y)
|
||||
{
|
||||
begin_x[0] = rng.uniform(_n, fscols);
|
||||
begin_y[0] = rng.uniform(_n, fsrows);
|
||||
*begin_x = rng.uniform(_n, fscols);
|
||||
*begin_y = rng.uniform(_n, fsrows);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -731,8 +730,8 @@ void CV_Remap_Test::generate_test_data()
|
||||
fsrows = static_cast<float>(std::max(src.rows - 1 + n, 0));
|
||||
for ( ; begin_x != end_x; ++begin_x)
|
||||
{
|
||||
begin_x[0] = rng.uniform(_n, fscols);
|
||||
begin_x[1] = rng.uniform(_n, fsrows);
|
||||
(*begin_x)[0] = rng.uniform(_n, fscols);
|
||||
(*begin_x)[1] = rng.uniform(_n, fsrows);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -777,23 +776,6 @@ void CV_Remap_Test::prepare_test_data_for_reference_func()
|
||||
{
|
||||
CV_ImageWarpBaseTest::prepare_test_data_for_reference_func();
|
||||
convert_maps();
|
||||
/*
|
||||
const int ksize = 3;
|
||||
Mat kernel = getStructuringElement(CV_MOP_ERODE, Size(ksize, ksize));
|
||||
Mat mask(src.size(), CV_8UC1, Scalar::all(255)), dst_mask;
|
||||
cv::erode(src, erode_src, kernel);
|
||||
cv::erode(mask, dst_mask, kernel, Point(-1, -1), 1, BORDER_CONSTANT, Scalar::all(0));
|
||||
bitwise_not(dst_mask, mask);
|
||||
src.copyTo(erode_src, mask);
|
||||
dst_mask.release();
|
||||
|
||||
mask = Scalar::all(0);
|
||||
kernel = getStructuringElement(CV_MOP_DILATE, kernel.size());
|
||||
cv::dilate(src, dilate_src, kernel);
|
||||
cv::dilate(mask, dst_mask, kernel, Point(-1, -1), 1, BORDER_CONSTANT, Scalar::all(255));
|
||||
src.copyTo(dilate_src, dst_mask);
|
||||
dst_mask.release();
|
||||
*/
|
||||
}
|
||||
|
||||
void CV_Remap_Test::run_reference_func()
|
||||
|
||||
@@ -1535,6 +1535,10 @@ void CvANN_MLP::read( CvFileStorage* fs, CvFileNode* node )
|
||||
|
||||
_layer_sizes = (CvMat*)cvReadByName( fs, node, "layer_sizes" );
|
||||
CV_CALL( create( _layer_sizes, SIGMOID_SYM, 0, 0 ));
|
||||
|
||||
cvReleaseMat( &_layer_sizes );
|
||||
_layer_sizes = NULL;
|
||||
|
||||
l_count = layer_sizes->cols;
|
||||
|
||||
CV_CALL( read_params( fs, node ));
|
||||
|
||||
@@ -537,6 +537,9 @@ void CvERTreeTrainData::set_data( const CvMat* _train_data, int _tflag,
|
||||
if( data )
|
||||
delete data;
|
||||
|
||||
if ( pair16u32s_ptr )
|
||||
cvFree( &pair16u32s_ptr );
|
||||
|
||||
if (_fdst)
|
||||
cvFree( &_fdst );
|
||||
if (_idst)
|
||||
|
||||
@@ -259,7 +259,7 @@ CvGBTrees::train( const CvMat* _train_data, int _tflag,
|
||||
for (int i=1; i<n; ++i)
|
||||
{
|
||||
int k = 0;
|
||||
while ((int(orig_response->data.fl[i]) - class_labels->data.i[k]) && (k<j))
|
||||
while ((k<j) && (int(orig_response->data.fl[i]) - class_labels->data.i[k]))
|
||||
k++;
|
||||
if (k == j)
|
||||
{
|
||||
@@ -1292,13 +1292,18 @@ CvGBTrees::calc_error( CvMLData* _data, int type, std::vector<float> *resp )
|
||||
return -FLT_MAX;
|
||||
|
||||
float* pred_resp = 0;
|
||||
bool needsFreeing = false;
|
||||
|
||||
if (resp)
|
||||
{
|
||||
resp->resize(n);
|
||||
pred_resp = &((*resp)[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
pred_resp = new float[n];
|
||||
needsFreeing = true;
|
||||
}
|
||||
|
||||
Sample_predictor predictor = Sample_predictor(this, pred_resp, _data->get_values(),
|
||||
_data->get_missing(), _sample_idx);
|
||||
@@ -1331,6 +1336,9 @@ CvGBTrees::calc_error( CvMLData* _data, int type, std::vector<float> *resp )
|
||||
err = err / (float)n;
|
||||
}
|
||||
|
||||
if (needsFreeing)
|
||||
delete[]pred_resp;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
@@ -777,7 +777,8 @@ cvGetTrainSamples( const CvMat* train_data, int tflag,
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
int i, j, var_count, sample_count, s_step, v_step;
|
||||
int i, j, var_count, sample_count;
|
||||
size_t s_step, v_step, s;
|
||||
bool copy_data;
|
||||
const float* data;
|
||||
const int *s_idx, *v_idx;
|
||||
@@ -815,7 +816,7 @@ cvGetTrainSamples( const CvMat* train_data, int tflag,
|
||||
{
|
||||
samples[0] = (float*)(samples + sample_count);
|
||||
if( tflag != CV_ROW_SAMPLE )
|
||||
CV_SWAP( s_step, v_step, i );
|
||||
CV_SWAP( s_step, v_step, s );
|
||||
|
||||
for( i = 0; i < sample_count; i++ )
|
||||
{
|
||||
|
||||
@@ -2315,7 +2315,12 @@ void CvSVM::write( CvFileStorage* fs, const char* name ) const
|
||||
params.svm_type == CvSVM::ONE_CLASS ? 1 : 0;
|
||||
const CvSVMDecisionFunc* df = decision_func;
|
||||
if( !isSvmModelApplicable(sv_total, var_all, var_count, class_count) )
|
||||
{
|
||||
cvReleaseFileStorage( &fs );
|
||||
fs = NULL;
|
||||
|
||||
CV_ERROR( CV_StsParseError, "SVM model data is invalid, check sv_count, var_* and class_count tags" );
|
||||
}
|
||||
|
||||
cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_ML_SVM );
|
||||
|
||||
|
||||
@@ -323,6 +323,7 @@ BadArgTest::BadArgTest()
|
||||
progress = -1;
|
||||
test_case_idx = -1;
|
||||
freq = cv::getTickFrequency();
|
||||
t = -1;
|
||||
// oldErrorCbk = 0;
|
||||
// oldErrorCbkData = 0;
|
||||
}
|
||||
@@ -338,6 +339,7 @@ int BadArgTest::run_test_case( int expected_code, const string& _descr )
|
||||
{
|
||||
test_case_idx = 0;
|
||||
progress = 0;
|
||||
t = 0;
|
||||
dt = 0;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user