Merge branch '2.4'

This commit is contained in:
Andrey Kamaev 2012-10-23 20:32:19 +04:00
commit 8dbde3297e
24 changed files with 131 additions and 79 deletions

View File

@ -1,4 +1,4 @@
if(MINGW) if(MINGW OR (X86 AND UNIX AND NOT APPLE))
# mingw compiler is known to produce unstable SSE code with -O3 hence we are trying to use -O2 instead # mingw compiler is known to produce unstable SSE code with -O3 hence we are trying to use -O2 instead
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
foreach(flags CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG) foreach(flags CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)

View File

@ -182,10 +182,20 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
_PCH_GET_TARGET_COMPILE_FLAGS(_target_cflags ${_name} ${_pch_output_to_use} ${_dowarn}) _PCH_GET_TARGET_COMPILE_FLAGS(_target_cflags ${_name} ${_pch_output_to_use} ${_dowarn})
#MESSAGE("Add flags ${_target_cflags} to ${_targetName} " ) #MESSAGE("Add flags ${_target_cflags} to ${_targetName} " )
SET_TARGET_PROPERTIES(${_targetName}
PROPERTIES GET_TARGET_PROPERTY(_sources ${_targetName} SOURCES)
COMPILE_FLAGS ${_target_cflags} FOREACH(src ${_sources})
) if(NOT "${src}" MATCHES "\\.mm$")
get_source_file_property(_flags "${src}" COMPILE_FLAGS)
if(_flags)
set(_flags "${_flags} ${_target_cflags}")
else()
set(_flags "${_target_cflags}")
endif()
set_source_files_properties("${src}" PROPERTIES COMPILE_FLAGS "${_flags}")
endif()
ENDFOREACH()
ADD_CUSTOM_TARGET(pch_Generate_${_targetName} ADD_CUSTOM_TARGET(pch_Generate_${_targetName}
DEPENDS ${_pch_output_to_use} DEPENDS ${_pch_output_to_use}

View File

@ -96,7 +96,7 @@ PERF_TEST(PointsNum_Algo, solveP3P)
SANITY_CHECK(tvec, 1e-6); SANITY_CHECK(tvec, 1e-6);
} }
PERF_TEST_P(PointsNum, SolvePnPRansac, testing::Values(4, 3*9, 7*13)) PERF_TEST_P(PointsNum, DISABLED_SolvePnPRansac, testing::Values(4, 3*9, 7*13))
{ {
int count = GetParam(); int count = GetParam();

View File

@ -59,6 +59,9 @@
# ifdef ANDROID # ifdef ANDROID
template <typename Scalar> Scalar log2(Scalar v) { using std::log; return log(v)/log(Scalar(2)); } template <typename Scalar> Scalar log2(Scalar v) { using std::log; return log(v)/log(Scalar(2)); }
# endif # endif
# if defined __GNUC__ && defined __APPLE__
# pragma GCC diagnostic ignored "-Wshadow"
# endif
# include <unsupported/Eigen/MatrixFunctions> # include <unsupported/Eigen/MatrixFunctions>
# include <Eigen/Dense> # include <Eigen/Dense>
#endif #endif

View File

@ -86,6 +86,11 @@
#include <limits> #include <limits>
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable:4127) //conditional expression is constant
#endif
namespace cv namespace cv
{ {
@ -3950,5 +3955,9 @@ template<typename _Tp> inline void AlgorithmInfo::addParam(Algorithm& algo, cons
} }
#ifdef _MSC_VER
# pragma warning(pop)
#endif
#endif // __cplusplus #endif // __cplusplus
#endif #endif

View File

@ -23,6 +23,13 @@ PERF_TEST_P(Size_MatType, addWeighted, TYPICAL_MATS_ADWEIGHTED)
declare.in(src1, src2, dst, WARMUP_RNG).out(dst); declare.in(src1, src2, dst, WARMUP_RNG).out(dst);
if (CV_MAT_DEPTH(type) == CV_32S)
{
//see ticket 1529: absdiff can be without saturation on 32S
src1 /= 8;
src2 /= 8;
}
TEST_CYCLE() cv::addWeighted( src1, alpha, src2, beta, gamma, dst, dst.type() ); TEST_CYCLE() cv::addWeighted( src1, alpha, src2, beta, gamma, dst, dst.type() );
SANITY_CHECK(dst); SANITY_CHECK(dst);

View File

@ -2543,7 +2543,6 @@ public:
data(_data), data(_data),
centers(_centers) centers(_centers)
{ {
CV_DbgAssert(centers.cols == data.cols);
} }
void operator()( const BlockedRange& range ) const void operator()( const BlockedRange& range ) const

View File

@ -361,8 +361,8 @@ void cv::setNumThreads( int threads )
else if (pplScheduler == 0 || 1 + pplScheduler->GetNumberOfVirtualProcessors() != (unsigned int)threads) else if (pplScheduler == 0 || 1 + pplScheduler->GetNumberOfVirtualProcessors() != (unsigned int)threads)
{ {
pplScheduler = Concurrency::Scheduler::Create(Concurrency::SchedulerPolicy(2, pplScheduler = Concurrency::Scheduler::Create(Concurrency::SchedulerPolicy(2,
Concurrency::PolicyElementKey::MinConcurrency, threads-1, Concurrency::MinConcurrency, threads-1,
Concurrency::PolicyElementKey::MaxConcurrency, threads-1)); Concurrency::MaxConcurrency, threads-1));
} }
#endif #endif

View File

@ -500,7 +500,7 @@ int runRadiusSearch_(void* index, const Mat& query, Mat& indices, Mat& dists,
::cvflann::Matrix<DistanceType> _dists((DistanceType*)dists.data, dists.rows, dists.cols); ::cvflann::Matrix<DistanceType> _dists((DistanceType*)dists.data, dists.rows, dists.cols);
return ((IndexType*)index)->radiusSearch(_query, _indices, _dists, return ((IndexType*)index)->radiusSearch(_query, _indices, _dists,
saturate_cast<DistanceType>(radius), saturate_cast<float>(radius),
(const ::cvflann::SearchParams&)get_params(params)); (const ::cvflann::SearchParams&)get_params(params));
} }

View File

@ -503,6 +503,9 @@ bool CvCaptureCAM::setProperty(int property_id, double value) {
didOutputVideoFrame:(CVImageBufferRef)videoFrame didOutputVideoFrame:(CVImageBufferRef)videoFrame
withSampleBuffer:(QTSampleBuffer *)sampleBuffer withSampleBuffer:(QTSampleBuffer *)sampleBuffer
fromConnection:(QTCaptureConnection *)connection { fromConnection:(QTCaptureConnection *)connection {
(void)captureOutput;
(void)sampleBuffer;
(void)connection;
CVBufferRetain(videoFrame); CVBufferRetain(videoFrame);
CVImageBufferRef imageBufferToRelease = mCurrentImageBuffer; CVImageBufferRef imageBufferToRelease = mCurrentImageBuffer;
@ -519,6 +522,9 @@ bool CvCaptureCAM::setProperty(int property_id, double value) {
- (void)captureOutput:(QTCaptureOutput *)captureOutput - (void)captureOutput:(QTCaptureOutput *)captureOutput
didDropVideoFrameWithSampleBuffer:(QTSampleBuffer *)sampleBuffer didDropVideoFrameWithSampleBuffer:(QTSampleBuffer *)sampleBuffer
fromConnection:(QTCaptureConnection *)connection { fromConnection:(QTCaptureConnection *)connection {
(void)captureOutput;
(void)sampleBuffer;
(void)connection;
cout << "Camera dropped frame!" << endl; cout << "Camera dropped frame!" << endl;
} }

View File

@ -48,6 +48,10 @@
# pragma warning( disable: 4100 4244 4267 ) # pragma warning( disable: 4100 4244 4267 )
#endif #endif
#if defined __GNUC__ && defined __APPLE__
# pragma GCC diagnostic ignored "-Wshadow"
#endif
#include <ImfHeader.h> #include <ImfHeader.h>
#include <ImfInputFile.h> #include <ImfInputFile.h>
#include <ImfOutputFile.h> #include <ImfOutputFile.h>

View File

@ -45,6 +45,10 @@
#ifdef HAVE_OPENEXR #ifdef HAVE_OPENEXR
#if defined __GNUC__ && defined __APPLE__
# pragma GCC diagnostic ignored "-Wshadow"
#endif
#include <ImfChromaticities.h> #include <ImfChromaticities.h>
#include <ImfInputFile.h> #include <ImfInputFile.h>
#include <ImfChannelList.h> #include <ImfChannelList.h>

View File

@ -136,7 +136,7 @@ static bool wasInitialized = false;
} }
}*/ }*/
CV_IMPL int cvInitSystem( int argc, char** argv) CV_IMPL int cvInitSystem( int , char** )
{ {
//cout << "cvInitSystem" << endl; //cout << "cvInitSystem" << endl;
wasInitialized = true; wasInitialized = true;
@ -159,7 +159,7 @@ CV_IMPL int cvInitSystem( int argc, char** argv)
return 0; return 0;
} }
CVWindow *cvGetWindow(const char *name) { static CVWindow *cvGetWindow(const char *name) {
//cout << "cvGetWindow" << endl; //cout << "cvGetWindow" << endl;
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
NSString *cvname = [NSString stringWithFormat:@"%s", name]; NSString *cvname = [NSString stringWithFormat:@"%s", name];
@ -614,6 +614,7 @@ void cvSetModeWindow_COCOA( const char* name, double prop_value )
@synthesize status; @synthesize status;
- (void)cvSendMouseEvent:(NSEvent *)event type:(int)type flags:(int)flags { - (void)cvSendMouseEvent:(NSEvent *)event type:(int)type flags:(int)flags {
(void)event;
//cout << "cvSendMouseEvent" << endl; //cout << "cvSendMouseEvent" << endl;
NSPoint mp = [NSEvent mouseLocation]; NSPoint mp = [NSEvent mouseLocation];
//NSRect visible = [[self contentView] frame]; //NSRect visible = [[self contentView] frame];
@ -924,6 +925,7 @@ void cvSetModeWindow_COCOA( const char* name, double prop_value )
} }
- (void)sliderChanged:(NSNotification *)notification { - (void)sliderChanged:(NSNotification *)notification {
(void)notification;
int pos = [slider intValue]; int pos = [slider intValue];
if(value) if(value)
*value = pos; *value = pos;

View File

@ -109,6 +109,6 @@ void CV_FramecountTest::run(int)
} }
} }
} }
#if BUILD_WITH_VIDEO_INPUT_SUPPORT #if BUILD_WITH_VIDEO_INPUT_SUPPORT && defined HAVE_FFMPEG
TEST(Highgui_Video, framecount) {CV_FramecountTest test; test.safe_run();} TEST(Highgui_Video, framecount) {CV_FramecountTest test; test.safe_run();}
#endif #endif

View File

@ -217,7 +217,7 @@ void CV_VideoRandomPositioningTest::run(int)
run_test(RANDOM); run_test(RANDOM);
} }
#if BUILD_WITH_VIDEO_INPUT_SUPPORT #if BUILD_WITH_VIDEO_INPUT_SUPPORT && defined HAVE_FFMPEG
TEST (Highgui_Video, seek_progressive) { CV_VideoProgressivePositioningTest test; test.safe_run(); } TEST (Highgui_Video, seek_progressive) { CV_VideoProgressivePositioningTest test; test.safe_run(); }
TEST (Highgui_Video, seek_random) { CV_VideoRandomPositioningTest test; test.safe_run(); } TEST (Highgui_Video, seek_random) { CV_VideoRandomPositioningTest test; test.safe_run(); }
#endif #endif

View File

@ -173,6 +173,6 @@ public:
Size framesize; Size framesize;
}; };
#if BUILD_WITH_VIDEO_INPUT_SUPPORT && BUILD_WITH_VIDEO_OUTPUT_SUPPORT #if BUILD_WITH_VIDEO_INPUT_SUPPORT && BUILD_WITH_VIDEO_OUTPUT_SUPPORT && defined HAVE_FFMPEG
TEST(Highgui_Video, seek_random_synthetic) { CV_PositioningTest test; test.safe_run(); } TEST(Highgui_Video, seek_random_synthetic) { CV_PositioningTest test; test.safe_run(); }
#endif #endif

View File

@ -15,6 +15,7 @@ CV_ENUM(RemapMode, HALF_SIZE, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH)
typedef TestBaseWithParam< tr1::tuple<Size, InterType, BorderMode> > TestWarpAffine; typedef TestBaseWithParam< tr1::tuple<Size, InterType, BorderMode> > TestWarpAffine;
typedef TestBaseWithParam< tr1::tuple<Size, InterType, BorderMode> > TestWarpPerspective; typedef TestBaseWithParam< tr1::tuple<Size, InterType, BorderMode> > TestWarpPerspective;
typedef TestBaseWithParam< tr1::tuple<Size, InterType, BorderMode, MatType> > TestWarpPerspectiveNear_t;
typedef TestBaseWithParam< tr1::tuple<MatType, Size, InterType, BorderMode, RemapMode> > TestRemap; typedef TestBaseWithParam< tr1::tuple<MatType, Size, InterType, BorderMode, RemapMode> > TestRemap;
void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode ); void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode );
@ -80,44 +81,59 @@ PERF_TEST_P( TestWarpPerspective, WarpPerspective,
SANITY_CHECK(dst); SANITY_CHECK(dst);
} }
PERF_TEST_P( TestWarpPerspective, WarpPerspectiveLarge, PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear,
Combine( Combine(
Values( sz3MP, sz5MP ), Values( Size(176,144), Size(320,240), Size(352,288), Size(480,480),
ValuesIn( InterType::all() ), Size(640,480), Size(704,576), Size(720,408), Size(720,480),
ValuesIn( BorderMode::all() ) Size(720,576), Size(768,432), Size(800,448), Size(960,720),
Size(1024,768), Size(1280,720), Size(1280,960), Size(1360,720),
Size(1600,1200), Size(1920,1080), Size(2048,1536), Size(2592,1920),
Size(2592,1944), Size(3264,2448), Size(4096,3072), Size(4208,3120) ),
ValuesIn( InterType::all() ),
ValuesIn( BorderMode::all() ),
Values( CV_8UC1, CV_8UC4 )
)
) )
)
{ {
Size sz; Size size;
int borderMode, interType; int borderMode, interType, type;
sz = get<0>(GetParam()); size = get<0>(GetParam());
borderMode = get<1>(GetParam()); borderMode = get<1>(GetParam());
interType = get<2>(GetParam()); interType = get<2>(GetParam());
type = get<3>(GetParam());
string resolution; Mat src, img = imread(getDataPath("cv/shared/5MP.png"));
if (sz == sz3MP)
resolution = "3MP"; if( type == CV_8UC1 )
else if (sz == sz5MP) {
resolution = "5MP"; cvtColor(img, src, COLOR_BGR2GRAY, 1);
}
else if( type == CV_8UC4 )
{
cvtColor(img, src, COLOR_BGR2BGRA, 4);
}
else else
{
FAIL(); FAIL();
}
Mat src, img = imread(getDataPath("cv/shared/" + resolution + ".png")); resize(src, src, size);
cvtColor(img, src, COLOR_BGR2BGRA, 4);
int shift = 103; int shift = src.cols*0.04;
Mat srcVertices = (Mat_<Vec2f>(1, 4) << Vec2f(0, 0), Vec2f(sz.width-1, 0), Mat srcVertices = (Mat_<Vec2f>(1, 4) << Vec2f(0, 0), Vec2f(size.width-1, 0),
Vec2f(sz.width-1, sz.height-1), Vec2f(0, sz.height-1)); Vec2f(size.width-1, size.height-1), Vec2f(0, size.height-1));
Mat dstVertices = (Mat_<Vec2f>(1, 4) << Vec2f(0, shift), Vec2f(sz.width-shift/2, 0), Mat dstVertices = (Mat_<Vec2f>(1, 4) << Vec2f(0, shift), Vec2f(size.width-shift/2, 0),
Vec2f(sz.width-shift, sz.height-shift), Vec2f(shift/2, sz.height-1)); Vec2f(size.width-shift, size.height-shift), Vec2f(shift/2, size.height-1));
Mat warpMat = getPerspectiveTransform(srcVertices, dstVertices); Mat warpMat = getPerspectiveTransform(srcVertices, dstVertices);
Mat dst(sz, CV_8UC4); Mat dst(size, type);
declare.in(src).out(dst); declare.in(src).out(dst);
TEST_CYCLE() TEST_CYCLE()
warpPerspective( src, dst, warpMat, sz, interType, borderMode, Scalar::all(150) ); {
warpPerspective( src, dst, warpMat, size, interType, borderMode, Scalar::all(150) );
}
SANITY_CHECK(dst); SANITY_CHECK(dst);
} }

View File

@ -1387,8 +1387,8 @@ struct RGB2Lab_f
C6 = coeffs[6], C7 = coeffs[7], C8 = coeffs[8]; C6 = coeffs[6], C7 = coeffs[7], C8 = coeffs[8];
n *= 3; n *= 3;
static const float _1_3 = 1.0 / 3.0; static const float _1_3 = 1.0f / 3.0f;
static const double _a = 16.0 / 116; static const float _a = 16.0f / 116.0f;
for (i = 0; i < n; i += 3, src += scn ) for (i = 0; i < n; i += 3, src += scn )
{ {
float R = clip(src[0]); float R = clip(src[0]);
@ -1409,11 +1409,11 @@ struct RGB2Lab_f
float Y = R*C3 + G*C4 + B*C5; float Y = R*C3 + G*C4 + B*C5;
float Z = R*C6 + G*C7 + B*C8; float Z = R*C6 + G*C7 + B*C8;
float FX = X > 0.008856 ? pow(X, _1_3) : (7.787f * X + _a); float FX = X > 0.008856f ? pow(X, _1_3) : (7.787f * X + _a);
float FY = Y > 0.008856 ? pow(Y, _1_3) : (7.787f * Y + _a); float FY = Y > 0.008856f ? pow(Y, _1_3) : (7.787f * Y + _a);
float FZ = Z > 0.008856 ? pow(Z, _1_3) : (7.787f * Z + _a); float FZ = Z > 0.008856f ? pow(Z, _1_3) : (7.787f * Z + _a);
float L = Y > 0.008856 ? (116.f * FY - 16.f) : (903.3 * Y); float L = Y > 0.008856f ? (116.f * FY - 16.f) : (903.3f * Y);
float a = 500.f * (FX - FY); float a = 500.f * (FX - FY);
float b = 200.f * (FY - FZ); float b = 200.f * (FY - FZ);

View File

@ -220,7 +220,7 @@ static const void* initInterTab2D( int method, bool fixpt )
return fixpt ? (const void*)itab : (const void*)tab; return fixpt ? (const void*)itab : (const void*)tab;
} }
#ifndef __MINGW32__
static bool initAllInterTab2D() static bool initAllInterTab2D()
{ {
return initInterTab2D( INTER_LINEAR, false ) && return initInterTab2D( INTER_LINEAR, false ) &&
@ -232,6 +232,7 @@ static bool initAllInterTab2D()
} }
static volatile bool doInitAllInterTab2D = initAllInterTab2D(); static volatile bool doInitAllInterTab2D = initAllInterTab2D();
#endif
template<typename ST, typename DT> struct Cast template<typename ST, typename DT> struct Cast
{ {

View File

@ -169,7 +169,7 @@ private:
__instype *split = median; __instype *split = median;
for (; split != last && deref(ctor(*split), dim) == for (; split != last && deref(ctor(*split), dim) ==
deref(ctor(*median), dim); ++split); deref(ctor(*median), dim); ++split) {}
if (split == last) { // leaf if (split == last) { // leaf
int nexti = -1; int nexti = -1;
@ -387,9 +387,8 @@ public:
// ret_nn_pq is an array containing the (at most) k nearest neighbors // ret_nn_pq is an array containing the (at most) k nearest neighbors
// (see bbf_nn structure def above). // (see bbf_nn structure def above).
template < class __desctype > template < class __desctype >
int find_nn_bbf(const __desctype * d, int find_nn_bbf(const __desctype * d, int k, int emax, bbf_nn_pqueue & ret_nn_pq) const
int k, int emax, {
bbf_nn_pqueue & ret_nn_pq) const {
assert(k > 0); assert(k > 0);
ret_nn_pq.clear(); ret_nn_pq.clear();
@ -400,7 +399,8 @@ public:
// iterate while queue non-empty and emax>0 // iterate while queue non-empty and emax>0
tmp_pq.clear(); tmp_pq.clear();
tmp_pq.push_back(bbf_node(root_node, 0)); tmp_pq.push_back(bbf_node(root_node, 0));
while (tmp_pq.size() && emax > 0) { while (tmp_pq.size() && emax > 0)
{
// from node nearest query point d, run to leaf // from node nearest query point d, run to leaf
std::pop_heap(tmp_pq.begin(), tmp_pq.end()); std::pop_heap(tmp_pq.begin(), tmp_pq.end());
@ -408,18 +408,17 @@ public:
tmp_pq.erase(tmp_pq.end() - 1); tmp_pq.erase(tmp_pq.end() - 1);
int i; int i;
for (i = bbf.node; for (i = bbf.node; i != -1 && nodes[i].dim >= 0; i = bbf_branch(i, d, tmp_pq)) {}
i != -1 && nodes[i].dim >= 0;
i = bbf_branch(i, d, tmp_pq));
if (i != -1) { if (i != -1)
{
// add points in leaf/bin to ret_nn_pq // add points in leaf/bin to ret_nn_pq
do { do {
bbf_new_nn(ret_nn_pq, k, d, nodes[i].value); bbf_new_nn(ret_nn_pq, k, d, nodes[i].value);
} while (-1 != (i = nodes[i].right)); } while (-1 != (i = nodes[i].right));
--emax; --emax;
} }
} }

View File

@ -414,7 +414,7 @@ static void icvFindStereoCorrespondenceByBirchfieldDP( uchar* src1, uchar* src2,
for( x = 1; x < imgW; x++ ) for( x = 1; x < imgW; x++ )
{ {
i = x - 1; i = x - 1;
for( ; x < imgW && dest[y*widthStep+x] == dest[y*widthStep+x-1]; x++ ); for( ; x < imgW && dest[y*widthStep+x] == dest[y*widthStep+x-1]; x++ ) {}
s = x - i; s = x - i;
for( ; i < x; i++ ) for( ; i < x; i++ )
{ {

View File

@ -633,7 +633,7 @@ static CvTestSeqElem* icvTestSeqReadElemOne(CvTestSeq_* pTS, CvFileStorage* fs,
for(i0=0, i1=1; i1<KeyFrameNum;) for(i0=0, i1=1; i1<KeyFrameNum;)
{ {
for(i1=i0+1; i1<KeyFrameNum && KeyFrames[i1]<0; i1++); for(i1=i0+1; i1<KeyFrameNum && KeyFrames[i1]<0; i1++) {}
assert(i1<KeyFrameNum); assert(i1<KeyFrameNum);
assert(i1>i0); assert(i1>i0);
@ -779,7 +779,7 @@ static CvTestSeqElem* icvTestSeqReadElemAll(CvTestSeq_* pTS, CvFileStorage* fs,
} }
/* Find last element: */ /* Find last element: */
for(pElemLast=pElemNew;pElemLast && pElemLast->next;pElemLast= pElemLast->next); for(pElemLast=pElemNew;pElemLast && pElemLast->next;pElemLast= pElemLast->next) {}
} /* Next element. */ } /* Next element. */
} /* Read all element in sequence. */ } /* Read all element in sequence. */
@ -842,7 +842,7 @@ CvTestSeq* cvCreateTestSeq(char* pConfigfile, char** videos, int numvideo, float
else else
{ {
CvTestSeqElem* p = NULL; CvTestSeqElem* p = NULL;
for(p=pTS->pElemList;p->next;p=p->next); for(p=pTS->pElemList;p->next;p=p->next) {}
p->next = pElemNew; p->next = pElemNew;
} }
} /* Read all videos. */ } /* Read all videos. */

View File

@ -31,28 +31,20 @@ int getFeatureMaps(const IplImage* image, const int k, CvLSVMFeatureMap **map)
int i, j, kk, c, ii, jj, d; int i, j, kk, c, ii, jj, d;
float * datadx, * datady; float * datadx, * datady;
//номер канала в цикле
int ch; int ch;
//переменные вычисления магнитуды
float magnitude, x, y, tx, ty; float magnitude, x, y, tx, ty;
IplImage * dx, * dy; IplImage * dx, * dy;
int *nearest; int *nearest;
float *w, a_x, b_x; float *w, a_x, b_x;
// ядро для вычисления градиентов изображение по осям x и y
float kernel[3] = {-1.f, 0.f, 1.f}; float kernel[3] = {-1.f, 0.f, 1.f};
CvMat kernel_dx = cvMat(1, 3, CV_32F, kernel); CvMat kernel_dx = cvMat(1, 3, CV_32F, kernel);
CvMat kernel_dy = cvMat(3, 1, CV_32F, kernel); CvMat kernel_dy = cvMat(3, 1, CV_32F, kernel);
// грачение градиента
float * r; float * r;
// новер сектора куда попало значение градиента
// четные иннексы не контрастное изображение
// не четные иннексы контрастное изображение
int * alfa; int * alfa;
// векторы границ секторов
float boundary_x[NUM_SECTOR + 1]; float boundary_x[NUM_SECTOR + 1];
float boundary_y[NUM_SECTOR + 1]; float boundary_y[NUM_SECTOR + 1];
float max, dotProd; float max, dotProd;
@ -70,7 +62,7 @@ int getFeatureMaps(const IplImage* image, const int k, CvLSVMFeatureMap **map)
sizeX = width / k; sizeX = width / k;
sizeY = height / k; sizeY = height / k;
px = 3 * NUM_SECTOR; // контрастное и не контрастное изображение px = 3 * NUM_SECTOR;
p = px; p = px;
stringSize = sizeX * p; stringSize = sizeX * p;
allocFeatureMapObject(map, sizeX, sizeY, p); allocFeatureMapObject(map, sizeX, sizeY, p);
@ -138,7 +130,6 @@ int getFeatureMaps(const IplImage* image, const int k, CvLSVMFeatureMap **map)
}/*for(i = 0; i < width; i++)*/ }/*for(i = 0; i < width; i++)*/
}/*for(j = 0; j < height; j++)*/ }/*for(j = 0; j < height; j++)*/
//подсчет весов и смещений
nearest = (int *)malloc(sizeof(int ) * k); nearest = (int *)malloc(sizeof(int ) * k);
w = (float*)malloc(sizeof(float) * (k * 2)); w = (float*)malloc(sizeof(float) * (k * 2));
@ -167,7 +158,6 @@ int getFeatureMaps(const IplImage* image, const int k, CvLSVMFeatureMap **map)
}/*for(j = k / 2; j < k; j++)*/ }/*for(j = k / 2; j < k; j++)*/
//интерполяция
for(i = 0; i < sizeY; i++) for(i = 0; i < sizeY; i++)
{ {
for(j = 0; j < sizeX; j++) for(j = 0; j < sizeX; j++)
@ -275,7 +265,7 @@ int normalizeAndTruncate(CvLSVMFeatureMap *map, const float alfa)
sizeY -= 2; sizeY -= 2;
newData = (float *)malloc (sizeof(float) * (sizeX * sizeY * pp)); newData = (float *)malloc (sizeof(float) * (sizeX * sizeY * pp));
//normalization //normalization
for(i = 1; i <= sizeY; i++) for(i = 1; i <= sizeY; i++)
{ {
for(j = 1; j <= sizeX; j++) for(j = 1; j <= sizeX; j++)
@ -336,12 +326,12 @@ int normalizeAndTruncate(CvLSVMFeatureMap *map, const float alfa)
}/*for(ii = 0; ii < 2 * p; ii++)*/ }/*for(ii = 0; ii < 2 * p; ii++)*/
}/*for(j = 1; j <= sizeX; j++)*/ }/*for(j = 1; j <= sizeX; j++)*/
}/*for(i = 1; i <= sizeY; i++)*/ }/*for(i = 1; i <= sizeY; i++)*/
//truncation //truncation
for(i = 0; i < sizeX * sizeY * pp; i++) for(i = 0; i < sizeX * sizeY * pp; i++)
{ {
if(newData [i] > alfa) newData [i] = alfa; if(newData [i] > alfa) newData [i] = alfa;
}/*for(i = 0; i < sizeX * sizeY * pp; i++)*/ }/*for(i = 0; i < sizeX * sizeY * pp; i++)*/
//swop data //swap data
map->numFeatures = pp; map->numFeatures = pp;
map->sizeX = sizeX; map->sizeX = sizeX;
@ -354,6 +344,7 @@ int normalizeAndTruncate(CvLSVMFeatureMap *map, const float alfa)
return LATENT_SVM_OK; return LATENT_SVM_OK;
} }
/* /*
// Feature map reduction // Feature map reduction
// In each cell we reduce dimension of the feature vector // In each cell we reduce dimension of the feature vector
@ -427,7 +418,7 @@ int PCAFeatureMaps(CvLSVMFeatureMap *map)
} /*for(ii = 0; ii < yp; ii++)*/ } /*for(ii = 0; ii < yp; ii++)*/
}/*for(j = 0; j < sizeX; j++)*/ }/*for(j = 0; j < sizeX; j++)*/
}/*for(i = 0; i < sizeY; i++)*/ }/*for(i = 0; i < sizeY; i++)*/
//swop data //swap data
map->numFeatures = pp; map->numFeatures = pp;

View File

@ -3829,8 +3829,9 @@ static int zero = 0;
coeff_usage = CV_VALUE; \ coeff_usage = CV_VALUE; \
else if ((length == alpha.count) && (alpha.count == beta.count) && (beta.count == gamma.count)) \ else if ((length == alpha.count) && (alpha.count == beta.count) && (beta.count == gamma.count)) \
coeff_usage = CV_ARRAY; \ coeff_usage = CV_ARRAY; \
else \ else { \
return (PyObject*)failmsg("SnakeImage weights invalid"); \ failmsg("SnakeImage weights invalid"); \
return (PyObject*)0; } \
cvSnakeImage(image, points, length, a, b, g, coeff_usage, win, criteria, calc_gradient); \ cvSnakeImage(image, points, length, a, b, g, coeff_usage, win, criteria, calc_gradient); \
} while (0) } while (0)