Minimize usages of legacy C API inside the library

This commit is contained in:
Andrey Kamaev
2013-04-15 15:27:09 +04:00
parent 4223a59497
commit 8f32902ce6
45 changed files with 184 additions and 238 deletions

View File

@@ -10,7 +10,8 @@
#include <iostream>
#include <cstring>
#include "opencv2/opencv.hpp"
#include "opencv2/contrib.hpp"
#include "opencv2/highgui.hpp"
static void help(std::string errorMessage)
{
@@ -28,7 +29,7 @@ static void drawPlot(const cv::Mat curve, const std::string figureTitle, const i
cv::Mat displayedCurveImage = cv::Mat::ones(200, curve.size().height, CV_8U);
cv::Mat windowNormalizedCurve;
normalize(curve, windowNormalizedCurve, 0, 200, CV_MINMAX, CV_32F);
normalize(curve, windowNormalizedCurve, 0, 200, cv::NORM_MINMAX, CV_32F);
displayedCurveImage = cv::Scalar::all(255); // set a white background
int binW = cvRound((double)displayedCurveImage.cols/curve.size().height);
@@ -80,8 +81,7 @@ static void drawPlot(const cv::Mat curve, const std::string figureTitle, const i
normalize(hist, normalizedHist, 1, 0, cv::NORM_L1, CV_32F); // normalize histogram so that its sum equals 1
double min_val, max_val;
CvMat histArr(normalizedHist);
cvMinMaxLoc(&histArr, &min_val, &max_val);
minMaxLoc(normalizedHist, &min_val, &max_val);
//std::cout<<"Hist max,min = "<<max_val<<", "<<min_val<<std::endl;
// compute density probability

View File

@@ -14,7 +14,8 @@
#include <stdio.h>
#include <cstring>
#include "opencv2/opencv.hpp"
#include "opencv2/contrib.hpp"
#include "opencv2/highgui.hpp"
static void help(std::string errorMessage)
{
@@ -38,7 +39,7 @@ static void drawPlot(const cv::Mat curve, const std::string figureTitle, const i
cv::Mat displayedCurveImage = cv::Mat::ones(200, curve.size().height, CV_8U);
cv::Mat windowNormalizedCurve;
normalize(curve, windowNormalizedCurve, 0, 200, CV_MINMAX, CV_32F);
normalize(curve, windowNormalizedCurve, 0, 200, cv::NORM_MINMAX, CV_32F);
displayedCurveImage = cv::Scalar::all(255); // set a white background
int binW = cvRound((double)displayedCurveImage.cols/curve.size().height);

View File

@@ -5,7 +5,8 @@
* Author: Andrew B. Godbehere
*/
#include <opencv2/opencv.hpp>
#include "opencv2/video.hpp"
#include "opencv2/highgui.hpp"
#include <opencv2/core/utility.hpp>
#include <iostream>

View File

@@ -39,10 +39,10 @@
//
//M*/
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/legacy/legacy.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/legacy.hpp"
#include <limits>
#include <cstdio>
@@ -93,7 +93,7 @@ static void calcKeyPointProjections( const vector<KeyPoint>& src, const Mat_<dou
{
if( !src.empty() )
{
assert( !H.empty() && H.cols == 3 && H.rows == 3);
CV_Assert( !H.empty() && H.cols == 3 && H.rows == 3);
dst.resize(src.size());
vector<KeyPoint>::const_iterator srcIt = src.begin();
vector<KeyPoint>::iterator dstIt = dst.begin();
@@ -109,7 +109,7 @@ static void calcKeyPointProjections( const vector<KeyPoint>& src, const Mat_<dou
Mat_<double> Aff; linearizeHomographyAt(H, srcIt->pt, Aff);
Mat_<double> dstM; invert(Aff*invM*Aff.t(), dstM);
Mat_<double> eval; eigen( dstM, eval );
assert( eval(0,0) && eval(1,0) );
CV_Assert( eval(0,0) && eval(1,0) );
float dstSize = (float)pow(1./(eval(0,0)*eval(1,0)), 0.25);
// TODO: check angle projection
@@ -526,7 +526,7 @@ inline void writeKeypoints( FileStorage& fs, const vector<KeyPoint>& keypoints,
inline void readKeypoints( FileStorage& fs, vector<KeyPoint>& keypoints, int imgIdx )
{
assert( fs.isOpened() );
CV_Assert( fs.isOpened() );
stringstream imgName; imgName << "img" << imgIdx;
read( fs[imgName.str()], keypoints);
}

View File

@@ -1,5 +1,5 @@
#include "opencv2/legacy/legacy.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/legacy.hpp"
using namespace cv;
@@ -45,7 +45,7 @@ int main( int /*argc*/, char** /*argv*/ )
params.start_step = CvEM::START_AUTO_STEP;
params.term_crit.max_iter = 300;
params.term_crit.epsilon = 0.1;
params.term_crit.type = CV_TERMCRIT_ITER|CV_TERMCRIT_EPS;
params.term_crit.type = TermCriteria::COUNT|TermCriteria::EPS;
// cluster the data
em_model.train( samples, Mat(), params, &labels );
@@ -76,7 +76,7 @@ int main( int /*argc*/, char** /*argv*/ )
int response = cvRound(em_model.predict( sample ));
Scalar c = colors[response];
circle( img, Point(j, i), 1, c*0.75, CV_FILLED );
circle( img, Point(j, i), 1, c*0.75, FILLED );
}
}
@@ -84,7 +84,7 @@ int main( int /*argc*/, char** /*argv*/ )
for( i = 0; i < nsamples; i++ )
{
Point pt(cvRound(samples.at<float>(i, 0)), cvRound(samples.at<float>(i, 1)));
circle( img, pt, 1, colors[labels.at<int>(i)], CV_FILLED );
circle( img, pt, 1, colors[labels.at<int>(i)], FILLED );
}
imshow( "EM-clustering result", img );

View File

@@ -49,9 +49,11 @@
//
//M*/
#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/contrib.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/nonfree.hpp"
using namespace cv;
using namespace std;

View File

@@ -43,7 +43,6 @@
#include <opencv2/highgui.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/nonfree.hpp>
#include <opencv2/legacy.hpp>
using namespace cv;
@@ -95,9 +94,9 @@ int main( int argc, char** argv ) {
// MATCHER
// The standard Hamming distance can be used such as
// BruteForceMatcher<Hamming> matcher;
// BFMatcher matcher(NORM_HAMMING);
// or the proposed cascade of hamming distance using SSSE3
BruteForceMatcher<Hamming> matcher;
BFMatcher matcher(NORM_HAMMING);
// detect
double t = (double)getTickCount();

View File

@@ -11,10 +11,6 @@
*
*/
//#include <cv.h>
//#include <ml.h>
//#include <cvaux.h>
//#include <highgui.h>
#include <stdio.h>
#include <time.h>
#include <iostream>

View File

@@ -6,7 +6,9 @@
* PSPC-lab - University of Genoa
*/
#include "opencv2/opencv.hpp"
#include "opencv2/contrib.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
#include <cmath>

View File

@@ -1,5 +1,3 @@
#define CV_NO_BACKWARD_COMPATIBILITY
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdlib.h>

View File

@@ -9,7 +9,8 @@
#include <iostream>
#include <cstring>
#include "opencv2/opencv.hpp"
#include "opencv2/contrib.hpp"
#include "opencv2/highgui.hpp"
static void help(std::string errorMessage)
{

View File

@@ -9,7 +9,8 @@
#include <iostream>
#include <cstring>
#include "opencv2/opencv.hpp"
#include "opencv2/contrib.hpp"
#include "opencv2/highgui.hpp"
static void help(std::string errorMessage)
{