diff --git a/include/animation.h b/include/animation.h index 2136fb8aeba31c2fa37e0570302a7d98b027ff52..7116a9aea295be26b867fcfbec7720f695b3c364 100644 --- a/include/animation.h +++ b/include/animation.h @@ -23,12 +23,8 @@ they can be represented in QT. #include <QStringList> #include <QTime> -#ifndef STEREO_DISABLED -#include "opencv/cv.h" -#include "opencv/highgui.h" -#else + #include "opencv.hpp" -#endif #include "filter.h" #include "helper.h" @@ -260,13 +256,10 @@ private: // Free's the video data void freeVideo(); -#if CV_MAJOR_VERSION == 2 - // Capture structure from OpenCV 2 - CvCapture *mCapture; -#else + // Capture structure from OpenCV 3/4 cv::VideoCapture mVideoCapture; -#endif + #ifndef STEREO_DISABLED // Capture structure from pgrAviFile for Stereo Videos diff --git a/include/backgroundFilter.h b/include/backgroundFilter.h index c23ed2411176053c37ab3f34a56f8104dcd72194..77c30b9cf0b44ecb961c35e851ff8feb4fefc034 100644 --- a/include/backgroundFilter.h +++ b/include/backgroundFilter.h @@ -3,12 +3,8 @@ #include "filter.h" -#ifndef STEREO_DISABLED -#include "cvaux.h" -#include "opencv/cvaux.h" -#else + #include "opencv2/opencv.hpp" -#endif #include "opencv2/video/background_segm.hpp" @@ -22,12 +18,10 @@ class BackgroundFilter : public Filter { private: -#if CV_MAJOR_VERSION == 2 - CvBGStatModel* mBgModel; -#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 + cv::Ptr<cv::BackgroundSubtractorMOG2> mBgModel; //Ptr<BackgroundSubtractor> mBgModel; -#endif + bool mUpdate; // if 0, kein update des models, sonst schon pet::StereoContext** mStereoContext; // zeiger auf den zeiger in petrack mit stereocontext cv::Mat mBgPointCloud; diff --git a/include/blurFilter.h b/include/blurFilter.h index 2437d059ff1d92169d274b365cfdc7b08e26cd10..05688b8f7a600f0e8851a0aab095184eb120aa68 100644 --- a/include/blurFilter.h +++ b/include/blurFilter.h @@ -2,11 +2,7 @@ #define BLURFILTER_H #include "filter.h" -#if not CV_MAJOR_VERSION == 4 -#include "cv.h" -#else #include "opencv.hpp" -#endif class BlurFilter : public Filter { diff --git a/include/ellipse.h b/include/ellipse.h index 080146c977f3321af1c28c669b6f8df266cb34b9..240f51e2747d30970d91a76d52f989d1677008ca 100644 --- a/include/ellipse.h +++ b/include/ellipse.h @@ -1,11 +1,8 @@ #ifndef ELLIPSE_H #define ELLIPSE_H -#ifndef STEREO_DISABLED -#include <cxcore.h> -#else + #include "opencv.hpp" -#endif #include "vector.h" diff --git a/include/extrCalibration.h b/include/extrCalibration.h index e70a8754c89cc227d5253ce313bb5a399117750d..9e5db71e55227d3b00b6a33c9bad2427a22b75bd 100644 --- a/include/extrCalibration.h +++ b/include/extrCalibration.h @@ -14,13 +14,7 @@ #include "opencv2/opencv.hpp" -#include <opencv.hpp> -#ifndef STEREO_DISABLED -#include "cxcore.h" -#include "cvaux.h" -#endif -#include "opencv.hpp" class Petrack; class Control; diff --git a/include/filter.h b/include/filter.h index 6593cbcff5dd0ab5c35f342118cef6a9ea16b83d..3dabd9ab4556159c907d3cd082e217b49934e95b 100644 --- a/include/filter.h +++ b/include/filter.h @@ -1,12 +1,8 @@ #ifndef FILTER_H #define FILTER_H -#ifndef STEREO_DISABLED -#include "cv.h" -#include "opencv/cv.h" -#else + #include "opencv2/opencv.hpp" -#endif class Filter; diff --git a/include/petrack.h b/include/petrack.h index 81709907a0c281db8da592d8b83b9f36d4c726db..e9b74b3083c0fb8975455bd22d22ec93046bb8de 100644 --- a/include/petrack.h +++ b/include/petrack.h @@ -6,10 +6,6 @@ #include <QKeyEvent> #include <QMouseEvent> -#ifndef STEREO_DISABLED -#include "cvaux.h" -#include "cxcore.h" -#endif #include <opencv.hpp> //#include "opencv2/cxcore.h" diff --git a/include/player.h b/include/player.h index 8bcec2a8dd9ff1336fb305124e7fb8694708daed..764fb16891f58a96c17054a53065aece8a06cdc7 100644 --- a/include/player.h +++ b/include/player.h @@ -9,11 +9,8 @@ #else #include "aviFileWriter.h" #endif -#ifndef STEREO_DISABLED -#include "cv.h" -#else + #include "opencv.hpp" -#endif class QLabel; class QSlider; diff --git a/include/stereoContext.h b/include/stereoContext.h index 998409dafc1e6f381b23269b8b5781c3b7d25579..1b9909bfa610366159e20b8f8f5ff7a1e215b917 100644 --- a/include/stereoContext.h +++ b/include/stereoContext.h @@ -132,11 +132,8 @@ protected: CvStereoBMState *mBMState; #endif -#if CV_MAJOR_VERSION == 2 - cv::StereoSGBM *mSgbm; -#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 + cv::Ptr<cv::StereoSGBM> mSgbm; -#endif CvMat *mBMdisparity16; CvMat *mPointCloud; unsigned char mSurfaceValue; diff --git a/include/tracker.h b/include/tracker.h index b9623b92441f16627a80070c7d686161a1899dd3..534f3203179e04fec5f4af48d9e12e688b33e22f 100644 --- a/include/tracker.h +++ b/include/tracker.h @@ -7,9 +7,6 @@ //#include <opencv2/core/core.hpp> -#ifndef STEREO_DISABLED -#include "cxcore.h" -#endif #include "vector.h" diff --git a/src/animation.cpp b/src/animation.cpp index f1cdab0b69763066fc16227446c42fd89f369093..e32a4eb135c57815d77f2c735757713ccda2ac2b 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -33,12 +33,8 @@ they can be represented in QT. #include <cstdlib> #include <iomanip> -#ifndef STEREO_DISABLED -#include "cv.h" -#include "highgui.h" -#else + #include "opencv.hpp" -#endif #include "animation.h" diff --git a/src/autoCalib.cpp b/src/autoCalib.cpp index efebbbe954a293573e902656345de0407325140f..4d63dbe085caa3623f02c1c37e0e6968a12dfd58 100644 --- a/src/autoCalib.cpp +++ b/src/autoCalib.cpp @@ -94,11 +94,8 @@ void AutoCalib::autoCalib() QMessageBox::information(mMainWindow, Petrack::tr("Petrack"), Petrack::tr("At first you have to select files.")); return; } -#if CV_MAJOR_VERSION == 2 - CvSize board_size = {mBoardSizeX, mBoardSizeY}; //{6, 9}; //{6, 8}; // passt zu meinem Schachbrett, was ich ausgedruckt habe -#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 - Size board_size(mBoardSizeX, mBoardSizeY); -#endif + + Size board_size(mBoardSizeX, mBoardSizeY); //{6, 9}; //{6, 8}; // passt zu meinem Schachbrett, was ich ausgedruckt habe float square_size = mSquareSize; //5.25f; // 3.f; // da 3x3cm hat Schachbrett, was ich ausgedruckt habe float aspect_ratio = 1.f; int flags = 0; diff --git a/src/backgroundFilter.cpp b/src/backgroundFilter.cpp index 9643b9d4d26ecfe84eaac8173de4a36b6fac948a..b2a6615a66b73e436570c9b5eb931cff1ddf6c5b 100644 --- a/src/backgroundFilter.cpp +++ b/src/backgroundFilter.cpp @@ -29,14 +29,11 @@ BackgroundFilter::BackgroundFilter() { setOnCopy(false); // da img nur ausgelesen, aber bnicht veraendert wird kann auf eine kopie verzichtet werden (true ist default bei filter) -#if CV_MAJOR_VERSION == 2 - mBgModel = NULL; -#elif CV_MAJOR_VERSION == 3 + // mBgModel = createBackgroundSubtractorMOG2().dynamicCast<BackgroundSubtractor>(); // mBgModel = method == "knn" ? createBackgroundSubtractorKNN().dynamicCast<BackgroundSubstractor>() : // createBackgroundSubtractorMOG2().dynamicCast<BackgroundSubstractor>();//.dynamicCast<BackgroundSubtractorMOG2>(); -#endif // mBgPointCloud = NULL; // mForeground = NULL; mLastFile = ""; @@ -44,10 +41,7 @@ BackgroundFilter::BackgroundFilter() BackgroundFilter::~BackgroundFilter() { -#if CV_MAJOR_VERSION == 2 - cvReleaseBGStatModel(&mBgModel); - cvReleaseMat(&mBgPointCloud); -#endif + } @@ -70,16 +64,6 @@ bool BackgroundFilter::isForeground(int i, int j) // nutzen, wenn einzelne pixel // zuruecksetzen, wenn zB helligkeit veraendert wird oder schaerfe void BackgroundFilter::reset() { -#if CV_MAJOR_VERSION == 2 - cvReleaseBGStatModel(&mBgModel); - mBgModel = NULL; - - if (*stereoContext()) - { - cvReleaseMat(&mBgPointCloud); - mBgPointCloud = NULL; - } -#endif // funktioniert nicht wirklich // if (!mBgModel.empty()) if (!mForeground.empty()) mForeground = Scalar::all(0); @@ -439,24 +423,8 @@ waitKey(); { // GaussBGStatModel --------------------------------------------------------------------------------------------------------------------- -#if CV_MAJOR_VERSION == 2 - - // set parameters for Gaussian model. - static CvGaussBGStatModelParams* params = NULL; - - params = new CvGaussBGStatModelParams; - params->win_size=200; //default: 200 /* Learning rate; alpha = 1/CV_GBG_WINDOW_SIZE */ - params->n_gauss=5; //default: 5 /* = K = number of Gaussians in mixture */ - params->bg_threshold=0.7; //default: 0.7 /* threshold sum of weights for background test */ - params->std_threshold=2.5; //im netz: 3.5 //default: 2.5 /* lambda=2.5 is 99% */ - params->minArea=15; //1800; //default: 15 //hier wird meiner vermutung nach die groesse der minimalen abgetrennten bereiche eingestellt - params->weight_init=0.05; //default: 0.05 - params->variance_init=30; //=sigma_init //default: 30 - mBgModel = cvCreateGaussianBGModel(img, params); - mForeground = mBgModel->foreground; -#elif CV_MAJOR_VERSION == 3 if(!mBgModel.empty()) mBgModel->clear(); @@ -487,7 +455,6 @@ waitKey(); //mBgModel->getBackgroundImage(mBackground); //mBgModel->apply(img,mForeground); -#endif // FGDStatModel --------------------------------------------------------------------------------------------------------------------- // DOCUMENTATION: http://opencv.willowgarage.com/wiki/VideoSurveillance @@ -648,12 +615,7 @@ else // nicht stereo // GaussBGStatModel --------------------------------------------------------------------------------------------------------------------- -#if CV_MAJOR_VERSION == 2 - if (update()) - cvUpdateBGStatModel(img, mBgModel); // default -1 das Hintergrundmodell wird mit aktuellem Bild aktualisiert - else - cvUpdateBGStatModel(img, mBgModel, 0); -#elif CV_MAJOR_VERSION == 3 + mBgModel->apply(img, mForeground, update() ? -1 : 0); @@ -667,7 +629,6 @@ else // nicht stereo // mBgModel->apply(img,mForeground,0); // //mBgModel->apply(img,mForeground,0); // } -#endif #ifdef SHOW_TMP_IMG imshow("BackgroundFilter",img); @@ -722,11 +683,7 @@ waitKey(); { vector<Point> contour = contours.back(); - #if ((CV_MAJOR_VERSION < 2) || ((CV_MAJOR_VERSION == 2) && (CV_MINOR_VERSION < 1))) - contourArea = cvContourArea(contour, CV_WHOLE_SEQ); - #else contourArea = cv::contourArea(contour, true); - #endif if (contourArea > 0 && contourArea < 400) // kleine innere loecher schliessen { // pointArray = (CvPoint*)malloc(contour->total*sizeof(CvPoint)); diff --git a/src/blurFilter.cpp b/src/blurFilter.cpp index cd6c522063843d9a81b2cff1a3fee7bbc9f792ce..f748c590a62044b2b5fc4a375f0865f38a53fa62 100644 --- a/src/blurFilter.cpp +++ b/src/blurFilter.cpp @@ -1,9 +1,5 @@ #include "blurFilter.h" -#if CV_MAJOR_VERSION == 4 #include "opencv.hpp" -#else -#include "cv.h" -#endif #include "opencv2/opencv.hpp" using namespace::cv; diff --git a/src/calibStereoFilter.cpp b/src/calibStereoFilter.cpp index 3ac01e54f22a0bb8d5f43735f5bc5870a553db58..479620bcc2724ca1d5b5bb4b24db12928ada2bda 100644 --- a/src/calibStereoFilter.cpp +++ b/src/calibStereoFilter.cpp @@ -12,11 +12,8 @@ CalibStereoFilter::CalibStereoFilter() Mat CalibStereoFilter::act(Mat &img, Mat &res) { -#ifndef STEREO_DISABLED - return cvarrToMat(mStereoContext->getRectified(cameraUnset)); // kein Zugriff auf mAnimation->getCaptureStereo()->getCamera() -#else return Mat(); -#endif + } void CalibStereoFilter::setStereoContext(pet::StereoContext* stereoContext) { diff --git a/src/extrCalibration.cpp b/src/extrCalibration.cpp index 609fa233e8c5cef0566b05d30fc4873426ff3d5d..dfd909578d1e216b3896f7cd75b82b8b2b848436 100644 --- a/src/extrCalibration.cpp +++ b/src/extrCalibration.cpp @@ -393,10 +393,7 @@ void ExtrCalibration::calibExtrParams() Mat rvec(3,1,CV_64F),/*,0),*/ tvec(3,1,CV_64F);//,0); // Solve the PnP-Problem to calibrate the camera to its environment -#if ((CV_MAJOR_VERSION < 2) || ((CV_MAJOR_VERSION == 2) && (CV_MINOR_VERSION < 3))) - bool solvePNPsuccess = true; - solvePnP(op,ip,camMat,distMat,rvec,tvec,false); -#else + bool solvePNPsuccess = solvePnP(op,ip,camMat,distMat,rvec,tvec,false,SOLVEPNP_ITERATIVE); //bool solvePNPsuccess = solvePnP(op,ip,camMat,distMat,rvec,tvec,false,SOLVEPNP_P3P); // Requires exactly 4 points //bool solvePNPsuccess = solvePnP(op,ip,camMat,distMat,rvec,tvec,false,SOLVEPNP_EPNP); @@ -404,7 +401,7 @@ void ExtrCalibration::calibExtrParams() //bool solvePNPsuccess = solvePnP(op,ip,camMat,distMat,rvec,tvec,false,SOLVEPNP_UPNP); //bool solvePNPsuccess = true; //solvePnPRansac(op,ip,camMat,distMat,rvec,tvec); -#endif + // debout << "The solvePNP-Method " << (solvePNPsuccess ? "" : "doesn't ") << "worked. " << solvePNPsuccess << endl; diff --git a/src/recognition.cpp b/src/recognition.cpp index 883403dd49a3b4b3c6f073659435f429fd14f5c4..edb35e1be354c839e11a9f3acd32f28339756af2 100644 --- a/src/recognition.cpp +++ b/src/recognition.cpp @@ -283,11 +283,8 @@ void findMultiColorMarker(Mat &img, QList<TrackPoint> *crossList, Control *contr int i, j, x, y; bool atEdge; int threshold; -#if CV_MAJOR_VERSION == 2 - CvBox2D32f subBox; -#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 + RotatedRect subBox; -#endif int cx, cy, add; int nr; @@ -670,15 +667,10 @@ void findMultiColorMarker(Mat &img, QList<TrackPoint> *crossList, Control *contr if (subRatio < 1.8 && subMaxExpansion < markerSize*1.5 && subMaxExpansion > markerSize/2)//1.5 { // IN OPENCV2.1 liefert cvContourArea KEIN VORZEICHEN ZUM ERKENNEN DER DREHRICHTUNG!!!! es ist ein optionaler paramter hinzugefuegt worden!!!! - #if ((CV_MAJOR_VERSION < 2) || ((CV_MAJOR_VERSION == 2) && (CV_MINOR_VERSION < 1))) - //if ((CV_MAJOR_VERSION < 2) || ((CV_MAJOR_VERSION == 2) && (CV_MINOR_VERSION < 1))) -// subContourArea = cvContourArea(subContours,CV_WHOLE_SEQ); - subContourArea = cv::contourArea(subContour); - #else + //else subContourArea = cv::contourArea(subContour,true); // subContourArea = cvContourArea(subContours,CV_WHOLE_SEQ, true); - #endif cx = myRound(subBox.center.x); cy = myRound(subBox.center.y); @@ -1173,14 +1165,11 @@ void findContourMarker(Mat &img, QList<TrackPoint> *crossList, int markerBrightn vector<vector<Point> > contours; // CvSeq *contours; // CvSeq *firstContour; -#if CV_MAJOR_VERSION == 2 - CvPoint2D32f* PointArray2D32f; - CvBox2D32f box; -#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 + + // Mat PointArray2D32f; RotatedRect box; //CvBox2D box; -#endif // CvPoint center; int expansion; double contourArea; @@ -1356,35 +1345,7 @@ cvWaitKey(); ////// in weiss alle konturen - behindern jedoch weitere untersuchungen ////cvDrawContours(img,contours,CV_RGB(255,255,255),CV_RGB(255,255,255),0,1,8,cvPoint(0,0)); #endif -#if CV_MAJOR_VERSION == 2 -//debout << "PointArray malloc" << endl; - // Alloc memory for contour point set. - PointArray = (CvPoint*)malloc(count*sizeof(CvPoint)); - //cv::Mat PointMat = cv::Mat(1, count, CV_32SC2, contours); - //debout << cv::contourArea(PointMat) <<endl; - //debout << cv::isContourConvex(PointMat) <<endl; - //HoughCircles: Finds circles in a grayscale image using a Hough transform. - //debout << "seqToArray" << endl; - // Get contour point set. - cvCvtSeqToArray(contours, PointArray, CV_WHOLE_SEQ); - - - - PointArray2D32f = (CvPoint2D32f*)malloc(count*sizeof(CvPoint2D32f)); - - // Convert CvPoint set to CvBox2D32f set. - for(i=0; i<count; i++) - { - PointArray2D32f[i].x = (float)PointArray[i].x; - PointArray2D32f[i].y = (float)PointArray[i].y; - //debout << "[" << i << "]" << PointArray2D32f[i].x << ", " << PointArray2D32f[i].y << endl; - } - //debout << "FitEllipse" << endl; - // Fits ellipse to current contour. - //debout << "count: " << count << endl; - cvFitEllipse(PointArray2D32f, count, &box); -#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 // PointArray2D32f.create(count,2, CV_32F); // //Mat(cvarrToMat(contours)).convertTo(PointArray2D32f.at(i), CV_32F); @@ -1405,7 +1366,7 @@ cvWaitKey(); box = fitEllipse(pointsf); // box = fitEllipse(PointArray2D32f);//, count, &box); -#endif + // neuer: //// Fits ellipse to current contour. //CvBox2D box = cvFitEllipse2(PointArray2D32f); @@ -1428,14 +1389,10 @@ cvWaitKey(); //debout << "contourArea" << endl; //cvContourArea(contours,CV_WHOLE_SEQ) koennte mit MyEllipse.are() verglichen werden und bei grossen abweichungen verworfenwerden!!! // IN OPENCV2.1 liefert cvContourArea KEIN VORZEICHEN ZUM ERKENNEN DER DREHRICHTUNG!!!! es ist ein optionaler paramter hinzugefuegt worden!!!! -#if ((CV_MAJOR_VERSION < 2) || ((CV_MAJOR_VERSION == 2) && (CV_MINOR_VERSION < 1))) - //if ((CV_MAJOR_VERSION < 2) || ((CV_MAJOR_VERSION == 2) && (CV_MINOR_VERSION < 1))) - contourArea = cv:contourArea(contours,true); -#else + //else contourArea = cv::contourArea(contour,true); // contourArea = cvContourArea(contours,CV_WHOLE_SEQ, true); -#endif //contourArea koennte mit MyEllipse.area() verglichen werden und bei grossen abweichungen verworfenwerden!!! //debout << contourArea << " " << box.center.x << " " << box.center.y << " " << box.size.width <<" " << box.size.height <<endl; @@ -1505,11 +1462,8 @@ imShow("img2", tmpAusgabe2); } //debout << "FreePointArray" << endl; // free(PointArray); -#if CV_MAJOR_VERSION == 2 - free(PointArray2D32f); -#elif CV_MAJOR_VERSION == 3 + // PointArray2D32f.release(); -#endif } //debout << "Free PointArray" << endl; diff --git a/src/tracker.cpp b/src/tracker.cpp index 315a9b04923eae626b65f0d5f2e1e36fc27de5dd..62cd998fab9a93e1410b9121993e8939227c9bd2 100644 --- a/src/tracker.cpp +++ b/src/tracker.cpp @@ -1,9 +1,5 @@ -#if not CV_MAJOR_VERSION == 4 -#include <cv.h> -#else #include "opencv.hpp" #include "opencv2/video/legacy/constants_c.h" -#endif #include <time.h> #include <iomanip> diff --git a/src/vector.cpp b/src/vector.cpp index d483daa14c1f1cdb31b26bf38cfac4c83e3fc38c..c752f55172b75ec739a6e2326df89e17ebb060cf 100644 --- a/src/vector.cpp +++ b/src/vector.cpp @@ -1,8 +1,4 @@ -#ifndef STEREO_DISABLED -#include "cxcore.h" -#else #include "opencv.hpp" -#endif #include <QPointF> #include <QPoint>