1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Fixed number of warnings. Fixed mingw64 build.

This commit is contained in:
Andrey Kamaev
2012-06-12 14:46:12 +00:00
parent 02e3afae3a
commit c5aba337e9
110 changed files with 2232 additions and 2367 deletions
+10 -13
View File
@@ -32,23 +32,20 @@ static void help()
// define whether to use approximate nearest-neighbor search
#define USE_FLANN
IplImage* image = 0;
#ifdef USE_FLANN
static void
flannFindPairs( const CvSeq*, const CvSeq* objectDescriptors,
const CvSeq*, const CvSeq* imageDescriptors, vector<int>& ptpairs )
{
int length = (int)(objectDescriptors->elem_size/sizeof(float));
int length = (int)(objectDescriptors->elem_size/sizeof(float));
cv::Mat m_object(objectDescriptors->total, length, CV_32F);
cv::Mat m_image(imageDescriptors->total, length, CV_32F);
cv::Mat m_image(imageDescriptors->total, length, CV_32F);
// copy descriptors
// copy descriptors
CvSeqReader obj_reader;
float* obj_ptr = m_object.ptr<float>(0);
float* obj_ptr = m_object.ptr<float>(0);
cvStartReadSeq( objectDescriptors, &obj_reader );
for(int i = 0; i < objectDescriptors->total; i++ )
{
@@ -58,7 +55,7 @@ flannFindPairs( const CvSeq*, const CvSeq* objectDescriptors,
obj_ptr += length;
}
CvSeqReader img_reader;
float* img_ptr = m_image.ptr<float>(0);
float* img_ptr = m_image.ptr<float>(0);
cvStartReadSeq( imageDescriptors, &img_reader );
for(int i = 0; i < imageDescriptors->total; i++ )
{
@@ -77,10 +74,10 @@ flannFindPairs( const CvSeq*, const CvSeq* objectDescriptors,
int* indices_ptr = m_indices.ptr<int>(0);
float* dists_ptr = m_dists.ptr<float>(0);
for (int i=0;i<m_indices.rows;++i) {
if (dists_ptr[2*i]<0.6*dists_ptr[2*i+1]) {
ptpairs.push_back(i);
ptpairs.push_back(indices_ptr[2*i]);
}
if (dists_ptr[2*i]<0.6*dists_ptr[2*i+1]) {
ptpairs.push_back(i);
ptpairs.push_back(indices_ptr[2*i]);
}
}
}
#else
@@ -234,7 +231,7 @@ int main(int argc, char** argv)
cvNamedWindow("Object", 1);
cvNamedWindow("Object Correspond", 1);
static CvScalar colors[] =
static CvScalar colors[] =
{
{{0,0,255}},
{{0,128,255}},
+9 -14
View File
@@ -179,7 +179,7 @@ static const char* var_desc[] =
};
static void print_variable_importance( CvDTree* dtree, const char** var_desc )
static void print_variable_importance( CvDTree* dtree )
{
const CvMat* var_importance = dtree->get_var_importance();
int i;
@@ -201,21 +201,16 @@ static void print_variable_importance( CvDTree* dtree, const char** var_desc )
for( i = 0; i < var_importance->cols*var_importance->rows; i++ )
{
double val = var_importance->data.db[i];
if( var_desc )
{
char buf[100];
int len = (int)(strchr( var_desc[i], '(' ) - var_desc[i] - 1);
strncpy( buf, var_desc[i], len );
buf[len] = '\0';
printf( "%s", buf );
}
else
printf( "var #%d", i );
char buf[100];
int len = (int)(strchr( var_desc[i], '(' ) - var_desc[i] - 1);
strncpy( buf, var_desc[i], len );
buf[len] = '\0';
printf( "%s", buf );
printf( ": %g%%\n", val*100. );
}
}
static void interactive_classification( CvDTree* dtree, const char** var_desc )
static void interactive_classification( CvDTree* dtree )
{
char input[1000];
const CvDTreeNode* root;
@@ -319,8 +314,8 @@ int main( int argc, char** argv )
cvReleaseMat( &missing );
cvReleaseMat( &responses );
print_variable_importance( dtree, var_desc );
interactive_classification( dtree, var_desc );
print_variable_importance( dtree );
interactive_classification( dtree );
delete dtree;
return 0;
@@ -200,17 +200,18 @@ static void loadNewFrame(const std::string filenamePrototype, const int currentF
// TODO : take care of this step !!! maybe disable of do this in a nicer way ... each successive image should get the same transformation... but it depends on the initial image format
double maxInput, minInput;
minMaxLoc(inputImage, &minInput, &maxInput);
std::cout<<"ORIGINAL IMAGE pixels values range (max,min) : "<<maxInput<<", "<<minInput<<std::endl
;if (firstTimeread)
std::cout<<"ORIGINAL IMAGE pixels values range (max,min) : "<<maxInput<<", "<<minInput<<std::endl;
if (firstTimeread)
{
/* the first time, get the pixel values range and rougthly update scaling value
in order to center values around 128 and getting a range close to [0-255],
=> actually using a little less in order to let some more flexibility in range evolves...
*/
double maxInput, minInput;
minMaxLoc(inputImage, &minInput, &maxInput);
std::cout<<"FIRST IMAGE pixels values range (max,min) : "<<maxInput<<", "<<minInput<<std::endl;
globalRescalefactor=(float)(50.0/(maxInput-minInput)); // less than 255 for flexibility... experimental value to be carefull about
double maxInput1, minInput1;
minMaxLoc(inputImage, &minInput1, &maxInput1);
std::cout<<"FIRST IMAGE pixels values range (max,min) : "<<maxInput1<<", "<<minInput1<<std::endl;
globalRescalefactor=(float)(50.0/(maxInput1-minInput1)); // less than 255 for flexibility... experimental value to be carefull about
double channelOffset = -1.5*minInput;
globalOffset= cv::Scalar(channelOffset, channelOffset, channelOffset, channelOffset);
}
+3 -3
View File
@@ -803,9 +803,9 @@ void VocData::calcClassifierPrecRecall(const string& input_file, vector<float>&
std::sort(order.begin(),order.end(),orderingSorter());
/* 2. save ranking results to text file */
string input_file_std = checkFilenamePathsep(input_file);
size_t fnamestart = input_file_std.rfind("/");
string scoregt_file_str = input_file_std.substr(0,fnamestart+1) + "scoregt_" + class_name + ".txt";
string input_file_std1 = checkFilenamePathsep(input_file);
size_t fnamestart = input_file_std1.rfind("/");
string scoregt_file_str = input_file_std1.substr(0,fnamestart+1) + "scoregt_" + class_name + ".txt";
std::ofstream scoregt_file(scoregt_file_str.c_str());
if (scoregt_file.is_open())
{
+4 -4
View File
@@ -230,13 +230,13 @@ static void findConstrainedCorrespondences(const Mat& _F,
{
if( i1 == i )
continue;
Point2f p1 = keypoints1[i1].pt;
Point2f pt1 = keypoints1[i1].pt;
const float* d11 = descriptors1.ptr<float>(i1);
double dist = 0;
e = p2.x*(F[0]*p1.x + F[1]*p1.y + F[2]) +
p2.y*(F[3]*p1.x + F[4]*p1.y + F[5]) +
F[6]*p1.x + F[7]*p1.y + F[8];
e = p2.x*(F[0]*pt1.x + F[1]*pt1.y + F[2]) +
p2.y*(F[3]*pt1.x + F[4]*pt1.y + F[5]) +
F[6]*pt1.x + F[7]*pt1.y + F[8];
if( fabs(e) > eps )
continue;
+3 -3
View File
@@ -173,9 +173,9 @@ static void saveCameraParams( const string& filename,
{
FileStorage fs( filename, FileStorage::WRITE );
time_t t;
time( &t );
struct tm *t2 = localtime( &t );
time_t tt;
time( &tt );
struct tm *t2 = localtime( &tt );
char buf[1024];
strftime( buf, sizeof(buf)-1, "%c", t2 );
+22 -23
View File
@@ -48,46 +48,45 @@ static void onMouse( int event, int x, int y, int, void* )
static void help()
{
cout << "\nThis is a demo that shows mean-shift based tracking\n"
"You select a color objects such as your face and it tracks it.\n"
"This reads from video camera (0 by default, or the camera number the user enters\n"
"Usage: \n"
" ./camshiftdemo [camera number]\n";
"You select a color objects such as your face and it tracks it.\n"
"This reads from video camera (0 by default, or the camera number the user enters\n"
"Usage: \n"
" ./camshiftdemo [camera number]\n";
cout << "\n\nHot keys: \n"
"\tESC - quit the program\n"
"\tc - stop the tracking\n"
"\tb - switch to/from backprojection view\n"
"\th - show/hide object histogram\n"
"\tp - pause video\n"
"\tESC - quit the program\n"
"\tc - stop the tracking\n"
"\tb - switch to/from backprojection view\n"
"\th - show/hide object histogram\n"
"\tp - pause video\n"
"To initialize tracking, select the object with mouse\n";
}
const char* keys =
const char* keys =
{
"{1| | 0 | camera number}"
"{1| | 0 | camera number}"
};
int main( int argc, const char** argv )
{
help();
help();
VideoCapture cap;
Rect trackWindow;
RotatedRect trackBox;
int hsize = 16;
float hranges[] = {0,180};
const float* phranges = hranges;
CommandLineParser parser(argc, argv, keys);
int camNum = parser.get<int>("1");
cap.open(camNum);
CommandLineParser parser(argc, argv, keys);
int camNum = parser.get<int>("1");
cap.open(camNum);
if( !cap.isOpened() )
{
help();
help();
cout << "***Could not initialize capturing...***\n";
cout << "Current parameter's value: \n";
parser.printParams();
parser.printParams();
return -1;
}
@@ -100,7 +99,7 @@ int main( int argc, const char** argv )
Mat frame, hsv, hue, mask, hist, histimg = Mat::zeros(200, 320, CV_8UC3), backproj;
bool paused = false;
for(;;)
{
if( !paused )
@@ -111,7 +110,7 @@ int main( int argc, const char** argv )
}
frame.copyTo(image);
if( !paused )
{
cvtColor(image, hsv, CV_BGR2HSV);
@@ -131,7 +130,7 @@ int main( int argc, const char** argv )
Mat roi(hue, selection), maskroi(mask, selection);
calcHist(&roi, 1, 0, maskroi, hist, 1, &hsize, &phranges);
normalize(hist, hist, 0, 255, CV_MINMAX);
trackWindow = selection;
trackObject = 1;
@@ -141,7 +140,7 @@ int main( int argc, const char** argv )
for( int i = 0; i < hsize; i++ )
buf.at<Vec3b>(i) = Vec3b(saturate_cast<uchar>(i*180./hsize), 255, 255);
cvtColor(buf, buf, CV_HSV2BGR);
for( int i = 0; i < hsize; i++ )
{
int val = saturate_cast<int>(hist.at<float>(i)*histimg.rows/255);
+3 -3
View File
@@ -28,9 +28,9 @@ static void help()
int main(int,char**)
{
help();
Mat i = Mat::eye(4, 4, CV_64F);
i.at<double>(1,1) = CV_PI;
cout << "i = " << i << ";" << endl;
Mat I = Mat::eye(4, 4, CV_64F);
I.at<double>(1,1) = CV_PI;
cout << "I = " << I << ";" << endl;
Mat r = Mat(10, 3, CV_8UC3);
randu(r, Scalar::all(0), Scalar::all(255));
@@ -223,8 +223,8 @@ void BaseQualityEvaluator::readAllDatasetsRunParams()
isWriteParams = false;
FileNode topfn = fs.getFirstTopLevelNode();
FileNode fn = topfn[DEFAULT_PARAMS];
readDefaultRunParams(fn);
FileNode pfn = topfn[DEFAULT_PARAMS];
readDefaultRunParams(pfn);
for( int i = 0; i < DATASETS_COUNT; i++ )
{
@@ -280,7 +280,7 @@ bool BaseQualityEvaluator::readDataset( const string& datasetName, vector<Mat>&
if( !fs.isOpened() )
{
cout << "filename " << dirname + filename.str() << endl;
FileStorage fs( dirname + filename.str(), FileStorage::READ );
FileStorage fs2( dirname + filename.str(), FileStorage::READ );
return false;
}
fs.getFirstTopLevelNode() >> Hs[i];
+2 -2
View File
@@ -32,8 +32,8 @@ bool selectObject = false;
int trackObject = 0;
int live = 1;
static void drawRectangle(Mat* image, Rect win) {
rectangle(*image, Point(win.x, win.y), Point(win.x + win.width, win.y
static void drawRectangle(Mat* img, Rect win) {
rectangle(*img, Point(win.x, win.y), Point(win.x + win.width, win.y
+ win.height), Scalar(0, 255, 0), 2, CV_AA);
}
+4 -4
View File
@@ -23,14 +23,14 @@ static void help()
"To add/remove a feature point click it\n" << endl;
}
Point2f pt;
Point2f point;
bool addRemovePt = false;
static void onMouse( int event, int x, int y, int /*flags*/, void* /*param*/ )
{
if( event == CV_EVENT_LBUTTONDOWN )
{
pt = Point2f((float)x,(float)y);
point = Point2f((float)x,(float)y);
addRemovePt = true;
}
}
@@ -97,7 +97,7 @@ int main( int argc, char** argv )
{
if( addRemovePt )
{
if( norm(pt - points[1][i]) <= 5 )
if( norm(point - points[1][i]) <= 5 )
{
addRemovePt = false;
continue;
@@ -116,7 +116,7 @@ int main( int argc, char** argv )
if( addRemovePt && points[1].size() < (size_t)MAX_COUNT )
{
vector<Point2f> tmp;
tmp.push_back(pt);
tmp.push_back(point);
cornerSubPix( gray, tmp, winSize, cvSize(-1,-1), termcrit);
points[1].push_back(tmp[0]);
addRemovePt = false;
+3 -3
View File
@@ -146,11 +146,11 @@ static void parseCommandLine( int argc, char* argv[], bool& isColorizeDisp, bool
int val = atoi(mask.c_str());
int l = 100000, r = 10000, sum = 0;
for( int i = 0; i < 5; i++ )
for( int j = 0; j < 5; j++ )
{
retrievedImageFlags[i] = ((val % l) / r ) == 0 ? false : true;
retrievedImageFlags[j] = ((val % l) / r ) == 0 ? false : true;
l /= 10; r /= 10;
if( retrievedImageFlags[i] ) sum++;
if( retrievedImageFlags[j] ) sum++;
}
if( sum == 0 )
+6 -6
View File
@@ -126,7 +126,7 @@ double work_megapix = 0.6;
double seam_megapix = 0.1;
double compose_megapix = -1;
float conf_thresh = 1.f;
string features = "surf";
string features_type = "surf";
string ba_cost_func = "ray";
string ba_refine_mask = "xxxxx";
bool do_wave_correct = true;
@@ -194,8 +194,8 @@ static int parseCmdArgs(int argc, char** argv)
}
else if (string(argv[i]) == "--features")
{
features = argv[i + 1];
if (features == "orb")
features_type = argv[i + 1];
if (features_type == "orb")
match_conf = 0.3f;
i++;
}
@@ -345,7 +345,7 @@ int main(int argc, char* argv[])
int64 t = getTickCount();
Ptr<FeaturesFinder> finder;
if (features == "surf")
if (features_type == "surf")
{
#ifdef HAVE_OPENCV_GPU
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
@@ -354,13 +354,13 @@ int main(int argc, char* argv[])
#endif
finder = new SurfFeaturesFinder();
}
else if (features == "orb")
else if (features_type == "orb")
{
finder = new OrbFeaturesFinder();
}
else
{
cout << "Unknown 2D features type: '" << features << "'.\n";
cout << "Unknown 2D features type: '" << features_type << "'.\n";
return -1;
}
+6 -6
View File
@@ -179,7 +179,7 @@ public:
virtual ~IMotionEstimatorBuilder() {}
virtual Ptr<ImageMotionEstimatorBase> build() = 0;
protected:
IMotionEstimatorBuilder(CommandLineParser &cmd) : cmd(cmd) {}
IMotionEstimatorBuilder(CommandLineParser &command) : cmd(command) {}
CommandLineParser cmd;
};
@@ -187,8 +187,8 @@ protected:
class MotionEstimatorRansacL2Builder : public IMotionEstimatorBuilder
{
public:
MotionEstimatorRansacL2Builder(CommandLineParser &cmd, bool gpu, const string &prefix = "")
: IMotionEstimatorBuilder(cmd), gpu(gpu), prefix(prefix) {}
MotionEstimatorRansacL2Builder(CommandLineParser &command, bool use_gpu, const string &_prefix = "")
: IMotionEstimatorBuilder(command), gpu(use_gpu), prefix(_prefix) {}
virtual Ptr<ImageMotionEstimatorBase> build()
{
@@ -198,7 +198,7 @@ public:
if (arg(prefix + "subset") != "auto")
ransac.size = argi(prefix + "subset");
if (arg(prefix + "thresh") != "auto")
ransac.thresh = argi(prefix + "thresh");
ransac.thresh = argf(prefix + "thresh");
ransac.eps = argf(prefix + "outlier-ratio");
est->setRansacParams(ransac);
@@ -238,8 +238,8 @@ private:
class MotionEstimatorL1Builder : public IMotionEstimatorBuilder
{
public:
MotionEstimatorL1Builder(CommandLineParser &cmd, bool gpu, const string &prefix = "")
: IMotionEstimatorBuilder(cmd), gpu(gpu), prefix(prefix) {}
MotionEstimatorL1Builder(CommandLineParser &command, bool use_gpu, const string &_prefix = "")
: IMotionEstimatorBuilder(command), gpu(use_gpu), prefix(_prefix) {}
virtual Ptr<ImageMotionEstimatorBase> build()
{
+4 -4
View File
@@ -118,13 +118,13 @@ int main( int argc, char** argv )
for( i = 0; i < markers.rows; i++ )
for( j = 0; j < markers.cols; j++ )
{
int idx = markers.at<int>(i,j);
if( idx == -1 )
int index = markers.at<int>(i,j);
if( index == -1 )
wshed.at<Vec3b>(i,j) = Vec3b(255,255,255);
else if( idx <= 0 || idx > compCount )
else if( index <= 0 || index > compCount )
wshed.at<Vec3b>(i,j) = Vec3b(0,0,0);
else
wshed.at<Vec3b>(i,j) = colorTab[idx - 1];
wshed.at<Vec3b>(i,j) = colorTab[index - 1];
}
wshed = wshed*0.5 + imgGray*0.5;
+9 -9
View File
@@ -111,22 +111,22 @@ int main(int argc, const char* argv[])
GpuMat d_fu, d_fv;
d_flow(d_frame0, d_frame1, d_fu, d_fv);
Mat flowFieldForward;
getFlowField(Mat(d_fu), Mat(d_fv), flowFieldForward);
cout << "\tBackward..." << endl;
GpuMat d_bu, d_bv;
d_flow(d_frame1, d_frame0, d_bu, d_bv);
Mat flowFieldBackward;
getFlowField(Mat(d_bu), Mat(d_bv), flowFieldBackward);
#ifdef HAVE_OPENGL
cout << "Create Optical Flow Needle Map..." << endl;
GpuMat d_vertex, d_colors;
createOpticalFlowNeedleMap(d_fu, d_fv, d_vertex, d_colors);
@@ -153,7 +153,7 @@ int main(int argc, const char* argv[])
d_bt.upload(channels[0]);
d_gt.upload(channels[1]);
d_rt.upload(channels[2]);
// temporary buffer
GpuMat d_buf;
@@ -179,8 +179,8 @@ int main(int argc, const char* argv[])
// interpolate red channel
interpolateFrames(d_r, d_rt, d_fu, d_fv, d_bu, d_bv, timePos, d_rNew, d_buf);
GpuMat channels[] = {d_bNew, d_gNew, d_rNew};
merge(channels, 3, d_newFrame);
GpuMat channels3[] = {d_bNew, d_gNew, d_rNew};
merge(channels3, 3, d_newFrame);
frames.push_back(Mat(d_newFrame));
@@ -218,7 +218,7 @@ int main(int argc, const char* argv[])
return 0;
case 'A':
if (currentFrame > 0)
if (currentFrame > 0)
--currentFrame;
imshow("Interpolated frame", frames[currentFrame]);
@@ -269,7 +269,7 @@ void getFlowField(const Mat& u, const Mat& v, Mat& flowField)
{
float d = max(fabsf(ptr_u[j]), fabsf(ptr_v[j]));
if (d > maxDisplacement)
if (d > maxDisplacement)
maxDisplacement = d;
}
}
+9 -9
View File
@@ -14,11 +14,11 @@
class Runnable
{
public:
explicit Runnable(const std::string& name): name_(name) {}
explicit Runnable(const std::string& nameStr): name_(nameStr) {}
virtual ~Runnable() {}
const std::string& name() const { return name_; }
const std::string& name() const { return name_; }
virtual void run() = 0;
private:
@@ -59,7 +59,7 @@ public:
bool stop() const { return cur_iter_idx_ >= num_iters_; }
void cpuOn() { cpu_started_ = cv::getTickCount(); }
void cpuOff()
void cpuOff()
{
int64 delta = cv::getTickCount() - cpu_started_;
cpu_times_.push_back(delta);
@@ -73,7 +73,7 @@ public:
}
void gpuOn() { gpu_started_ = cv::getTickCount(); }
void gpuOff()
void gpuOff()
{
int64 delta = cv::getTickCount() - gpu_started_;
gpu_times_.push_back(delta);
@@ -98,10 +98,10 @@ private:
{
cpu_times_.reserve(num_iters_);
gpu_times_.reserve(num_iters_);
}
}
void finishCurrentSubtest();
void resetCurrentSubtest()
void resetCurrentSubtest()
{
cpu_elapsed_ = 0;
gpu_elapsed_ = 0;
@@ -180,7 +180,7 @@ private:
} TestSystem::instance().gpuComplete()
// Generates a matrix
void gen(cv::Mat& mat, int rows, int cols, int type, cv::Scalar low,
void gen(cv::Mat& mat, int rows, int cols, int type, cv::Scalar low,
cv::Scalar high);
// Returns abs path taking into account test system working dir
+1 -1
View File
@@ -74,7 +74,7 @@ struct DrawData
GlArrays arr;
};
void drawCallback(void* userdata)
static void drawCallback(void* userdata)
{
DrawData* data = static_cast<DrawData*>(userdata);
+2 -2
View File
@@ -136,8 +136,8 @@ Params Params::read(int argc, char** argv)
}
App::App(const Params& p)
: p(p), running(false)
App::App(const Params& params)
: p(params), running(false)
{
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());