int binIdx = featComponent % N_BINS;\r
int cellIdx = featComponent / N_BINS;\r
\r
- const float *hist = _hists[binIdx].ptr<float>(y);\r
+ const float *hist = _hists[binIdx].ptr<float>((int)y);\r
res = hist[fastRect[cellIdx].p0] - hist[fastRect[cellIdx].p1] - hist[fastRect[cellIdx].p2] + hist[fastRect[cellIdx].p3];\r
\r
- const float *normSum = _normSum.ptr<float>(y);\r
+ const float *normSum = _normSum.ptr<float>((int)y);\r
normFactor = (float)(normSum[fastRect[0].p0] - normSum[fastRect[1].p1] - normSum[fastRect[2].p2] + normSum[fastRect[3].p3]);\r
res = (res > 0.001f) ? ( res / (normFactor + 0.001f) ) : 0.f; //for cutting negative values, which apper due to floating precision\r
\r
if( _subsample_idx )
{
- CV_Assert( isubsample_idx = cvPreprocessIndexArray( _subsample_idx, sample_count ) );
+ CV_Assert( (isubsample_idx = cvPreprocessIndexArray( _subsample_idx, sample_count )) != 0 );
if( isubsample_idx->cols + isubsample_idx->rows - 1 == sample_count )
{
root = new_node( 0, count, 1, 0 );
- CV_Assert( subsample_co = cvCreateMat( 1, sample_count*2, CV_32SC1 ));
+ CV_Assert( (subsample_co = cvCreateMat( 1, sample_count*2, CV_32SC1 )) != 0);
cvZero( subsample_co );
co = subsample_co->data.i;
for( int i = 0; i < count; i++ )
projectPoints(points3d, rvec, tvec, intrinsics, distortion, points2d);
//add noise
- Mat noise(1, points2d.size(), CV_32FC2);
+ Mat noise(1, (int)points2d.size(), CV_32FC2);
randu(noise, 0, 0.01);
add(points2d, noise, points2d);
projectPoints(points3d, rvec, tvec, intrinsics, distortion, points2d);
//add noise
- Mat noise(1, points2d.size(), CV_32FC2);
+ Mat noise(1, (int)points2d.size(), CV_32FC2);
randu(noise, 0, 0.01);
add(points2d, noise, points2d);
return true;
}
else
- {
CV_Error(CV_StsBadArg, "The flags argument must be one of CV_ITERATIVE or CV_EPNP");
- return false;
- }
return false;
}
#define COUNT_NORM_TYPES 3\r
#define METHODS_COUNT 3\r
\r
-size_t NORM_TYPE[COUNT_NORM_TYPES] = {cv::NORM_L1, cv::NORM_L2, cv::NORM_INF};\r
-size_t METHOD[METHODS_COUNT] = {0, CV_RANSAC, CV_LMEDS};\r
+int NORM_TYPE[COUNT_NORM_TYPES] = {cv::NORM_L1, cv::NORM_L2, cv::NORM_INF};\r
+int METHOD[METHODS_COUNT] = {0, CV_RANSAC, CV_LMEDS};\r
\r
using namespace cv;\r
using namespace std;\r
\r
void CV_HomographyTest::run(int)\r
{\r
- for (size_t N = 4; N <= MAX_COUNT_OF_POINTS; ++N)\r
+ for (int N = 4; N <= MAX_COUNT_OF_POINTS; ++N)\r
{\r
RNG& rng = ts->get_rng();\r
\r
float *src_data = new float [2*N];\r
\r
- for (size_t i = 0; i < N; ++i)\r
+ for (int i = 0; i < N; ++i)\r
{\r
src_data[2*i] = (float)cvtest::randReal(rng)*image_size;\r
src_data[2*i+1] = (float)cvtest::randReal(rng)*image_size;\r
\r
vector <Point2f> src_vec, dst_vec;\r
\r
- for (size_t i = 0; i < N; ++i)\r
+ for (int i = 0; i < N; ++i)\r
{\r
float *tmp = src_mat_2d.ptr<float>()+2*i;\r
src_mat_3d.at<float>(0, i) = tmp[0];\r
\r
dst_mat_2d.create(2, N, CV_32F); dst_mat_2f.create(1, N, CV_32FC2);\r
\r
- for (size_t i = 0; i < N; ++i)\r
+ for (int i = 0; i < N; ++i)\r
{\r
float *tmp_2f = dst_mat_2f.ptr<float>()+2*i;\r
tmp_2f[0] = dst_mat_2d.at<float>(0, i) = dst_mat_3d.at<float>(0, i) /= dst_mat_3d.at<float>(2, i);\r
dst_vec.push_back(Point2f(tmp_2f[0], tmp_2f[1]));\r
}\r
\r
- for (size_t i = 0; i < METHODS_COUNT; ++i)\r
+ for (int i = 0; i < METHODS_COUNT; ++i)\r
{\r
method = METHOD[i];\r
switch (method)\r
cv::findHomography(src_vec, dst_mat_2f, method),\r
cv::findHomography(src_vec, dst_vec, method) };\r
\r
- for (size_t j = 0; j < 4; ++j)\r
+ for (int j = 0; j < 4; ++j)\r
{\r
\r
if (!check_matrix_size(H_res_64[j]))\r
\r
double diff;\r
\r
- for (size_t k = 0; k < COUNT_NORM_TYPES; ++k)\r
+ for (int k = 0; k < COUNT_NORM_TYPES; ++k)\r
if (!check_matrix_diff(H_64, H_res_64[j], NORM_TYPE[k], diff))\r
{\r
print_information_2(j, N, method, H_64, H_res_64[j], k, diff);\r
cv::findHomography(src_vec, dst_mat_2f, CV_RANSAC, reproj_threshold, mask[2]),\r
cv::findHomography(src_vec, dst_vec, CV_RANSAC, reproj_threshold, mask[3]) };\r
\r
- for (size_t j = 0; j < 4; ++j)\r
+ for (int j = 0; j < 4; ++j)\r
{\r
\r
if (!check_matrix_size(H_res_64[j]))\r
return;\r
}\r
\r
- for (size_t k = 0; k < COUNT_NORM_TYPES; ++k)\r
+ for (int k = 0; k < COUNT_NORM_TYPES; ++k)\r
if (!check_matrix_diff(H_64, H_res_64[j], NORM_TYPE[k], diff))\r
{\r
print_information_2(j, N, method, H_64, H_res_64[j], k, diff);\r
\r
cv::Mat mask(N, 1, CV_8UC1);\r
\r
- for (size_t i = 0; i < N; ++i)\r
+ for (int i = 0; i < N; ++i)\r
{\r
float *a = noise_2f.ptr<float>()+2*i, *_2f = dst_mat_2f.ptr<float>()+2*i;\r
_2f[0] += a[0]; _2f[1] += a[1];\r
mask.at<bool>(i, 0) = !(sqrt(a[0]*a[0]+a[1]*a[1]) > reproj_threshold);\r
}\r
\r
- for (size_t i = 0; i < METHODS_COUNT; ++i)\r
+ for (int i = 0; i < METHODS_COUNT; ++i)\r
{\r
method = METHOD[i];\r
switch (method)\r
cv::findHomography(src_vec, dst_mat_2f),\r
cv::findHomography(src_vec, dst_vec) };\r
\r
- for (size_t j = 0; j < 4; ++j)\r
+ for (int j = 0; j < 4; ++j)\r
{\r
\r
if (!check_matrix_size(H_res_64[j]))\r
\r
cv::Mat dst_res_3d(3, N, CV_32F), noise_2d(2, N, CV_32F);\r
\r
- for (size_t k = 0; k < N; ++k)\r
+ for (int k = 0; k < N; ++k)\r
{\r
\r
Mat tmp_mat_3d = H_res_32*src_mat_3d.col(k);\r
float *a = noise_2f.ptr<float>()+2*k;\r
noise_2d.at<float>(0, k) = a[0]; noise_2d.at<float>(1, k) = a[1];\r
\r
- for (size_t l = 0; l < COUNT_NORM_TYPES; ++l)\r
+ for (int l = 0; l < COUNT_NORM_TYPES; ++l)\r
if (cv::norm(tmp_mat_3d, dst_mat_3d.col(k), NORM_TYPE[l]) - cv::norm(noise_2d.col(k), NORM_TYPE[l]) > max_2diff)\r
{\r
print_information_4(method, j, N, k, l, cv::norm(tmp_mat_3d, dst_mat_3d.col(k), NORM_TYPE[l]) - cv::norm(noise_2d.col(k), NORM_TYPE[l]));\r
\r
}\r
\r
- for (size_t l = 0; l < COUNT_NORM_TYPES; ++l)\r
+ for (int l = 0; l < COUNT_NORM_TYPES; ++l)\r
if (cv::norm(dst_res_3d, dst_mat_3d, NORM_TYPE[l]) - cv::norm(noise_2d, NORM_TYPE[l]) > max_diff)\r
{\r
print_information_5(method, j, N, l, cv::norm(dst_res_3d, dst_mat_3d, NORM_TYPE[l]) - cv::norm(noise_2d, NORM_TYPE[l]));\r
cv::findHomography(src_vec, dst_mat_2f, CV_RANSAC, reproj_threshold, mask_res[2]),\r
cv::findHomography(src_vec, dst_vec, CV_RANSAC, reproj_threshold, mask_res[3]) };\r
\r
- for (size_t j = 0; j < 4; ++j)\r
+ for (int j = 0; j < 4; ++j)\r
{\r
-\r
if (!check_matrix_size(H_res_64[j]))\r
{\r
print_information_1(j, N, method, H_res_64[j]);\r
\r
cv::Mat dst_res_3d = H_res_32*src_mat_3d;\r
\r
- for (size_t k = 0; k < N; ++k)\r
+ for (int k = 0; k < N; ++k)\r
{\r
dst_res_3d.at<float>(0, k) /= dst_res_3d.at<float>(2, k);\r
dst_res_3d.at<float>(1, k) /= dst_res_3d.at<float>(2, k);\r
cv::Mat noise_2d(2, 1, CV_32F);\r
noise_2d.at<float>(0, 0) = a[0]; noise_2d.at<float>(1, 0) = a[1];\r
\r
- for (size_t l = 0; l < COUNT_NORM_TYPES; ++l)\r
+ for (int l = 0; l < COUNT_NORM_TYPES; ++l)\r
{\r
diff = cv::norm(dst_res_3d.col(k), dst_mat_3d.col(k), NORM_TYPE[l]);\r
\r
{
if (i % 20 == 0)
{
- projectedPoints[i] = projectedPoints[rng.uniform(0,points.size()-1)];
+ projectedPoints[i] = projectedPoints[rng.uniform(0,(int)points.size()-1)];
}
}
* Estimate the rigid body motion from frame0 to frame1. The method is based on the paper
* "Real-Time Visual Odometry from Dense RGB-D Images", F. Steinbucker, J. Strum, D. Cremers, ICCV, 2011.
*/
- CV_EXPORTS struct TransformationType
- {
- enum { ROTATION = 1,
- TRANSLATION = 2,
- RIGID_BODY_MOTION = 4
- };
- };
+ enum { ROTATION = 1,
+ TRANSLATION = 2,
+ RIGID_BODY_MOTION = 4
+ };
CV_EXPORTS bool RGBDOdometry( cv::Mat& Rt, const Mat& initRt,
const cv::Mat& image0, const cv::Mat& depth0, const cv::Mat& mask0,
const cv::Mat& image1, const cv::Mat& depth1, const cv::Mat& mask1,
const cv::Mat& cameraMatrix, float minDepth, float maxDepth, float maxDepthDiff,
const std::vector<int>& iterCounts, const std::vector<float>& minGradientMagnitudes,
- int transformType=TransformationType::RIGID_BODY_MOTION );
+ int transformType=RIGID_BODY_MOTION );
}
#include "opencv2/contrib/retina.hpp"
CV_Assert( src.total() >= count );
CV_Assert( src.type() == CV_8UC3);
- dst.create( 1, count, CV_8UC3 );
+ dst.create( 1, (int)count, CV_8UC3 );
//TODO: optimize by exploiting symmetry in the distance matrix
- Mat dists( src.total(), src.total(), CV_32FC1, Scalar(0) );
+ Mat dists( (int)src.total(), (int)src.total(), CV_32FC1, Scalar(0) );
if( dists.empty() )
std::cerr << "Such big matrix cann't be created." << std::endl;
Mat minDists;
reduce( activedDists, minDists, 0, CV_REDUCE_MIN );
minMaxLoc( minDists, 0, &maxVal, 0, &maxLoc, candidatePointsMask );
- dst.at<Point3_<uchar> >(i) = src.at<Point3_<uchar> >(maxLoc.x);
+ dst.at<Point3_<uchar> >((int)i) = src.at<Point3_<uchar> >(maxLoc.x);
}
}
// Generate a set of colors in RGB space. A size of the set is severel times (=factor) larger then
// the needed count of colors.
- Mat bgr( 1, count*factor, CV_8UC3 );
+ Mat bgr( 1, (int)(count*factor), CV_8UC3 );
randu( bgr, 0, 256 );
// Convert the colors set to Lab space.
CV_Assert( bgr_subset.total() == count );
for( size_t i = 0; i < count; i++ )
{
- Point3_<uchar> c = bgr_subset.at<Point3_<uchar> >(i);
+ Point3_<uchar> c = bgr_subset.at<Point3_<uchar> >((int)i);
colors[i] = Scalar(c.x, c.y, c.z);
}
}
for( int x = 0; x < cloud.cols; x++ )
{
float z = depth_prt[x];
- cloud_ptr[x].x = (x - ox) * z * inv_fx;
- cloud_ptr[x].y = (y - oy) * z * inv_fy;
+ cloud_ptr[x].x = (float)((x - ox) * z * inv_fx);
+ cloud_ptr[x].y = (float)((y - oy) * z * inv_fy);
cloud_ptr[x].z = z;
}
}
float d1 = depth1.at<float>(v1,u1);
if( !cvIsNaN(d1) && texturedMask1.at<uchar>(v1,u1) )
{
- float transformed_d1 = d1 * (KRK_inv_ptr[6] * u1 + KRK_inv_ptr[7] * v1 + KRK_inv_ptr[8]) + Kt_ptr[2];
+ float transformed_d1 = (float)(d1 * (KRK_inv_ptr[6] * u1 + KRK_inv_ptr[7] * v1 + KRK_inv_ptr[8]) + Kt_ptr[2]);
int u0 = cvRound((d1 * (KRK_inv_ptr[0] * u1 + KRK_inv_ptr[1] * v1 + KRK_inv_ptr[2]) + Kt_ptr[0]) / transformed_d1);
int v0 = cvRound((d1 * (KRK_inv_ptr[3] * u1 + KRK_inv_ptr[4] * v1 + KRK_inv_ptr[5]) + Kt_ptr[1]) / transformed_d1);
int exist_u1, exist_v1;
get2shorts( c, exist_u1, exist_v1);
- float exist_d1 = depth1.at<float>(exist_v1,exist_u1) * (KRK_inv_ptr[6] * exist_u1 + KRK_inv_ptr[7] * exist_v1 + KRK_inv_ptr[8]) + Kt_ptr[2];
+ float exist_d1 = (float)(depth1.at<float>(exist_v1,exist_u1) * (KRK_inv_ptr[6] * exist_u1 + KRK_inv_ptr[7] * exist_v1 + KRK_inv_ptr[8]) + Kt_ptr[2]);
if( transformed_d1 > exist_d1 )
continue;
vector<Mat>& pyramid_dI_dx1, vector<Mat>& pyramid_dI_dy1,
vector<Mat>& pyramidTexturedMask1, vector<Mat>& pyramidCameraMatrix )
{
- const int pyramidMaxLevel = minGradMagnitudes.size() - 1;
+ const int pyramidMaxLevel = (int)minGradMagnitudes.size() - 1;
buildPyramid( image0, pyramidImage0, pyramidMaxLevel );
buildPyramid( image1, pyramidImage1, pyramidMaxLevel );
const Mat& dy = pyramid_dI_dy1[i];
Mat texturedMask( dx.size(), CV_8UC1, Scalar(0) );
- const float minScalesGradMagnitude2 = (minGradMagnitudes[i] * minGradMagnitudes[i]) / (sobelScale * sobelScale);
+ const float minScalesGradMagnitude2 = (float)((minGradMagnitudes[i] * minGradMagnitudes[i]) / (sobelScale * sobelScale));
for( int y = 0; y < dx.rows; y++ )
{
for( int x = 0; x < dx.cols; x++ )
{
- float m2 = dx.at<short int>(y,x)*dx.at<short int>(y,x) + dy.at<short int>(y,x)*dy.at<short int>(y,x);
+ float m2 = (float)(dx.at<short>(y,x)*dx.at<short>(y,x) + dy.at<short>(y,x)*dy.at<short>(y,x));
if( m2 >= minScalesGradMagnitude2 )
texturedMask.at<uchar>(y,x) = 255;
}
{
int Cwidth = -1;
ComputeCFuncPtr computeCFuncPtr = 0;
- if( transformType == TransformationType::RIGID_BODY_MOTION )
+ if( transformType == RIGID_BODY_MOTION )
{
Cwidth = 6;
computeCFuncPtr = computeC_RigidBodyMotion;
}
- else if( transformType == TransformationType::ROTATION )
+ else if( transformType == ROTATION )
{
Cwidth = 3;
computeCFuncPtr = computeC_Rotation;
}
- else if( transformType == TransformationType::TRANSLATION )
+ else if( transformType == TRANSLATION )
{
Cwidth = 3;
computeCFuncPtr = computeC_Translation;
ksi = Scalar(0);
Mat subksi;
- if( transformType == TransformationType::RIGID_BODY_MOTION )
+ if( transformType == RIGID_BODY_MOTION )
{
subksi = ksi;
}
- else if( transformType == TransformationType::ROTATION )
+ else if( transformType == ROTATION )
{
subksi = ksi.rowRange(0,3);
}
- else if( transformType == TransformationType::TRANSLATION )
+ else if( transformType == TRANSLATION )
{
subksi = ksi.rowRange(3,6);
}
Mat resultRt = initRt.empty() ? Mat::eye(4,4,CV_64FC1) : initRt.clone();
Mat currRt, ksi;
- for( int level = iterCounts.size() - 1; level >= 0; level-- )
+ for( int level = (int)iterCounts.size() - 1; level >= 0; level-- )
{
const Mat& levelCameraMatrix = pyramidCameraMatrix[level];
/* Allocates string in memory storage */
CVAPI(CvString) cvMemStorageAllocString( CvMemStorage* storage, const char* ptr,
- int len CV_DEFAULT(-1) );
+ int len CV_DEFAULT(-1) );
/* Creates new empty sequence that will reside in the specified storage */
-CVAPI(CvSeq*) cvCreateSeq( int seq_flags, int header_size,
- int elem_size, CvMemStorage* storage );
+CVAPI(CvSeq*) cvCreateSeq( int seq_flags, size_t header_size,
+ size_t elem_size, CvMemStorage* storage );
/* Changes default size (granularity) of sequence blocks.
The default size is ~1Kbyte */
template<typename _Tp> struct CV_EXPORTS Matx_FastSolveOp<_Tp, 3, 1>
{
bool operator()(const Matx<_Tp, 3, 3>& a, const Matx<_Tp, 3, 1>& b,
- Matx<_Tp, 3, 1>& x, int method) const
+ Matx<_Tp, 3, 1>& x, int) const
{
- _Tp d = determinant(a);
+ _Tp d = (_Tp)determinant(a);
if( d == 0 )
return false;
d = 1/d;
{
_AccTp s = 0;
int i= 0;
- #if CV_ENABLE_UNROLLED
+#if CV_ENABLE_UNROLLED
for(; i <= n - 4; i += 4 )
{
_AccTp v0 = a[i] - b[i], v1 = a[i+1] - b[i+1], v2 = a[i+2] - b[i+2], v3 = a[i+3] - b[i+3];
#endif
for( ; i < n; i++ )
{
- _AccTp v = a[i] - b[i];
+ _AccTp v = (_AccTp)(a[i] - b[i]);
s += v*v;
}
return s;
{
_AccTp s = 0;
int i= 0;
- #if CV_ENABLE_UNROLLED
+#if CV_ENABLE_UNROLLED
for(; i <= n - 4; i += 4 )
{
_AccTp v0 = a[i] - b[i], v1 = a[i+1] - b[i+1], v2 = a[i+2] - b[i+2], v3 = a[i+3] - b[i+3];
#endif
for( ; i < n; i++ )
{
- _AccTp v = a[i] - b[i];
+ _AccTp v = (_AccTp)(a[i] - b[i]);
s += std::abs(v);
}
return s;
PERF_TEST_P(VectorLength, phase32f, testing::Values(128, 1000, 128*1024, 512*1024, 1024*1024))
{
- int length = GetParam();
+ size_t length = GetParam();
vector<float> X(length);
vector<float> Y(length);
vector<float> angle(length);
int x =0;
#if CV_SSE2
if( USE_SSE2 ){
- __m128i m128 = code == CMP_GT ? _mm_setzero_si128() : _mm_set1_epi8 (0xff);
- __m128i c128 = _mm_set1_epi8 (128);
+ __m128i m128 = code == CMP_GT ? _mm_setzero_si128() : _mm_set1_epi8 (-1);
+ __m128i c128 = _mm_set1_epi8 (-128);
for( ; x <= size.width - 16; x += 16 )
{
__m128i r00 = _mm_loadu_si128((const __m128i*)(src1 + x));
int x = 0;
#if CV_SSE2
if( USE_SSE2 ){
- __m128i m128 = code == CMP_EQ ? _mm_setzero_si128() : _mm_set1_epi8 (0xff);
+ __m128i m128 = code == CMP_EQ ? _mm_setzero_si128() : _mm_set1_epi8 (-1);
for( ; x <= size.width - 16; x += 16 )
{
__m128i r00 = _mm_loadu_si128((const __m128i*)(src1 + x));
int x =0;
#if CV_SSE2
if( USE_SSE2){//
- __m128i m128 = code == CMP_GT ? _mm_setzero_si128() : _mm_set1_epi16 (0xffff);
+ __m128i m128 = code == CMP_GT ? _mm_setzero_si128() : _mm_set1_epi16 (-1);
for( ; x <= size.width - 16; x += 16 )
{
__m128i r00 = _mm_loadu_si128((const __m128i*)(src1 + x));
int x = 0;
#if CV_SSE2
if( USE_SSE2 ){
- __m128i m128 = code == CMP_EQ ? _mm_setzero_si128() : _mm_set1_epi16 (0xffff);
+ __m128i m128 = code == CMP_EQ ? _mm_setzero_si128() : _mm_set1_epi16 (-1);
for( ; x <= size.width - 16; x += 16 )
{
__m128i r00 = _mm_loadu_si128((const __m128i*)(src1 + x));
for(;;)
{
bool tr = ((int)buf.length() > col_d-2) ? true: false;
- int pos;
+ std::string::size_type pos = 0;
if (tr)
{
pos = buf.find_first_of(' ');
for(;;)
{
- if ((int)buf.find_first_of(' ', pos + 1 ) < col_d-2 &&
- (int)buf.find_first_of(' ', pos + 1 ) != (int)std::string::npos)
+ if (buf.find_first_of(' ', pos + 1 ) < (std::string::size_type)(col_d-2) &&
+ buf.find_first_of(' ', pos + 1 ) != std::string::npos)
pos = buf.find_first_of(' ', pos + 1);
else
break;
/* Create empty sequence: */
CV_IMPL CvSeq *
-cvCreateSeq( int seq_flags, int header_size, int elem_size, CvMemStorage * storage )
+cvCreateSeq( int seq_flags, size_t header_size, size_t elem_size, CvMemStorage* storage )
{
CvSeq *seq = 0;
if( !storage )
CV_Error( CV_StsNullPtr, "" );
- if( header_size < (int)sizeof( CvSeq ) || elem_size <= 0 )
+ if( header_size < sizeof( CvSeq ) || elem_size <= 0 )
CV_Error( CV_StsBadSize, "" );
/* allocate sequence header */
seq = (CvSeq*)cvMemStorageAlloc( storage, header_size );
memset( seq, 0, header_size );
- seq->header_size = header_size;
+ seq->header_size = (int)header_size;
seq->flags = (seq_flags & ~CV_MAGIC_MASK) | CV_SEQ_MAGIC_VAL;
{
int elemtype = CV_MAT_TYPE(seq_flags);
int typesize = CV_ELEM_SIZE(elemtype);
if( elemtype != CV_SEQ_ELTYPE_GENERIC && elemtype != CV_USRTYPE1 &&
- typesize != 0 && typesize != elem_size )
+ typesize != 0 && typesize != (int)elem_size )
CV_Error( CV_StsBadSize,
"Specified element size doesn't match to the size of the specified element type "
"(try to use 0 for element type)" );
}
- seq->elem_size = elem_size;
+ seq->elem_size = (int)elem_size;
seq->storage = storage;
- cvSetSeqBlockSize( seq, (1 << 10)/elem_size );
+ cvSetSeqBlockSize( seq, (int)((1 << 10)/elem_size) );
return seq;
}
CV_PARSE_ERROR( "Bad format of floating-point constant" );
union{double d; uint64 i;} v;
+ v.d = 0.;
if( toupper(buf[1]) == 'I' && toupper(buf[2]) == 'N' && toupper(buf[3]) == 'F' )
v.i = (uint64)inf_hi << 32;
else if( toupper(buf[1]) == 'N' && toupper(buf[2]) == 'A' && toupper(buf[3]) == 'N' )
\r
while (n < count_non_zero)\r
{\r
- size_t i = rng.next()%size.height, j = rng.next()%size.width;\r
+ int i = rng.next()%size.height, j = rng.next()%size.width;\r
\r
switch (type)\r
{\r
\r
for (int i = 0; i < src.rows; ++i)\r
for (int j = 0; j < src.cols; ++j)\r
-\r
+ {\r
if (current_type == CV_8U) result += (src.at<uchar>(i, j) > 0);\r
-\r
- else if (current_type == CV_8S) result += abs(sign(src.at<char>(i, j)));\r
-\r
- else if (current_type == CV_16U) result += (src.at<ushort>(i, j) > 0);\r
-\r
- else if (current_type == CV_16S) result += abs(sign(src.at<short>(i, j)));\r
-\r
- else if (current_type == CV_32S) result += abs(sign(src.at<int>(i, j)));\r
-\r
- else if (current_type == CV_32F) result += (fabs(src.at<float>(i, j)) > eps_32);\r
-\r
- else result += (fabs(src.at<double>(i, j)) > eps_64);\r
+ else if (current_type == CV_8S) result += abs(sign(src.at<char>(i, j)));\r
+ else if (current_type == CV_16U) result += (src.at<ushort>(i, j) > 0);\r
+ else if (current_type == CV_16S) result += abs(sign(src.at<short>(i, j)));\r
+ else if (current_type == CV_32S) result += abs(sign(src.at<int>(i, j)));\r
+ else if (current_type == CV_32F) result += (fabs(src.at<float>(i, j)) > eps_32);\r
+ else result += (fabs(src.at<double>(i, j)) > eps_64);\r
+ }\r
\r
return result;\r
}\r
#define MESSAGE_ERROR_ORTHO "Matrix of eigen vectors is not orthogonal."\r
#define MESSAGE_ERROR_ORDER "Eigen values are not sorted in ascending order."\r
\r
-const size_t COUNT_NORM_TYPES = 3;\r
-const size_t NORM_TYPE[COUNT_NORM_TYPES] = {cv::NORM_L1, cv::NORM_L2, cv::NORM_INF};\r
+const int COUNT_NORM_TYPES = 3;\r
+const int NORM_TYPE[COUNT_NORM_TYPES] = {cv::NORM_L1, cv::NORM_L2, cv::NORM_INF};\r
\r
enum TASK_TYPE_EIGEN {VALUES, VECTORS};\r
\r
\r
cv::Mat E = Mat::eye(U.rows, U.cols, type);\r
\r
- for (size_t i = 0; i < COUNT_NORM_TYPES; ++i)\r
+ for (int i = 0; i < COUNT_NORM_TYPES; ++i)\r
{\r
double diff = cv::norm(UUt, E, NORM_TYPE[i]);\r
if (diff > eps_vec)\r
{\r
case CV_32FC1:\r
{\r
- for (size_t i = 0; i < eigen_values.total() - 1; ++i)\r
+ for (int i = 0; i < (int)(eigen_values.total() - 1); ++i)\r
if (!(eigen_values.at<float>(i, 0) > eigen_values.at<float>(i+1, 0)))\r
{\r
std::cout << endl; std::cout << "Checking order of eigen values vector " << eigen_values << "..." << endl;\r
\r
case CV_64FC1:\r
{\r
- for (size_t i = 0; i < eigen_values.total() - 1; ++i)\r
+ for (int i = 0; i < (int)(eigen_values.total() - 1); ++i)\r
if (!(eigen_values.at<double>(i, 0) > eigen_values.at<double>(i+1, 0)))\r
{\r
std::cout << endl; std::cout << "Checking order of eigen values vector " << eigen_values << "..." << endl;\r
\r
cv::Mat disparity = src_evec - eval_evec;\r
\r
- for (size_t i = 0; i < COUNT_NORM_TYPES; ++i)\r
+ for (int i = 0; i < COUNT_NORM_TYPES; ++i)\r
{\r
double diff = cv::norm(disparity, NORM_TYPE[i]);\r
if (diff > eps_vec)\r
\r
if (!check_pair_count(src, eigen_values_2)) return false;\r
\r
- for (size_t i = 0; i < COUNT_NORM_TYPES; ++i)\r
+ for (int i = 0; i < COUNT_NORM_TYPES; ++i)\r
{\r
double diff = cv::norm(eigen_values_1, eigen_values_2, NORM_TYPE[i]);\r
if (diff > eps_val)\r
\r
for (int i = 1; i <= MATRIX_COUNT; ++i)\r
{\r
- size_t src_size = (int)(std::pow(2.0, (rand()%MAX_DEGREE+1)*1.0));\r
+ int src_size = (int)(std::pow(2.0, (rand()%MAX_DEGREE+1)*1.0));\r
\r
cv::Mat src(src_size, src_size, type);\r
\r
Mat img = _img.getMat();
const int K = 8, N = 16 + K + 1;
int i, j, k, pixel[N];
- makeOffsets(pixel, img.step);
+ makeOffsets(pixel, (int)img.step);
for(k = 16; k < N; k++)
pixel[k] = pixel[k - 16];
threshold = std::min(std::max(threshold, 0), 255);
#if CV_SSE2
- __m128i delta = _mm_set1_epi8(128), t = _mm_set1_epi8(threshold), K16 = _mm_set1_epi8(K);
+ __m128i delta = _mm_set1_epi8(-128), t = _mm_set1_epi8((char)threshold), K16 = _mm_set1_epi8((char)K);
#endif
uchar threshold_tab[512];
for( i = -255; i <= 255; i++ )
{
cornerpos[ncorners++] = j+k;
if(nonmax_suppression)
- curr[j+k] = cornerScore(ptr+k, pixel, threshold);
+ curr[j+k] = (uchar)cornerScore(ptr+k, pixel, threshold);
}
}
#endif
{
cornerpos[ncorners++] = j;
if(nonmax_suppression)
- curr[j] = cornerScore(ptr, pixel, threshold);
+ curr[j] = (uchar)cornerScore(ptr, pixel, threshold);
break;
}
}
{
cornerpos[ncorners++] = j;
if(nonmax_suppression)
- curr[j] = cornerScore(ptr, pixel, threshold);
+ curr[j] = (uchar)cornerScore(ptr, pixel, threshold);
break;
}
}
FileNode ip = fn["indexParams"];
CV_Assert(ip.type() == FileNode::SEQ);
- for(size_t i = 0; i < ip.size(); ++i)
+ for(int i = 0; i < (int)ip.size(); ++i)
{
CV_Assert(ip[i].type() == FileNode::MAP);
std::string name = (std::string)ip[i]["name"];
indexParams->setString(name, (std::string) ip[i]["value"]);
break;
case CV_MAKETYPE(CV_USRTYPE1,2):
- indexParams->setBool(name, (int) ip[i]["value"]);
+ indexParams->setBool(name, (int) ip[i]["value"] != 0);
break;
case CV_MAKETYPE(CV_USRTYPE1,3):
indexParams->setAlgorithm((int) ip[i]["value"]);
FileNode sp = fn["searchParams"];
CV_Assert(sp.type() == FileNode::SEQ);
- for(size_t i = 0; i < sp.size(); ++i)
+ for(int i = 0; i < (int)sp.size(); ++i)
{
CV_Assert(sp[i].type() == FileNode::MAP);
std::string name = (std::string)sp[i]["name"];
searchParams->setString(name, (std::string) ip[i]["value"]);
break;
case CV_MAKETYPE(CV_USRTYPE1,2):
- searchParams->setBool(name, (int) ip[i]["value"]);
+ searchParams->setBool(name, (int) ip[i]["value"] != 0);
break;
case CV_MAKETYPE(CV_USRTYPE1,3):
searchParams->setAlgorithm((int) ip[i]["value"]);
struct MSERParams
{
- MSERParams( int _delta, int _minArea, int _maxArea, float _maxVariation,
- float _minDiversity, int _maxEvolution, double _areaThreshold,
+ MSERParams( int _delta, int _minArea, int _maxArea, double _maxVariation,
+ double _minDiversity, int _maxEvolution, double _areaThreshold,
double _minMargin, int _edgeBlurSize )
: delta(_delta), minArea(_minArea), maxArea(_maxArea), maxVariation(_maxVariation),
minDiversity(_minDiversity), maxEvolution(_maxEvolution), areaThreshold(_areaThreshold),
int delta;
int minArea;
int maxArea;
- float maxVariation;
- float minDiversity;
+ double maxVariation;
+ double minDiversity;
int maxEvolution;
double areaThreshold;
double minMargin;
vector<Mat> imagePyramid(nlevels), maskPyramid(nlevels);
for (int level = 0; level < nlevels; ++level)
{
- float scale = 1/getScale(level, firstLevel, scale);
+ float scale = 1/getScale(level, firstLevel, scaleFactor);
Size sz(cvRound(image.cols*scale), cvRound(image.rows*scale));
Size wholeSize(sz.width + border*2, sz.height + border*2);
Mat temp(wholeSize, image.type()), masktemp;
}
else
{
- float sf = scaleFactor;
- resize(imagePyramid[level-1], imagePyramid[level], sz, 1./sf, 1./sf, INTER_LINEAR);
+ resize(imagePyramid[level-1], imagePyramid[level], sz,
+ 1./scaleFactor, 1./scaleFactor, INTER_LINEAR);
if (!mask.empty())
- resize(maskPyramid[level-1], maskPyramid[level], sz, 1./sf, 1./sf, INTER_LINEAR);
+ resize(maskPyramid[level-1], maskPyramid[level], sz,
+ 1./scaleFactor, 1./scaleFactor, INTER_LINEAR);
copyMakeBorder(imagePyramid[level], temp, border, border, border, border,
BORDER_REFLECT_101+BORDER_ISOLATED);
}
const uchar* I = matI.ptr<uchar>();
int *S = matS.ptr<int>(), *T = matT.ptr<int>(), *FT = _FT.ptr<int>();
- int istep = matI.step, step = matS.step/sizeof(S[0]);
+ int istep = (int)matI.step, step = (int)(matS.step/sizeof(S[0]));
for( x = 0; x <= cols; x++ )
S[x] = T[x] = FT[x] = 0;
DistanceType tmp = distance(dataset[i], query, dataset.cols);
if (dcnt<n) {
- match[dcnt] = i;
+ match[dcnt] = (int)i;
dists[dcnt++] = tmp;
}
else if (tmp < dists[dcnt-1]) {
dists[dcnt-1] = tmp;
- match[dcnt-1] = i;
+ match[dcnt-1] = (int)i;
}
int j = dcnt-1;
for (int i=0; i<trees_; ++i) {
indices[i] = new int[size_];
for (size_t j=0; j<size_; ++j) {
- indices[i][j] = j;
+ indices[i][j] = (int)j;
}
root[i] = pool.allocate<Node>();
- computeClustering(root[i], indices[i], size_, branching_,0);
+ computeClustering(root[i], indices[i], (int)size_, branching_,0);
}
}
int maxChecks = get_param(searchParams,"checks",32);
// Priority queue storing intermediate branches in the best-bin-first search
- Heap<BranchSt>* heap = new Heap<BranchSt>(size_);
+ Heap<BranchSt>* heap = new Heap<BranchSt>((int)size_);
std::vector<bool> checked(size_,false);
int checks = 0;
{
save_value(stream, *node);
if (node->childs==NULL) {
- int indices_offset = node->indices - indices[num];
+ int indices_offset = (int)(node->indices - indices[num]);
save_value(stream, indices_offset);
}
else {
index.findNeighbors(resultSet, testData[i], searchParams);
correct += countCorrectMatches(neighbors,matches[i], nn);
- distR += computeDistanceRaport<Distance>(inputData, testData[i], neighbors, matches[i], testData.cols, nn, distance);
+ distR += computeDistanceRaport<Distance>(inputData, testData[i], neighbors, matches[i], (int)testData.cols, nn, distance);
}
t.stop();
}
// Create a permutable array of indices to the input vectors.
vind_.resize(size_);
for (size_t i = 0; i < size_; i++) {
- vind_[i] = i;
+ vind_[i] = (int)i;
}
}
void buildIndex()
{
computeBoundingBox(root_bbox_);
- root_node_ = divideTree(0, size_, root_bbox_ ); // construct the tree
+ root_node_ = divideTree(0, (int)size_, root_bbox_ ); // construct the tree
if (reorder_) {
delete[] data_.data;
*/
int usedMemory() const
{
- return pool_.usedMemory+pool_.wastedMemory+dataset_.rows*sizeof(int); // pool memory and vind array memory
+ return (int)(pool_.usedMemory+pool_.wastedMemory+dataset_.rows*sizeof(int)); // pool memory and vind array memory
}
computeMinMax(ind, count, cutfeat, min_elem, max_elem);
DistanceType spread = (DistanceType)(max_elem-min_elem);
if (spread>max_spread) {
- cutfeat = i;
+ cutfeat = (int)i;
max_spread = spread;
}
}
for (size_t i = 0; i < dim_; ++i) {
if (vec[i] < root_bbox_[i].low) {
- dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].low, i);
+ dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].low, (int)i);
distsq += dists[i];
}
if (vec[i] > root_bbox_[i].high) {
- dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].high, i);
+ dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].high, (int)i);
distsq += dists[i];
}
}
for (int i=0; i<branching; ++i) {
centers[i] = new DistanceType[veclen_];
- memoryCounter_ += veclen_*sizeof(DistanceType);
+ memoryCounter_ += (int)(veclen_*sizeof(DistanceType));
for (size_t k=0; k<veclen_; ++k) {
centers[i][k] = (DistanceType)dcenters[i][k];
}
ElementType* data = dataset_.data;
for (size_t i = 0; i < dataset_.rows; ++i, data += dataset_.cols) {
DistanceType dist = distance_(data, vec, dataset_.cols);
- resultSet.addPoint(dist, i);
+ resultSet.addPoint(dist, (int)i);
}
}
key_size_ = get_param<int>(index_params_,"key_size",20);
multi_probe_level_ = get_param<int>(index_params_,"multi_probe_level",2);
- feature_size_ = dataset_.cols;
+ feature_size_ = (unsigned)dataset_.cols;
fill_xor_mask(0, key_size_, multi_probe_level_, xor_masks_);
}
*/
int usedMemory() const
{
- return dataset_.rows * sizeof(int);
+ return (int)(dataset_.rows * sizeof(int));
}
std::vector<lsh::BucketKey>::const_iterator xor_mask_end = xor_masks_.end();
for (; xor_mask != xor_mask_end; ++xor_mask) {
size_t sub_key = key ^ (*xor_mask);
- const lsh::Bucket* bucket = table->getBucketFromKey(sub_key);
+ const lsh::Bucket* bucket = table->getBucketFromKey((lsh::BucketKey)sub_key);
if (bucket == 0) continue;
// Go over each descriptor index
// Process the rest of the candidates
for (; training_index < last_training_index; ++training_index) {
// Compute the Hamming distance
- hamming_distance = distance_(vec, dataset_[*training_index], dataset_.cols);
+ hamming_distance = distance_(vec, dataset_[*training_index], (int)dataset_.cols);
result.addPoint(hamming_distance, *training_index);
}
}
LshTable(unsigned int /*feature_size*/, unsigned int /*key_size*/)
{
std::cerr << "LSH is not implemented for that type" << std::endl;
- throw;
+ assert(0);
}
/** Add a feature to the table
void add(unsigned int value, const ElementType* feature)
{
// Add the value to the corresponding bucket
- BucketKey key = getKey(feature);
+ BucketKey key = (lsh::BucketKey)getKey(feature);
switch (speed_level_) {
case kArray:
size_t getKey(const ElementType* /*feature*/) const
{
std::cerr << "LSH is not implemented for that type" << std::endl;
- throw;
+ assert(0);
return 1;
}
if (!buckets_speed_.empty()) {
for (BucketsSpeed::const_iterator pbucket = buckets_speed_.begin(); pbucket != buckets_speed_.end(); ++pbucket) {
- stats.bucket_sizes_.push_back(pbucket->size());
+ stats.bucket_sizes_.push_back((lsh::FeatureIndex)pbucket->size());
stats.bucket_size_mean_ += pbucket->size();
}
stats.bucket_size_mean_ /= buckets_speed_.size();
}
else {
for (BucketsSpace::const_iterator x = buckets_space_.begin(); x != buckets_space_.end(); ++x) {
- stats.bucket_sizes_.push_back(x->second.size());
+ stats.bucket_sizes_.push_back((lsh::FeatureIndex)x->second.size());
stats.bucket_size_mean_ += x->second.size();
}
stats.bucket_size_mean_ /= buckets_space_.size();
int* indices_ptr = NULL;
DistanceType* dists_ptr = NULL;
if (indices.cols > 0) {
- n = indices.cols;
+ n = (int)indices.cols;
indices_ptr = indices[0];
dists_ptr = dists[0];
}
else resultSet.copy(indices_ptr, dists_ptr, n);
}
- return resultSet.size();
+ return (int)resultSet.size();
}
/**
T* src,* dest;
for (long i=0; i<size; ++i) {
- long r = rand_int(srcMatrix.rows-i);
+ long r = rand_int((int)(srcMatrix.rows-i));
dest = newSet[i];
src = srcMatrix[r];
std::copy(src, src+srcMatrix.cols, dest);
template<typename T>
Matrix<T> random_sample(const Matrix<T>& srcMatrix, size_t size)
{
- UniqueRandom rand(srcMatrix.rows);
+ UniqueRandom rand((int)srcMatrix.rows);
Matrix<T> newSet(new T[size * srcMatrix.cols], size,srcMatrix.cols);
T* src,* dest;
*************************************************************************/
#include "precomp.hpp"
+
+#ifdef _MSC_VER\r
+#pragma warning(disable: 4996)\r
+#endif
#include "opencv2/flann/flann.hpp"
namespace cvflann
#include <cstdarg>\r
#include <sstream>\r
\r
+#ifdef _MSC_VER\r
+#pragma warning(disable: 4996)\r
+#endif\r
+\r
#ifdef HAVE_CVCONFIG_H\r
# include "cvconfig.h"\r
#endif\r
#if defined _M_X64 && defined _MSC_VER && !defined CV_ICC
#pragma optimize("",off)
+#pragma warning( disable: 4748 )
#endif
namespace cv
#if defined _M_X64
#pragma optimize("",off)
+#pragma warning(disable: 4748)
#endif
/********************* Capturing video from AVI via VFW ************************/
#ifdef HAVE_JPEG
+#ifdef _MSC_VER
+#pragma warning(disable: 4324 4611)
+#endif
+
#include <stdio.h>
#include <setjmp.h>
generate_idx_seq(cap, method);
- int N = idx.size(), failed_frames = 0, failed_positions = 0, failed_iterations = 0;
+ int N = (int)idx.size(), failed_frames = 0, failed_positions = 0, failed_iterations = 0;
for (int j = 0; j < N; ++j)
{
\r
Mat kernel(kSize, kSize, CV_32FC1);\r
randu(kernel, -3, 10);\r
- float s = fabs( sum(kernel)[0] );\r
+ double s = fabs( sum(kernel)[0] );\r
if(s > 1e-3) kernel /= s;\r
\r
declare.in(src, WARMUP_RNG).out(dst).time(20);\r
const uchar* y = src.ptr();
const uchar* uv = y + dstSz.area();
+ int srcstep = (int)src.step;
// http://www.fourcc.org/yuv.php#NV21 == yuv420sp -> a plane of 8 bit Y samples followed by an interleaved V/U plane containing 8 bit 2x2 subsampled chroma samples
// http://www.fourcc.org/yuv.php#NV12 == yvu420sp -> a plane of 8 bit Y samples followed by an interleaved U/V plane containing 8 bit 2x2 subsampled colour difference samples
if (CV_YUV420sp2RGB == code || COLOR_YUV420sp2RGBA == code)
{
if (dcn == 3)
- cvtYUV4202RGB<2, 1>(dst, src.step, y, uv);
+ cvtYUV4202RGB<2, 1>(dst, srcstep, y, uv);
else
- cvtYUV4202RGBA<2, 1>(dst, src.step, y, uv);
+ cvtYUV4202RGBA<2, 1>(dst, srcstep, y, uv);
}
else if (CV_YUV420sp2BGR == code || CV_YUV420sp2BGRA == code)
{
if (dcn == 3)
- cvtYUV4202RGB<0, 1>(dst, src.step, y, uv);
+ cvtYUV4202RGB<0, 1>(dst, srcstep, y, uv);
else
- cvtYUV4202RGBA<0, 1>(dst, src.step, y, uv);
+ cvtYUV4202RGBA<0, 1>(dst, srcstep, y, uv);
}
else if (CV_YUV2RGB_NV12 == code || CV_YUV2RGBA_NV12 == code)
{
if (dcn == 3)
- cvtYUV4202RGB<2, 0>(dst, src.step, y, uv);
+ cvtYUV4202RGB<2, 0>(dst, srcstep, y, uv);
else
- cvtYUV4202RGBA<2, 0>(dst, src.step, y, uv);
+ cvtYUV4202RGBA<2, 0>(dst, srcstep, y, uv);
}
else //if (CV_YUV2BGR_NV12 == code || CV_YUV2BGRA_NV12 == code)
{
if (dcn == 3)
- cvtYUV4202RGB<0, 0>(dst, src.step, y, uv);
+ cvtYUV4202RGB<0, 0>(dst, srcstep, y, uv);
else
- cvtYUV4202RGBA<0, 0>(dst, src.step, y, uv);
+ cvtYUV4202RGBA<0, 0>(dst, srcstep, y, uv);
}
}
break;
if( ksize.width > 0 )
xmax = ksize.width/2;
else
- xmax = std::max(fabs(nstds*sigma_x*c), fabs(nstds*sigma_y*s));
+ xmax = cvRound(std::max(fabs(nstds*sigma_x*c), fabs(nstds*sigma_y*s)));
if( ksize.height > 0 )
ymax = ksize.height/2;
else
- ymax = std::max(fabs(nstds*sigma_x*s), fabs(nstds*sigma_y*c));
+ ymax = cvRound(std::max(fabs(nstds*sigma_x*s), fabs(nstds*sigma_y*c)));
xmin = -xmax;
ymin = -ymax;
(0.0 > t) || (t > 1.0) )
code = '0';
- p.x = a.x + s * ( b.x - a.x );
- p.y = a.y + s * ( b.y - a.y );
+ p.x = (float)(a.x + s*(b.x - a.x));
+ p.y = (float)(a.y + s*(b.y - a.y));
return code;
}
_p12.release();
return 0.f;
}
- area = contourArea(_InputArray(result, nr), false);
+ area = (float)contourArea(_InputArray(result, nr), false);
}
if( _p12.needed() )
int row0 = min(cvRound(range.begin() * src.rows / nStripes), src.rows);
int row1 = min(cvRound(range.end() * src.rows / nStripes), src.rows);
- if(0)
+ /*if(0)
printf("Size = (%d, %d), range[%d,%d), row0 = %d, row1 = %d\n",
- src.rows, src.cols, range.begin(), range.end(), row0, row1);
+ src.rows, src.cols, range.begin(), range.end(), row0, row1);*/
Mat srcStripe = src.rowRange(row0, row1);
Mat dstStripe = dst.rowRange(row0, row1);
Point anchor;
int rowBorderType;
int columnBorderType;
- const Scalar& borderValue;
+ Scalar borderValue;
};
static void morphOp( int op, InputArray _src, OutputArray _dst,
int rows = dst.rows;
int cols = dst.cols;
- int step = dst.step/dst.elemSize1();
if(dst.depth() == CV_32F)
{
- float* dstData = dst.ptr<float>();
-
for(int i = 0; i < rows; i++)
{
+ float* dstData = dst.ptr<float>(i);
double wr = 0.5 * (1.0f - cos(2.0f * CV_PI * (double)i / (double)(rows - 1)));
for(int j = 0; j < cols; j++)
{
double wc = 0.5 * (1.0f - cos(2.0f * CV_PI * (double)j / (double)(cols - 1)));
- dstData[i*step + j] = (float)(wr * wc);
+ dstData[j] = (float)(wr * wc);
}
}
}
else
{
- double* dstData = dst.ptr<double>();
-
for(int i = 0; i < rows; i++)
{
+ double* dstData = dst.ptr<double>(i);
double wr = 0.5 * (1.0 - cos(2.0 * CV_PI * (double)i / (double)(rows - 1)));
for(int j = 0; j < cols; j++)
{
double wc = 0.5 * (1.0 - cos(2.0 * CV_PI * (double)j / (double)(cols - 1)));
- dstData[i*step + j] = wr * wc;
+ dstData[j] = wr * wc;
}
}
}
int row0 = std::min(cvRound(range.begin() * src.rows / nStripes), src.rows);
int row1 = std::min(cvRound(range.end() * src.rows / nStripes), src.rows);
- if(0)
+ /*if(0)
printf("Size = (%d, %d), range[%d,%d), row0 = %d, row1 = %d\n",
- src.rows, src.cols, range.begin(), range.end(), row0, row1);
+ src.rows, src.cols, range.begin(), range.end(), row0, row1);*/
Mat srcStripe = src.rowRange(row0, row1);
Mat dstStripe = dst.rowRange(row0, row1);
\r
template <typename T> cv::Rect CV_BoundingRectTest::get_bounding_rect(const vector <Point_<T> > src)\r
{\r
- int n = src.size();\r
+ int n = (int)src.size();\r
T min_w = std::numeric_limits<T>::max(), max_w = std::numeric_limits<T>::min();\r
T min_h = min_w, max_h = max_w;\r
\r
KeyPointsFilter::runByImageBorder(keypoints, image.size(), BORDER_SIZE);
/// @todo Check 16-byte aligned
- descriptors.create(keypoints.size(), classifier_.classes(), cv::DataType<T>::type);
+ descriptors.create((int)keypoints.size(), classifier_.classes(), cv::DataType<T>::type);
int patchSize = RandomizedTree::PATCH_SIZE;
int offset = patchSize / 2;
{
cv::Point2f pt = keypoints[i].pt;
IplImage ipl = image( Rect((int)(pt.x - offset), (int)(pt.y - offset), patchSize, patchSize) );
- classifier_.getSignature( &ipl, descriptors.ptr<T>(i));
+ classifier_.getSignature( &ipl, descriptors.ptr<T>((int)i));
}
}
*_keypoints = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvSURFPoint), storage);
if( _descriptors )
- *_descriptors = cvCreateSeq( 0, sizeof(CvSeq), descr.cols*descr.elemSize(), storage );
+ *_descriptors = cvCreateSeq(0, sizeof(CvSeq), descr.cols*descr.elemSize(), storage);
for( size_t i = 0; i < kpt.size(); i++ )
{
cvSeqPush(*_keypoints, &pt);
}
if( _descriptors )
- cvSeqPush(*_descriptors, descr.ptr(i));
+ cvSeqPush(*_descriptors, descr.ptr((int)i));
}
}
if( x <= 0 || x >= img.cols - 1 )
continue;
- float dx = img.at<short>(y, x+1) - img.at<short>(y, x-1);
- float dy = img.at<short>(y-1, x) - img.at<short>(y+1, x);
+ float dx = (float)(img.at<short>(y, x+1) - img.at<short>(y, x-1));
+ float dy = (float)(img.at<short>(y-1, x) - img.at<short>(y+1, x));
X[k] = dx; Y[k] = dy; W[k] = (i*i + j*j)*expf_scale;
k++;
(img.at<short>(r+1, c) - img.at<short>(r-1, c))*deriv_scale,
(next.at<short>(r, c) - prev.at<short>(r, c))*deriv_scale);
- float v2 = img.at<short>(r, c)*2;
+ float v2 = (float)img.at<short>(r, c)*2;
float dxx = (img.at<short>(r, c+1) + img.at<short>(r, c-1) - v2)*second_deriv_scale;
float dyy = (img.at<short>(r+1, c) + img.at<short>(r-1, c) - v2)*second_deriv_scale;
float dss = (next.at<short>(r, c) + prev.at<short>(r, c) - v2)*second_deriv_scale;
return false;
/* principal curvatures are computed using the trace and det of Hessian */
- float v2 = img.at<short>(r, c)*2;
+ float v2 = img.at<short>(r, c)*2.f;
float dxx = (img.at<short>(r, c+1) + img.at<short>(r, c-1) - v2)*second_deriv_scale;
float dyy = (img.at<short>(r+1, c) + img.at<short>(r-1, c) - v2)*second_deriv_scale;
float dxy = (img.at<short>(r+1, c+1) - img.at<short>(r+1, c-1) -
val <= prevptr[c+step-1] && val <= prevptr[c+step] && val <= prevptr[c+step+1])))
{
int r1 = r, c1 = c, layer = i;
- if( !adjustLocalExtrema(dog_pyr, kpt, o, layer, r1, c1, nOctaveLayers,
- contrastThreshold, edgeThreshold, sigma) )
+ if( !adjustLocalExtrema(dog_pyr, kpt, o, layer, r1, c1,
+ nOctaveLayers, (float)contrastThreshold,
+ (float)edgeThreshold, (float)sigma) )
continue;
float scl_octv = kpt.size*0.5f/(1 << o);
float omax = calcOrientationHist(gauss_pyr[o*(nOctaveLayers+3) + layer],
if( rbin > -1 && rbin < d && cbin > -1 && cbin < d &&
r > 0 && r < rows - 1 && c > 0 && c < cols - 1 )
{
- float dx = img.at<short>(r, c+1) - img.at<short>(r, c-1);
- float dy = img.at<short>(r-1, c) - img.at<short>(r+1, c);
+ float dx = (float)(img.at<short>(r, c+1) - img.at<short>(r, c-1));
+ float dy = (float)(img.at<short>(r-1, c) - img.at<short>(r+1, c));
X[k] = dx; Y[k] = dy; RBin[k] = rbin; CBin[k] = cbin;
W[k] = (c_rot * c_rot + r_rot * r_rot)*exp_scale;
k++;
Point2f ptf(kpt.pt.x*scale, kpt.pt.y*scale);
const Mat& img = gpyr[octv*(nOctaveLayers + 3) + layer];
- calcSIFTDescriptor(img, ptf, kpt.angle, size*0.5f, d, n, descriptors.ptr<float>(i));
+ calcSIFTDescriptor(img, ptf, kpt.angle, size*0.5f, d, n, descriptors.ptr<float>((int)i));
}
}
if( !mask.empty() && mask.type() != CV_8UC1 )
CV_Error( CV_StsBadArg, "mask has incorrect type (!=CV_8UC1)" );
- Mat base = createInitialImage(image, false, sigma);
+ Mat base = createInitialImage(image, false, (float)sigma);
vector<Mat> gpyr, dogpyr;
int nOctaves = cvRound(log( (double)std::min( base.cols, base.rows ) ) / log(2.) - 2);
{
kpt.pt.x += x(0,0)*dx;
kpt.pt.y += x(1,0)*dy;
- kpt.size = cvRound( kpt.size + x(2,0)*ds );
+ kpt.size = (float)cvRound( kpt.size + x(2,0)*ds );
}
return ok;
}
float center_i = sum_i + (size-1)*0.5f;
float center_j = sum_j + (size-1)*0.5f;
- KeyPoint kpt( center_j, center_i, sizes[layer], -1, val0, octave, CV_SIGN(trace_ptr[j]) );
+ KeyPoint kpt( center_j, center_i, (float)sizes[layer],
+ -1, val0, octave, CV_SIGN(trace_ptr[j]) );
/* Interpolate maxima location within the 3x3x3 neighbourhood */
int ds = size - sizes[layer-1];
{
maxSize = std::max(maxSize, (*keypoints)[k].size);
}
- maxSize = cvCeil((PATCH_SZ+1)*maxSize*1.2f/9.0f);
- Ptr<CvMat> winbuf = cvCreateMat( 1, maxSize > 0 ? maxSize*maxSize : 1, CV_8U );
+ int imaxSize = std::max(cvCeil((PATCH_SZ+1)*maxSize*1.2f/9.0f), 1);
+ Ptr<CvMat> winbuf = cvCreateMat( 1, imaxSize*imaxSize, CV_8U );
for( k = k1; k < k2; k++ )
{
int i, j, kk, x, y, nangle;
cv::min(mask, 1, mask1);
integral(mask1, msum, CV_32S);
}
- fastHessianDetector( sum, msum, keypoints, nOctaves, nOctaveLayers, hessianThreshold );
+ fastHessianDetector( sum, msum, keypoints, nOctaves, nOctaveLayers, (float)hessianThreshold );
}
int i, j, N = (int)keypoints.size();
if (exp.empty())
return;
- if (!testDetector(to_test, SurfNoMaskWrap(SURF(1536+512+512, 2)), exp))
+ if (!testDetector(to_test, SurfNoMaskWrap(SURF(1536+512+512, true, false, 2)), exp))
return;
LoadExpected(string(ts->get_data_path()) + "detectors/star.xml", exp);
\r
const int extentionSize = 4; //.xml\r
\r
- int substrLength = filename.size() - startPos - extentionSize;\r
+ int substrLength = (int)(filename.size() - startPos - extentionSize);\r
\r
return filename.substr(startPos, substrLength);\r
}\r
case 64: return 6;
case 128: return 7;
default:
- CV_Assert(false);
+ CV_Error(CV_StsBadArg, "Invalid value of quantized parameter");
return -1; //avoid warning
}
}
float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8];\r
\r
float u_ = atan2f(x_, z_);\r
- float v_ = CV_PI - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_));\r
+ float v_ = (float)CV_PI - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_));\r
\r
u = scale * v_ * cosf(u_);\r
v = scale * v_ * sinf(u_);\r
float u_ = atan2f(v, u);\r
float v_ = sqrtf(u*u + v*v);\r
\r
- float sinv = sinf(CV_PI - v_);\r
+ float sinv = sinf((float)CV_PI - v_);\r
float x_ = sinv * sinf(u_);\r
- float y_ = cosf(CV_PI - v_);\r
+ float y_ = cosf((float)CV_PI - v_);\r
float z_ = sinv * cosf(u_);\r
\r
float z;\r
float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8];\r
\r
float u_ = atan2f(x_, z_);\r
- float v_ = CV_PI - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_));\r
+ float v_ = (float)CV_PI - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_));\r
\r
float r = sinf(v_) / (1 - cosf(v_));\r
\r
\r
float u_ = atan2f(v, u);\r
float r = sqrtf(u*u + v*v);\r
- float v_ = 2 * atanf(1.0 / r);\r
+ float v_ = 2 * atanf(1.f / r);\r
\r
- float sinv = sinf(CV_PI - v_);\r
+ float sinv = sinf((float)CV_PI - v_);\r
float x_ = sinv * sinf(u_);\r
- float y_ = cosf(CV_PI - v_);\r
+ float y_ = cosf((float)CV_PI - v_);\r
float z_ = sinv * cosf(u_);\r
\r
float z;\r
float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_));\r
\r
u = scale * u_;\r
- v = scale * logf( tanf( CV_PI/4 + v_/2 ) );\r
+ v = scale * logf( tanf( (float)(CV_PI/4) + v_/2 ) );\r
}\r
\r
inline\r
} else if (image.type() == CV_8UC1) {\r
gray_image=image;\r
} else {\r
- CV_Assert(false);\r
+ CV_Error(CV_StsUnsupportedFormat, "");\r
}\r
\r
if (grid_size.area() == 1)\r
\r
for (size_t i = 0; i < comps.size.size(); ++i)\r
{\r
- if (comps.size[comps.findSetByElem(i)] == 1)\r
+ if (comps.size[comps.findSetByElem((int)i)] == 1)\r
{\r
string name = pathes[i];\r
size_t prefix_len = name.find_last_of("/\\");\r
warper->warp(mask, K, cameras_[img_idx].R, INTER_NEAREST, BORDER_CONSTANT, mask_warped);
// Compensate exposure
- exposure_comp_->apply(img_idx, corners[img_idx], img_warped, mask_warped);
+ exposure_comp_->apply((int)img_idx, corners[img_idx], img_warped, mask_warped);
img_warped.convertTo(img_warped_s, CV_16S);
img_warped.release();
(*features_finder_)(img, features_[i]);
else
(*features_finder_)(img, features_[i], rois_[i]);
- features_[i].img_idx = i;
+ features_[i].img_idx = (int)i;
LOGLN("Features in image #" << i+1 << ": " << features_[i].keypoints.size());
resize(full_img, img, Size(), seam_scale_, seam_scale_);
if (m.depth() < CV_32F)\r
{\r
int minmax[] = {0, 256};\r
- cv::Mat mr = cv::Mat(m.rows, m.cols * m.elemSize(), CV_8U, m.ptr(), m.step[0]);\r
+ cv::Mat mr = cv::Mat(m.rows, (int)(m.cols * m.elemSize()), CV_8U, m.ptr(), m.step[0]);\r
cv::randu(mr, cv::Mat(1, 1, CV_32S, minmax), cv::Mat(1, 1, CV_32S, minmax + 1));\r
}\r
else if (m.depth() == CV_32F)\r
\r
if (data_path_dir)\r
{\r
- int len = strlen(data_path_dir)-1;\r
+ int len = (int)strlen(data_path_dir)-1;\r
if (len < 0) len = 0;\r
std::string path_base = (data_path_dir[0] == 0 ? std::string(".") : std::string(data_path_dir))\r
+ (data_path_dir[len] == '/' || data_path_dir[len] == '\\' ? "" : path_separator)\r
write() << "type" << array.type();\r
if (isVector(array))\r
{\r
- int total = array.total();\r
+ int total = (int)array.total();\r
int idx = regRNG.uniform(0, total);\r
write() << "len" << total;\r
write() << "idx" << idx;\r
{\r
size_t total = a.total();\r
for (size_t i = 0; i < total; ++i)\r
- warmup_impl(a.getMat(i), wtype);\r
+ warmup_impl(a.getMat((int)i), wtype);\r
}\r
}\r
\r
std::string path;\r
if (data_path_dir)\r
{\r
- int len = strlen(data_path_dir) - 1;\r
+ int len = (int)strlen(data_path_dir) - 1;\r
if (len < 0) len = 0;\r
path = (data_path_dir[0] == 0 ? std::string(".") : std::string(data_path_dir))\r
+ (data_path_dir[len] == '/' || data_path_dir[len] == '\\' ? "" : path_separator);\r
*/
static void set_params(int argc, char* argv[], CvVSModule* pM, const char* prefix, const char* module)
{
- int prefix_len = strlen(prefix);
+ int prefix_len = (int)strlen(prefix);
int i;
for(i=0; i<argc; ++i)
{
cmd++;
ptr_eq = strchr(cmd,'=');
- if(ptr_eq)cmd_param_len = ptr_eq-cmd;
+ if(ptr_eq)
+ cmd_param_len = (int)(ptr_eq-cmd);
for(j=0; ; ++j)
{
int param_len;
const char* param = pM->GetParamName(j);
if(param==NULL) break;
- param_len = strlen(param);
+ param_len = (int)strlen(param);
if(cmd_param_len!=param_len) continue;
if(MY_STRNICMP(param,cmd,param_len)!=0) continue;
cmd+=param_len;
if( var_desc )
{
char buf[100];
- int len = strchr( var_desc[i], '(' ) - var_desc[i] - 1;
+ int len = (int)(strchr( var_desc[i], '(' ) - var_desc[i] - 1);
strncpy( buf, var_desc[i], len );
buf[len] = '\0';
printf( "%s", buf );
return -1;
rmap[ival] = 1;
}
- return rmap.size();
+ return (int)rmap.size();
}
void print_result(float train_err, float test_err, const CvMat* _var_imp)
int localAdaptation_photoreceptors, localAdaptation_Gcells;
void callBack_updateRetinaParams(int, void*)
{
-
- retina->setupOPLandIPLParvoChannel(true, true, (float)(localAdaptation_photoreceptors/200.0), 0.5f, 0.43f, (double)retinaHcellsGain, 1.f, 7.f, (float)(localAdaptation_Gcells/200.0));
+ retina->setupOPLandIPLParvoChannel(true, true, (float)(localAdaptation_photoreceptors/200.0), 0.5f, 0.43f, (float)retinaHcellsGain, 1.f, 7.f, (float)(localAdaptation_Gcells/200.0));
}
int colorSaturationFactor;
{
inputMat.copyTo(outputMat);
// update threshold in the initial input image range
- maxInputValue=(maxInputValue-255.f)/histNormRescalefactor+maxInput;
- minInputValue=minInputValue/histNormRescalefactor+minInput;
+ maxInputValue=(float)((maxInputValue-255.f)/histNormRescalefactor+maxInput);
+ minInputValue=(float)(minInputValue/histNormRescalefactor+minInput);
std::cout<<"===> Input Hist clipping values (max,min) = "<<maxInputValue<<", "<<minInputValue<<std::endl;
cv::threshold( outputMat, outputMat, maxInputValue, maxInputValue, 2 ); //THRESH_TRUNC, clips values above maxInputValue
cv::threshold( outputMat, outputMat, minInputValue, minInputValue, 3 ); //
int localAdaptation_photoreceptors, localAdaptation_Gcells;
void callBack_updateRetinaParams(int, void*)
{
-
- retina->setupOPLandIPLParvoChannel(true, true, (float)(localAdaptation_photoreceptors/200.0), 0.5f, 0.43f, (double)retinaHcellsGain, 1.f, 7.f, (float)(localAdaptation_Gcells/200.0));
+ retina->setupOPLandIPLParvoChannel(true, true, (float)(localAdaptation_photoreceptors/200.0), 0.5f, 0.43f, (float)retinaHcellsGain, 1.f, 7.f, (float)(localAdaptation_Gcells/200.0));
}
int colorSaturationFactor;
double maxInput, minInput;
minMaxLoc(inputImage, &minInput, &maxInput);
std::cout<<"FIRST IMAGE pixels values range (max,min) : "<<maxInput<<", "<<minInput<<std::endl;
- globalRescalefactor=50.0/(maxInput-minInput); // less than 255 for flexibility... experimental value to be carefull about
- float channelOffset = -1.5*minInput;
+ globalRescalefactor=(float)(50.0/(maxInput-minInput)); // less than 255 for flexibility... experimental value to be carefull about
+ double channelOffset = -1.5*minInput;
globalOffset= cv::Scalar(channelOffset, channelOffset, channelOffset, channelOffset);
}
// call the generic input image rescaling callback
CV_Error(CV_StsError,err_msg.c_str());
}
/* convert iterator to index */
- target_idx = std::distance(output_headers.begin(),target_idx_it);
+ target_idx = (int)std::distance(output_headers.begin(),target_idx_it);
}
/* prepare variables related to calculating recall if using the recall threshold */
/* in order to calculate the total number of relevant images for normalization of recall
it's necessary to extract the ground truth for the images under consideration */
getClassifierGroundTruth(obj_class, images, ground_truth);
- total_relevant = std::count_if(ground_truth.begin(),ground_truth.end(),std::bind2nd(std::equal_to<char>(),(char)1));
+ total_relevant = (int)std::count_if(ground_truth.begin(),ground_truth.end(),std::bind2nd(std::equal_to<char>(),(char)1));
}
/* iterate through images */
CV_Error(CV_StsError,err_msg.c_str());
}
/* convert iterator to index */
- int class_idx = std::distance(output_headers.begin(),class_idx_it);
+ int class_idx = (int)std::distance(output_headers.begin(),class_idx_it);
//add to confusion matrix row in proportion
output_values[class_idx] += 1.f/static_cast<float>(img_objects.size());
}
if (ov > maxov)
{
maxov = ov;
- max_gt_obj_idx = gt_obj_idx;
+ max_gt_obj_idx = (int)gt_obj_idx;
}
}
}
CV_Error(CV_StsError,err_msg.c_str());
}
/* convert iterator to index */
- int class_idx = std::distance(output_headers.begin(),class_idx_it);
+ int class_idx = (int)std::distance(output_headers.begin(),class_idx_it);
//add to confusion matrix row in proportion
output_values[class_idx] += 1.0;
} else {
bounding_boxes.push_back(bounding_box_vect);
} else {
/* if the image index has been seen before, add the current object below it in the 2D arrays */
- int image_idx = std::distance(image_codes.begin(),image_codes_it);
+ int image_idx = (int)std::distance(image_codes.begin(),image_codes_it);
scores[image_idx].push_back(score);
bounding_boxes[image_idx].push_back(bounding_box);
}
{
VocabTrainParams() : trainObjClass("chair"), vocabSize(1000), memoryUse(200), descProportion(0.3f) {}
VocabTrainParams( const string _trainObjClass, size_t _vocabSize, size_t _memoryUse, float _descProportion ) :
- trainObjClass(_trainObjClass), vocabSize(_vocabSize), memoryUse(_memoryUse), descProportion(_descProportion) {}
+ trainObjClass(_trainObjClass), vocabSize((int)_vocabSize), memoryUse((int)_memoryUse), descProportion(_descProportion) {}
void read( const FileNode& fn )
{
fn["trainObjClass"] >> trainObjClass;
// Randomly pick an image from the dataset which hasn't yet been seen
// and compute the descriptors from that image.
- int randImgIdx = rng( images.size() );
+ int randImgIdx = rng( (unsigned)images.size() );
Mat colorImage = imread( images[randImgIdx].path );
vector<KeyPoint> imageKeypoints;
fdetector->detect( colorImage, imageKeypoints );
const SVMTrainParamsExt& svmParamsExt, int descsToDelete )
{
RNG& rng = theRNG();
- int pos_ex = std::count( objectPresent.begin(), objectPresent.end(), (char)1 );
- int neg_ex = std::count( objectPresent.begin(), objectPresent.end(), (char)0 );
+ int pos_ex = (int)std::count( objectPresent.begin(), objectPresent.end(), (char)1 );
+ int neg_ex = (int)std::count( objectPresent.begin(), objectPresent.end(), (char)0 );
while( descsToDelete != 0 )
{
- int randIdx = rng(images.size());
+ int randIdx = rng((unsigned)images.size());
// Prefer positive training examples according to svmParamsExt.targetRatio if required
if( objectPresent[randIdx] )
}
// Prepare the input matrices for SVM training.
- Mat trainData( images.size(), bowExtractor->getVocabulary().rows, CV_32FC1 );
- Mat responses( images.size(), 1, CV_32SC1 );
+ Mat trainData( (int)images.size(), bowExtractor->getVocabulary().rows, CV_32FC1 );
+ Mat responses( (int)images.size(), 1, CV_32SC1 );
// Transfer bag of words vectors and responses across to the training data matrices
for( size_t imageIdx = 0; imageIdx < images.size(); imageIdx++ )
{
// Transfer image descriptor (bag of words vector) to training data matrix
- Mat submat = trainData.row(imageIdx);
+ Mat submat = trainData.row((int)imageIdx);
if( bowImageDescriptors[imageIdx].cols != bowExtractor->descriptorSize() )
{
cout << "Error: computed bow image descriptor size " << bowImageDescriptors[imageIdx].cols
bowImageDescriptors[imageIdx].copyTo( submat );
// Set response value
- responses.at<int>(imageIdx) = objectPresent[imageIdx] ? 1 : -1;
+ responses.at<int>((int)imageIdx) = objectPresent[imageIdx] ? 1 : -1;
}
cout << "TRAINING SVM FOR CLASS ..." << objClassName << "..." << endl;
if( !imagePoints.empty() )
{
- Mat imagePtMat((int)imagePoints.size(), imagePoints[0].size(), CV_32FC2);
+ Mat imagePtMat((int)imagePoints.size(), (int)imagePoints[0].size(), CV_32FC2);
for( int i = 0; i < (int)imagePoints.size(); i++ )
{
Mat r = imagePtMat.row(i).reshape(2, imagePtMat.cols);
imshow("image", isColor ? image : gray);
int c = waitKey(0);
- switch( (char)c )
+ if( (c & 255) == 27 )
{
- case 27:
cout << "Exiting ...\n";
- return 0;
+ break;
+ }
+ switch( (char)c )
+ {
case 'c':
if( isColor )
{
HybridTrackerParams params;
// motion model params
params.motion_model = CvMotionModel::LOW_PASS_FILTER;
- params.low_pass_gain = 0.1;
+ params.low_pass_gain = 0.1f;
// mean shift params
- params.ms_tracker_weight = 0.8;
+ params.ms_tracker_weight = 0.8f;
params.ms_params.tracking_type = CvMeanShiftTrackerParams::HS;
// feature tracking params
- params.ft_tracker_weight = 0.2;
+ params.ft_tracker_weight = 0.2f;
params.ft_params.feature_type = CvFeatureTrackerParams::OPTICAL_FLOW;
params.ft_params.window_size = 0;
int i = 0;
float w[4];
- while(1)
+ for(;;)
{
i++;
if (live)
{
cap >> frame;
+ if( frame.empty() )
+ break;
frame.copyTo(image);
}
else
fscanf(f, "%d %f %f %f %f\n", &i, &w[0], &w[1], &w[2], &w[3]);
sprintf(img_file, "seqG/%04d.png", i);
image = imread(img_file, CV_LOAD_IMAGE_COLOR);
- selection = Rect(w[0]*image.cols, w[1]*image.rows, w[2]*image.cols, w[3]*image.rows);
+ if (image.empty())
+ break;
+ selection = Rect(cvRound(w[0]*image.cols), cvRound(w[1]*image.rows),
+ cvRound(w[2]*image.cols), cvRound(w[3]*image.rows));
}
- if (image.data == NULL)
- continue;
-
sprintf(img_file_num, "Frame: %d", i);
putText(image, img_file_num, Point(10, image.rows-20), FONT_HERSHEY_PLAIN, 0.75, Scalar(255, 255, 255));
if (!image.empty())
bitwise_not(roi, roi);
}
- drawRectangle(&image, Rect(w[0]*image.cols, w[1]*image.rows, w[2]*image.cols, w[3]*image.rows));
+ drawRectangle(&image, Rect(cvRound(w[0]*image.cols), cvRound(w[1]*image.rows),
+ cvRound(w[2]*image.cols), cvRound(w[3]*image.rows)));
imshow("Win", image);
waitKey(100);
fclose(f);
return 0;
-
}
help();
string images_folder, models_folder;
- float overlapThreshold = 0.2;
+ float overlapThreshold = 0.2f;
int numThreads = -1;
if( argc > 2 )
{
images_folder = argv[1];
models_folder = argv[2];
- if( argc > 3 ) overlapThreshold = atof(argv[3]);
+ if( argc > 3 ) overlapThreshold = (float)atof(argv[3]);
if( overlapThreshold < 0 || overlapThreshold > 1)
{
cout << "overlapThreshold must be in interval (0,1)." << endl;
imshow( "result", image );
- while(1)
+ for(;;)
{
int c = waitKey();
if( (char)c == 'n')
}
private:
- static void cv_on_mouse(int a_event, int a_x, int a_y, int a_flags, void * a_params)
+ static void cv_on_mouse(int a_event, int a_x, int a_y, int, void *)
{
m_event = a_event;
m_x = a_x;
std::copy(ids.begin(), ids.end(), std::ostream_iterator<std::string>(std::cout, "\n"));
}
}
- int num_modalities = detector->getModalities().size();
+ int num_modalities = (int)detector->getModalities().size();
// Open Kinect sensor
cv::VideoCapture capture( CV_CAP_OPENNI );
// Main loop
cv::Mat color, depth;
- while (true)
+ for(;;)
{
// Capture next color/depth pair
capture.grab();
std::vector<std::string> class_ids;
std::vector<cv::Mat> quantized_images;
match_timer.start();
- detector->match(sources, matching_threshold, matches, class_ids, quantized_images);
+ detector->match(sources, (float)matching_threshold, matches, class_ids, quantized_images);
match_timer.stop();
int classes_visited = 0;
cv::FileStorage fs;
char key = (char)cvWaitKey(10);
+ if( key == 'q' )
+ break;
+
switch (key)
{
case 'h':
writeLinemod(detector, filename);
printf("Wrote detector and templates to %s\n", filename.c_str());
break;
- case 'q':
- return 0;
+ default:
+ ;
}
}
return 0;
for (int l_i = 0; l_i < (int)a_chain.size(); ++l_i)
{
- float x_diff = a_chain[(l_i + 1) % a_chain.size()].x - a_chain[l_i].x;
- float y_diff = a_chain[(l_i + 1) % a_chain.size()].y - a_chain[l_i].y;
+ float x_diff = (float)(a_chain[(l_i + 1) % a_chain.size()].x - a_chain[l_i].x);
+ float y_diff = (float)(a_chain[(l_i + 1) % a_chain.size()].y - a_chain[l_i].y);
lp_seg_length[l_i] = sqrt(x_diff*x_diff + y_diff*y_diff);
l_chain_length += lp_seg_length[l_i];
}
{
if (lp_seg_length[l_i] > 0)
{
- int l_cur_num = l_num_cost_pts * lp_seg_length[l_i] / l_chain_length;
+ int l_cur_num = cvRound(l_num_cost_pts * lp_seg_length[l_i] / l_chain_length);
float l_cur_len = lp_seg_length[l_i] / l_cur_num;
for (int l_j = 0; l_j < l_cur_num; ++l_j)
CvPoint l_pts;
- l_pts.x = l_ratio * (a_chain[(l_i + 1) % a_chain.size()].x - a_chain[l_i].x) + a_chain[l_i].x;
- l_pts.y = l_ratio * (a_chain[(l_i + 1) % a_chain.size()].y - a_chain[l_i].y) + a_chain[l_i].y;
+ l_pts.x = cvRound(l_ratio * (a_chain[(l_i + 1) % a_chain.size()].x - a_chain[l_i].x) + a_chain[l_i].x);
+ l_pts.y = cvRound(l_ratio * (a_chain[(l_i + 1) % a_chain.size()].y - a_chain[l_i].y) + a_chain[l_i].y);
l_chain_vector.push_back(l_pts);
}
reprojectPoints(lp_src_3Dpts, lp_src_3Dpts, f);
- CvMat * lp_pts = cvCreateMat(l_chain_vector.size(), 4, CV_32F);
+ CvMat * lp_pts = cvCreateMat((int)l_chain_vector.size(), 4, CV_32F);
CvMat * lp_v = cvCreateMat(4, 4, CV_32F);
CvMat * lp_w = cvCreateMat(4, 1, CV_32F);
for (int l_i = 0; l_i < (int)l_chain_vector.size(); ++l_i)
{
- CV_MAT_ELEM(*lp_pts, float, l_i, 0) = lp_src_3Dpts[l_i].x;
- CV_MAT_ELEM(*lp_pts, float, l_i, 1) = lp_src_3Dpts[l_i].y;
- CV_MAT_ELEM(*lp_pts, float, l_i, 2) = lp_src_3Dpts[l_i].z;
- CV_MAT_ELEM(*lp_pts, float, l_i, 3) = 1.0;
+ CV_MAT_ELEM(*lp_pts, float, l_i, 0) = (float)lp_src_3Dpts[l_i].x;
+ CV_MAT_ELEM(*lp_pts, float, l_i, 1) = (float)lp_src_3Dpts[l_i].y;
+ CV_MAT_ELEM(*lp_pts, float, l_i, 2) = (float)lp_src_3Dpts[l_i].z;
+ CV_MAT_ELEM(*lp_pts, float, l_i, 3) = 1.0f;
}
cvSVD(lp_pts, lp_w, 0, lp_v);
}
int l_w = l_maxx - l_minx + 1;
int l_h = l_maxy - l_miny + 1;
- int l_nn = a_chain.size();
+ int l_nn = (int)a_chain.size();
CvPoint * lp_chain = new CvPoint[l_nn];
{
for (int l_c = 0; l_c < l_w; ++l_c)
{
- float l_dist = l_n[0] * lp_dst_3Dpts[l_ind].x + l_n[1] * lp_dst_3Dpts[l_ind].y + lp_dst_3Dpts[l_ind].z * l_n[2] + l_n[3];
+ float l_dist = (float)(l_n[0] * lp_dst_3Dpts[l_ind].x + l_n[1] * lp_dst_3Dpts[l_ind].y + lp_dst_3Dpts[l_ind].z * l_n[2] + l_n[3]);
++l_ind;
{
for (int l_p = 0; l_p < (int)a_masks.size(); ++l_p)
{
- int l_col = (l_c + l_minx) / (l_p + 1.0);
- int l_row = (l_r + l_miny) / (l_p + 1.0);
+ int l_col = cvRound((l_c + l_minx) / (l_p + 1.0));
+ int l_row = cvRound((l_r + l_miny) / (l_p + 1.0));
CV_IMAGE_ELEM(a_masks[l_p], unsigned char, l_row, l_col) = 0;
}
{
for (int l_p = 0; l_p < (int)a_masks.size(); ++l_p)
{
- int l_col = (l_c + l_minx) / (l_p + 1.0);
- int l_row = (l_r + l_miny) / (l_p + 1.0);
+ int l_col = cvRound((l_c + l_minx) / (l_p + 1.0));
+ int l_row = cvRound((l_r + l_miny) / (l_p + 1.0));
CV_IMAGE_ELEM(a_masks[l_p], unsigned char, l_row, l_col) = 255;
}
cv::convexHull(points, hull);
dst = cv::Mat::zeros(size, CV_8U);
- const int hull_count = hull.size();
+ const int hull_count = (int)hull.size();
const cv::Point* hull_pts = &hull[0];
cv::fillPoly(dst, &hull_pts, &hull_count, 1, cv::Scalar(255));
}
{
if( !trainImages[i].empty() )
{
- maskMatchesByTrainImgIdx( matches, i, mask );
+ maskMatchesByTrainImgIdx( matches, (int)i, mask );
drawMatches( queryImage, queryKeypoints, trainImages[i], trainKeypoints[i],
matches, drawImg, Scalar(255, 0, 0), Scalar(0, 255, 255), mask );
string filename = resultDir + "/res_" + trainImagesNames[i];
return -1;
}
- bool modeRes;
+ bool modeRes=false;
switch ( imageMode )
{
case 0:
// ++filename;
if(filename[0] == '#')
continue;
- int l = strlen(filename);
+ int l = (int)strlen(filename);
while(l > 0 && isspace(filename[l-1]))
--l;
filename[l] = '\0';
using namespace cv;
-int main(int argc, char* argv[])
+int main(int, char* [])
{
VideoCapture video(0);
Mat frame, curr, prev, curr64f, prev64f, hann;
setMouseCallback(windowName, mouseCallback, &renderer);\r
setOpenGlDrawCallback(windowName, openGlDrawCallback, &renderer);\r
\r
- while (true)\r
+ for(;;)\r
{\r
int key = waitKey(10);\r
\r
return;
trainedPoints.push_back( Point(x,y) );
- trainedPointsMarkers.push_back( classColors.size()-1 );
+ trainedPointsMarkers.push_back( (int)(classColors.size()-1) );
updateFlag = true;
}
else if( event == CV_EVENT_RBUTTONUP )
return -1;
}
- int transformationType = TransformationType::RIGID_BODY_MOTION;
+ int transformationType = RIGID_BODY_MOTION;
if( argc == 6 )
{
string ttype = argv[5];
if( ttype == "-rbm" )
{
- transformationType = TransformationType::RIGID_BODY_MOTION;
+ transformationType = RIGID_BODY_MOTION;
}
else if ( ttype == "-r")
{
- transformationType = TransformationType::ROTATION;
+ transformationType = ROTATION;
}
else if ( ttype == "-t")
{
- transformationType = TransformationType::TRANSLATION;
+ transformationType = TRANSLATION;
}
else
{
minGradMagnitudes[2] = 3;
minGradMagnitudes[3] = 1;
- const float minDepth = 0; //in meters
- const float maxDepth = 3; //in meters
- const float maxDepthDiff = 0.07; //in meters
+ const float minDepth = 0.f; //in meters
+ const float maxDepth = 3.f; //in meters
+ const float maxDepthDiff = 0.07f; //in meters
tm.start();
bool isFound = cv::RGBDOdometry( Rt, Mat(),
vector<Point> hull;
convexHull(Mat_<Point>(Mat(imgpt)), hull);
Mat selectedObjMask = Mat::zeros(frame.size(), CV_8U);
- fillConvexPoly(selectedObjMask, &hull[0], hull.size(), Scalar::all(255), 8, 0);
+ fillConvexPoly(selectedObjMask, &hull[0], (int)hull.size(), Scalar::all(255), 8, 0);
Rect roi = boundingRect(Mat(hull)) & Rect(Point(), frame.size());
if( runExtraSegmentation )
{
selectedObjMask = Scalar::all(GC_BGD);
- fillConvexPoly(selectedObjMask, &hull[0], hull.size(), Scalar::all(GC_PR_FGD), 8, 0);
+ fillConvexPoly(selectedObjMask, &hull[0], (int)hull.size(), Scalar::all(GC_PR_FGD), 8, 0);
Mat bgdModel, fgdModel;
grabCut(frame, selectedObjMask, roi, bgdModel, fgdModel,
3, GC_INIT_WITH_RECT + GC_INIT_WITH_MASK);
{
Mat_<float> K;
cameras[i].K().convertTo(K, CV_32F);
- K(0,0) *= seam_work_aspect; K(0,2) *= seam_work_aspect;
- K(1,1) *= seam_work_aspect; K(1,2) *= seam_work_aspect;
+ float swa = (float)seam_work_aspect;
+ K(0,0) *= swa; K(0,2) *= swa;
+ K(1,1) *= swa; K(1,2) *= swa;
corners[i] = warper->warp(images[i], K, cameras[i].R, INTER_LINEAR, BORDER_REFLECT, images_warped[i]);
sizes[i] = images_warped[i].size();
{
capture >> frame;
if (frame.empty())
- continue;
+ break;
cv::Mat gray;
cv::cvtColor(frame,gray,CV_RGB2GRAY);
findDataMatrix(gray, codes);
"ALPHA_ATOP_PREMUL", "ALPHA_XOR_PREMUL", "ALPHA_PLUS_PREMUL", "ALPHA_PREMUL"\r
};\r
\r
- while (true)\r
+ for(;;)\r
{\r
cout << op_names[alpha_op] << endl;\r
\r
\r
imshow("Interpolated frame", frames[currentFrame]);\r
\r
- while (true)\r
+ for(;;)\r
{\r
int key = toupper(waitKey(10) & 0xff);\r
\r
gpu::GpuMat d_frame1(frame1);\r
\r
gpu::GpuMat d_pts;\r
- Mat pts_mat(1, pts.size(), CV_32FC2, (void*)&pts[0]);\r
+ Mat pts_mat(1, (int)pts.size(), CV_32FC2, (void*)&pts[0]);\r
d_pts.upload(pts_mat);\r
\r
gpu::GpuMat d_nextPts;\r