diff --git a/include/animation.h b/include/animation.h index 9da0500b4922a37d1b0a829763bfed8ceaae2bfb..2136fb8aeba31c2fa37e0570302a7d98b027ff52 100644 --- a/include/animation.h +++ b/include/animation.h @@ -23,8 +23,12 @@ 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" @@ -123,20 +127,24 @@ public: bool isImageSequence(); bool isCameraLiveStream(); +#ifndef STEREO_DISABLED enum Camera getCamera(); void setCamera(enum Camera); +#endif int getFirstFrameSec(); int getFirstFrameMicroSec(); QString getFileBase(); QFileInfo getFileInfo(); +#ifndef STEREO_DISABLED // used to get access of both frames only with calibStereoFilter #ifdef STEREO PgrAviFile *getCaptureStereo(); #else StereoAviFile *getCaptureStereo(); #endif +#endif private: @@ -149,9 +157,11 @@ private: // Indicate if the current animation is a video or a photo or a stereo video bool mVideo, mImgSeq, mStereo, mCameraLiveStream; +#ifndef STEREO_DISABLED // indicates which camera is used for stereo video enum Camera mCamera; - + #endif + // Pointer that will be used by the animation and that will be returned in the public functions // IplImage *mImage; cv::Mat mImage; @@ -224,7 +234,9 @@ private: // Opens an animation from a sequence of stereo video files // fileNumber indicates the number of the successive files splited while writing // nur bei einer ganz neuen sequenz ist stereoImgBuffer != 0 +#ifndef STEREO_DISABLED bool openAnimationStereoVideo(int fileNumber, IplImage* stereoImgLeft, IplImage* stereoImgRight); +#endif bool openAnimationStereoVideo(int fileNumber, cv::Mat &stereoImgLeft, cv::Mat &stereoImgRight); // like above for the first time with new filename @@ -251,11 +263,12 @@ private: #if CV_MAJOR_VERSION == 2 // Capture structure from OpenCV 2 CvCapture *mCapture; -#elif CV_MAJOR_VERSION == 3 - // Capture structure from OpenCV 3 +#else + // Capture structure from OpenCV 3/4 cv::VideoCapture mVideoCapture; #endif +#ifndef STEREO_DISABLED // Capture structure from pgrAviFile for Stereo Videos #ifdef STEREO PgrAviFile *mCaptureStereo; @@ -271,7 +284,7 @@ private: // A list with all the filenames of the stereo video series QStringList mStereoVideoFilesList; - + #endif }; #endif diff --git a/include/backgroundFilter.h b/include/backgroundFilter.h index 7f517e4dc3b83c5825bbed8c24559407fc82f3d6..c23ed2411176053c37ab3f34a56f8104dcd72194 100644 --- a/include/backgroundFilter.h +++ b/include/backgroundFilter.h @@ -3,8 +3,12 @@ #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" @@ -20,7 +24,7 @@ class BackgroundFilter : public Filter private: #if CV_MAJOR_VERSION == 2 CvBGStatModel* mBgModel; -#elif CV_MAJOR_VERSION == 3 +#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 cv::Ptr<cv::BackgroundSubtractorMOG2> mBgModel; //Ptr<BackgroundSubtractor> mBgModel; #endif diff --git a/include/blurFilter.h b/include/blurFilter.h index 1322a59f349b66b499b375ed3e7a30d1fa993cf7..2437d059ff1d92169d274b365cfdc7b08e26cd10 100644 --- a/include/blurFilter.h +++ b/include/blurFilter.h @@ -2,7 +2,11 @@ #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/borderFilter.h b/include/borderFilter.h index 3143a28ccefd518e3a4cac2407743db8703e107a..8e658fd25de4252a322e3bb5fb3c933058df71f3 100644 --- a/include/borderFilter.h +++ b/include/borderFilter.h @@ -3,7 +3,6 @@ #include "filter.h" -using namespace::cv; class BorderFilter : public Filter { diff --git a/include/brightContrastFilter.h b/include/brightContrastFilter.h index 9ea525b2c37cc2fa7a1cb8daba8cbdb4327b3ad9..1ade1af2ead68eb42f94f108887cb23d79c4f356 100644 --- a/include/brightContrastFilter.h +++ b/include/brightContrastFilter.h @@ -4,7 +4,6 @@ #include "filter.h" #include "helper.h" -using namespace::cv; class BrightContrastFilter : public Filter { diff --git a/include/brightFilter.h b/include/brightFilter.h index 9610443b5a8b98c0fe77b14b2a93ae768710e573..a930b1ffc2f748b2187a3aca3d0ec1c1ac5269d2 100644 --- a/include/brightFilter.h +++ b/include/brightFilter.h @@ -10,8 +10,9 @@ private: public: BrightFilter(); - +#ifndef STEREO_DISABLED IplImage* act(IplImage *img, IplImage *res); +#endif // bool changed(); diff --git a/include/calibFilter.h b/include/calibFilter.h index 54f49e3809557b0c1b238d9e01b0effaafcaee10..2aacde73e6413527adfdbb30afb84a0f7ae120d1 100644 --- a/include/calibFilter.h +++ b/include/calibFilter.h @@ -3,7 +3,6 @@ #include "filter.h" -using namespace::cv; class CalibFilter : public Filter { diff --git a/include/codeMarkerItem.h b/include/codeMarkerItem.h index 6f02e6b3e0e6243c1d97a2918bf7f8085ff98c48..0b3de32a522e1e2076b369d025cf3e3b6b3b9baa 100644 --- a/include/codeMarkerItem.h +++ b/include/codeMarkerItem.h @@ -16,7 +16,7 @@ private: // QImage *mImage; vector<int> mIds; - vector<vector<Point2f> > mCorners, mRejected; + vector<vector<cv::Point2f> > mCorners, mRejected; Vec2F mUlc; // upper left corner to draw public: @@ -24,8 +24,8 @@ public: QRectF boundingRect() const; void setRect(Vec2F& v); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - void setDetectedMarkers(vector<vector<Point2f> > corners, vector<int> ids); - void setRejectedMarkers(vector<vector<Point2f> > rejected); + void setDetectedMarkers(vector<vector<cv::Point2f> > corners, vector<int> ids); + void setRejectedMarkers(vector<vector<cv::Point2f> > rejected); }; #endif diff --git a/include/contrastFilter.h b/include/contrastFilter.h index 4006a1c15b902415cd9d23e1581dabd05b3e9d0d..88431504ce83db81f2f7ebc80d0a4be3c73ae165 100644 --- a/include/contrastFilter.h +++ b/include/contrastFilter.h @@ -11,8 +11,9 @@ private: public: ContrastFilter(); - +#ifndef STEREO_DISABLED IplImage* act(IplImage *img, IplImage *res); +#endif // bool changed(); diff --git a/include/ellipse.h b/include/ellipse.h index 77682e498d2dc19a58775f2db20235606fbb27f5..080146c977f3321af1c28c669b6f8df266cb34b9 100644 --- a/include/ellipse.h +++ b/include/ellipse.h @@ -1,7 +1,11 @@ #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 6cd83ec7d3ad8e5d896fe62fecec995b54e4040e..e70a8754c89cc227d5253ce313bb5a399117750d 100644 --- a/include/extrCalibration.h +++ b/include/extrCalibration.h @@ -2,6 +2,10 @@ #define EXTRCALIBRATION_H #include <iostream> +#include <vector> + +#include <QString> +#include <QVector> //#include <opencv.hpp> @@ -12,17 +16,16 @@ #include <opencv.hpp> +#ifndef STEREO_DISABLED #include "cxcore.h" #include "cvaux.h" +#endif #include "opencv.hpp" class Petrack; class Control; -using namespace cv; -using namespace std; - class ExtrCalibration { @@ -30,8 +33,8 @@ private: Petrack *mMainWindow; Control *mControlWidget; - vector<Point3f> points3D; - vector<Point2f> points2D; + std::vector<cv::Point3f> points3D; + std::vector<cv::Point2f> points2D; // Mat mRotation; // Mat mTranslation; @@ -66,27 +69,27 @@ public: bool fetch2DPoints(); void calibExtrParams(); bool calcReprojectionError(); - Point2f getImagePoint(Point3f p3d); - Point3f get3DPoint(Point2f p2d, double h); - Point3f transformRT(Point3f p); - bool isOutsideImage(Point2f p2d); - inline bool isOutsideImage(Point3f p3d) + cv::Point2f getImagePoint(cv::Point3f p3d); + cv::Point3f get3DPoint(cv::Point2f p2d, double h); + cv::Point3f transformRT(cv::Point3f p); + bool isOutsideImage(cv::Point2f p2d); + inline bool isOutsideImage(cv::Point3f p3d) { return isOutsideImage(getImagePoint(p3d)); } - inline vector<Point3f> get3DList() + inline std::vector<cv::Point3f> get3DList() { return points3D; } - inline void set3DList(vector<Point3f> list3D) + inline void set3DList(std::vector<cv::Point3f> list3D) { this->points3D = list3D; } - inline vector<Point2f> get2DList() + inline std::vector<cv::Point2f> get2DList() { return points2D; } - inline void set2DList(vector<Point2f> list2D) + inline void set2DList(std::vector<cv::Point2f> list2D) { this->points2D = list2D; } diff --git a/include/filter.h b/include/filter.h index e08789c641bc3af67fe4123cae9b0e39bbab8af6..6593cbcff5dd0ab5c35f342118cef6a9ea16b83d 100644 --- a/include/filter.h +++ b/include/filter.h @@ -1,8 +1,12 @@ #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/gridItem.h b/include/gridItem.h index 7255c52102136bdbeb15d2a6a07b032118cc372f..c936ba5520be0cff0a6c7b08b69a86bf82088a92 100644 --- a/include/gridItem.h +++ b/include/gridItem.h @@ -31,7 +31,7 @@ public: void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event); // void hoverMoveEvent(QGraphicsSceneHoverEvent *event); - int drawLine(QPainter *painter, Point2f *p, int y_offset); + int drawLine(QPainter *painter, cv::Point2f *p, int y_offset); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); }; diff --git a/include/helper.h b/include/helper.h index 03ddb3166b7044243b9300649885baf0a6f9ee42..8496c743b0c0c762af672c8d8ef7afce8c4cc786 100644 --- a/include/helper.h +++ b/include/helper.h @@ -54,12 +54,16 @@ inline ostream& operator<<(ostream& s, const QString& t) // Static function that converts an iplImg in a qImg. // If the images are not the same size, a new qImg will be created with the same size as the iplImg. #include <QImage> +#ifndef STEREO_DISABLED #include "cxcore.h" void copyToQImage(QImage *qImg, IplImage *iplImg); // war static functin in animatioln class +#endif void copyToQImage(QImage *qImg, cv::Mat &img); #include <QLabel> +#ifndef STEREO_DISABLED void showImg(QLabel *l, IplImage *i); +#endif cv::Mat getRoi(cv::Mat &img, const QRect &roi, cv::Rect &rect, bool evenPixelNumber = true); diff --git a/include/markerCasern.h b/include/markerCasern.h index 3f1c8d8718f04e892a000d08c7161136298e87d3..1eb6157f32285a68c24b1f3635be86854caca6d0 100644 --- a/include/markerCasern.h +++ b/include/markerCasern.h @@ -6,6 +6,8 @@ #include "ellipse.h" + + class TrackPoint; class MarkerCasern diff --git a/include/petrack.h b/include/petrack.h index 79d5a10e5ea662dfe96294589ed1e52a7b1bdf0b..81709907a0c281db8da592d8b83b9f36d4c726db 100644 --- a/include/petrack.h +++ b/include/petrack.h @@ -6,8 +6,10 @@ #include <QKeyEvent> #include <QMouseEvent> +#ifndef STEREO_DISABLED #include "cvaux.h" #include "cxcore.h" +#endif #include <opencv.hpp> //#include "opencv2/cxcore.h" @@ -32,6 +34,10 @@ #include "animation.h" #include "extrCalibration.h" +#ifdef STEREO_DISABLED +enum Camera {cameraLeft, cameraRight, cameraUnset}; +#endif + #define HEAD_SIZE 21. // durchschnittliche Kopflaenge in cm (Kopf 21x14) #define AXIS_MARKERS_LENGTH 10 @@ -159,7 +165,7 @@ public: void playAll(); int winSize(QPointF *pos=NULL, int pers=-1, int frame=-1, int level=-1); void updateImage(bool imageChanged = false); - void updateImage(const Mat &img); + void updateImage(const cv::Mat &img); // void updateImage(IplImage *iplImg); void updateSequence(); // void calcBackground(); diff --git a/include/player.h b/include/player.h index 2186985d65ef40f9d9f4907b2459625799b2f7e2..8bcec2a8dd9ff1336fb305124e7fb8694708daed 100644 --- a/include/player.h +++ b/include/player.h @@ -9,7 +9,11 @@ #else #include "aviFileWriter.h" #endif +#ifndef STEREO_DISABLED #include "cv.h" +#else +#include "opencv.hpp" +#endif class QLabel; class QSlider; diff --git a/include/stereoAviFile.h b/include/stereoAviFile.h index 1d1ad401426ef1ca3d6ba9df0990bf78868b6ff8..de7b14010aad036ebbabb7cb95f39d308bb2fe41 100644 --- a/include/stereoAviFile.h +++ b/include/stereoAviFile.h @@ -1,4 +1,4 @@ - +#ifndef STEREO_DISABLED #ifndef STEREOAVIFILE_H #define STEREOAVIFILE_H #undef UNICODE @@ -117,3 +117,4 @@ private: }; #endif // STEREOAVIFILE_H +#endif // STEREO_DISABLED diff --git a/include/stereoContext.h b/include/stereoContext.h index c69c909c316d17d8ab4f08bc8faaea1e3f4d581d..998409dafc1e6f381b23269b8b5781c3b7d25579 100644 --- a/include/stereoContext.h +++ b/include/stereoContext.h @@ -41,10 +41,11 @@ public: void init(cv::Mat &viewImg); void preprocess(); - +#ifndef STEREO_DISABLED IplImage *getRectified(enum Camera camera=cameraRight); IplImage *getDisparity(bool *dispNew = NULL); +#endif // von person.cpp benoetigt, um frame nummer zu erhalten inline Animation *getAnimation() @@ -124,13 +125,16 @@ protected: #endif BackgroundFilter *mBackgroundFilterLeft; BackgroundFilter *mBackgroundFilterRight; +#ifndef STEREO_DISABLED IplImage mRectLeft; IplImage mRectRight; IplImage mDisparity; CvStereoBMState *mBMState; +#endif + #if CV_MAJOR_VERSION == 2 cv::StereoSGBM *mSgbm; -#elif CV_MAJOR_VERSION == 3 +#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 cv::Ptr<cv::StereoSGBM> mSgbm; #endif CvMat *mBMdisparity16; diff --git a/include/stereoItem.h b/include/stereoItem.h index 05d97eb6a46a5db8280265ff3e40a795faae6f7d..0725e96f32a6e789ef8c2aa72b49b894a2698c3e 100644 --- a/include/stereoItem.h +++ b/include/stereoItem.h @@ -19,7 +19,9 @@ public: StereoItem(QWidget *wParent, QGraphicsItem * parent = NULL); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void hoverMoveEvent(QGraphicsSceneHoverEvent *event); +#ifndef STEREO_DISABLED void updateData(IplImage *disp); +#endif QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void setDispNew(bool d = true); diff --git a/include/stereoWidget.h b/include/stereoWidget.h index e40a11ceafe4baf8babf32726471ba7e8b6bfd0a..b16d7b656c245f8b14a7cc7626e8c4094c3688bf 100644 --- a/include/stereoWidget.h +++ b/include/stereoWidget.h @@ -21,7 +21,7 @@ public: void getXml(QDomElement &elem); private slots: - +#ifndef STEREO_DISABLED void on_stereoUseForHeight_stateChanged(int i) { if (stereoUseForHeightEver->isChecked() && stereoUseForHeight->isChecked()) @@ -123,6 +123,7 @@ private slots: { mMainWindow->getStereoContext()->exportPointCloud(); } +#endif private: Petrack *mMainWindow; diff --git a/include/swapFilter.h b/include/swapFilter.h index 922eb6d40d5c3381782ba652475b7eb8c24804d2..adcc5b2a4de60e6c11fd3be0e09cd46998598e1b 100644 --- a/include/swapFilter.h +++ b/include/swapFilter.h @@ -3,7 +3,6 @@ #include "filter.h" -using namespace::cv; class SwapFilter : public Filter { diff --git a/include/tracker.h b/include/tracker.h index d680c3ac6b987a26ec0a619c60f0654c2d81915d..b9623b92441f16627a80070c7d686161a1899dd3 100644 --- a/include/tracker.h +++ b/include/tracker.h @@ -7,7 +7,9 @@ //#include <opencv2/core/core.hpp> +#ifndef STEREO_DISABLED #include "cxcore.h" +#endif #include "vector.h" @@ -412,10 +414,10 @@ private: Petrack *mMainWindow; //int mNr; //double mFps; - Mat mGrey, mPrevGrey;//, mPyramid, mPrevPyramid; + cv::Mat mGrey, mPrevGrey;//, mPyramid, mPrevPyramid; // IplImage *mGrey, *mPrevGrey, *mPyramid, *mPrevPyramid; // CvPoint2D32f* mPrevFeaturePoints, *mFeaturePoints; - vector<Point2f> mPrevFeaturePoints, mFeaturePoints; + vector<cv::Point2f> mPrevFeaturePoints, mFeaturePoints; // CvPoint2D32f* mPrevColorFeaturePoints, *mColorFeaturePoints; vector<uchar> mStatus; //, *mColorStatus; int mFlags; @@ -433,11 +435,11 @@ public: ~Tracker(); // neben loeschen der liste muessen auch ... - void init(Size size); + void init(cv::Size size); void reset(); - void resize(Size size); + void resize(cv::Size size); void splitPerson(int pers, int frame); bool splitPersonAt(const Vec2F& p, int frame, QSet<int> onlyVisible); diff --git a/include/vector.h b/include/vector.h index 88a8fc528035d2f2b91c1b449afddaf88b36ff9e..5cb0682ef9d9f05dfc2bf9e679736a8851fa4224 100644 --- a/include/vector.h +++ b/include/vector.h @@ -4,6 +4,7 @@ #include "helper.h" #include <QVector3D> +#include "opencv2/core/types_c.h" #include <QMatrix4x4> struct CvPoint; diff --git a/petrack.pro b/petrack.pro index 7393b889e41aa95fd70665be988d980190c36036..78b08368f7b1058415ab4efa37fe56ee05582129 100644 --- a/petrack.pro +++ b/petrack.pro @@ -321,6 +321,7 @@ contains(hostname, [zZ][aA][mM]852) { } } else:contains(hostname, ias7176) { # Deniz 32-Bit + DEFINES += STEREO_DISABLED # PointGray PGRPATH = "../petrack/3rdparty/windows/triclops-3.4" @@ -328,9 +329,9 @@ contains(hostname, [zZ][aA][mM]852) { # OpenCV #CVPATH = "C:/OpenCV/opencv300/build/install" #CVPATH = "3rdparty/windows/opencv-3.1.0" - CVPATH = "../petrack/3rdparty/windows/opencv-3.1.0" - CVVERSION = "310" - CV_MAJOR_VERSION = "3" + CVPATH = "../petrack/3rdparty/windows/opencv-4.2.0" + CVVERSION = "420" + CV_MAJOR_VERSION = "4" # to switch between version 2.4.10 and 3.0.0 you have to update your OPENCV_DIR environment variable to the specific path @@ -342,30 +343,35 @@ contains(hostname, [zZ][aA][mM]852) { #QWTPATH = "D:/petrack/trunk/3rdparty/windows/qwt-6.1.2" INCLUDEPATH += $${QWTPATH}/include - STEREO = true # true / false + STEREO = false # true / false AVI = false # true / false #QWT = false # true / false #LIBELAS = false # fuer 64 bit -lopencv_ffmpeg_64 - LIBS += -lopencv_core$${CVVERSION} \ + LIBS += -L$${CVPATH}/x64/mingw/bin \ + -lopencv_core$${CVVERSION} \ -lopencv_highgui$${CVVERSION} \ -lopencv_imgproc$${CVVERSION} \ -lopencv_calib3d$${CVVERSION} \ -lopencv_video$${CVVERSION} \ - -lopencv_ffmpeg$${CVVERSION}\ + -lopencv_videoio_ffmpeg$${CVVERSION}\ -lopencv_aruco$${CVVERSION} contains(CV_MAJOR_VERSION,3){ message("Build with OpenCV 3.0.0") LIBS += -lopencv_videoio$${CVVERSION} \ -lopencv_imgcodecs$${CVVERSION} QMAKE_CXXFLAGS += -march=i686 - }else { + }else:contains(CV_MAJOR_VERSION,4) { + message("Build with OpenCV 4.x") + LIBS += -lopencv_videoio$${CVVERSION} \ + -lopencv_imgcodecs$${CVVERSION} + }else{ message("Build with OpenCV 2.x.x") LIBS += -lopencv_legacy$${CVVERSION} } } else:contains(hostname, ias7171) { - # Deniz 32-Bit + # Ann Katrin 32-Bit # PointGray PGRPATH = "../petrack/3rdparty/windows/triclops-3.4" diff --git a/src/animation.cpp b/src/animation.cpp index 429b0729d6607c65192e5349f38549beb0b0d711..f1cdab0b69763066fc16227446c42fd89f369093 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -33,8 +33,12 @@ 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" @@ -60,7 +64,9 @@ Animation::Animation(QWidget *wParent) mFirstSec = -1; mFirstMicroSec = -1; ////mCapture = NULL; +#ifndef STEREO_DISABLED mCaptureStereo = NULL; +#endif // mImage = NULL; // mStereoImgLeft = NULL; @@ -388,8 +394,8 @@ double Animation::getFPS() { if (mCameraLiveStream) { - if (mVideoCapture.get(CV_CAP_PROP_FPS)) - setFPS(mVideoCapture.get(CV_CAP_PROP_FPS)); + if (mVideoCapture.get(CAP_PROP_FPS)) + setFPS(mVideoCapture.get(CAP_PROP_FPS)); } if (mVideo) return mFps; @@ -452,7 +458,9 @@ void Animation::reset() mFirstSec = -1; mFirstMicroSec = -1; ////mCapture = NULL; +#ifndef STEREO_DISABLED mCaptureStereo = NULL; +#endif mTimeFileLoaded = false; @@ -501,6 +509,7 @@ bool Animation::isCameraLiveStream() return mCameraLiveStream; } +#ifndef STEREO_DISABLED enum Camera Animation::getCamera() { if (mCaptureStereo != NULL) @@ -516,7 +525,7 @@ void Animation::setCamera(enum Camera c) //else //keine Warnung, damit bei Projekt ohne direkt geladenem Video aber setzen von Stereo-Einstellungen keine Warnung ausgegeben wird // debout << "Warning: Setting camera is only allowed for loaded stereo videos!" << endl; } - +#endif /**********************************************************************/ /* Sequence of Images implementation **/ /**********************************************************************/ @@ -780,7 +789,7 @@ void Animation::freePhoto() /* Video implementation **/ /**********************************************************************/ - +#ifndef STEREO_DISABLED // used to get access of both frames only with calibStereoFilter #ifdef STEREO PgrAviFile *Animation::getCaptureStereo() @@ -790,9 +799,10 @@ StereoAviFile *Animation::getCaptureStereo() { return mCaptureStereo; } +#endif // also cvcamPlayAVI() is available!!!!! - +#ifndef STEREO_DISABLED // Implementation of the openAnimation function for videos // Opens an animation from a sequence of stereo video file // Stereo data from Arena/Messe (hermes) experiments @@ -858,7 +868,8 @@ bool Animation::openAnimationStereoVideo(int fileNumber, Mat &stereoImgLeft, Mat return ret; } - +#endif +#ifndef STEREO_DISABLED // like above for the first time with new filename bool Animation::openAnimationStereoVideo(QString fileName) { @@ -917,6 +928,7 @@ bool Animation::openAnimationStereoVideo(QString fileName) return ret; } +#endif // Implementation of the openAnimation function for videos // Opens an animation from a video file @@ -936,9 +948,9 @@ bool Animation::openAnimationVideo(QString fileName) ////int width = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH); ////int height = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT); ////int fps = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS); - int width = (int) mVideoCapture.get(CV_CAP_PROP_FRAME_WIDTH); - int height = (int) mVideoCapture.get(CV_CAP_PROP_FRAME_HEIGHT); - int fps = (int) mVideoCapture.get(CV_CAP_PROP_FPS); + int width = (int) mVideoCapture.get(CAP_PROP_FRAME_WIDTH); + int height = (int) mVideoCapture.get(CAP_PROP_FRAME_HEIGHT); + int fps = (int) mVideoCapture.get(CAP_PROP_FPS); //int fourcc = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FOURCC); //int frameCount = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT); //int propFormat = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FORMAT); @@ -996,11 +1008,13 @@ bool Animation::openAnimationVideo(QString fileName) { // Destroy anything that was before free(); +#ifndef STEREO_DISABLED if (mCaptureStereo) { mCaptureStereo->close(); delete mCaptureStereo; } +#endif ////mCapture = capture; // Set new video & photo labels mStereo = false; @@ -1067,7 +1081,7 @@ Mat Animation::getFrameVideo(int index) // OLD ////cvSetCaptureProperty(mCapture, CV_CAP_PROP_POS_FRAMES, index); // NEW - if( !mVideoCapture.set(CV_CAP_PROP_POS_FRAMES, index) ) + if( !mVideoCapture.set(CAP_PROP_POS_FRAMES, index) ) { debout << "Error: video file does not support skipping." << endl; return Mat(); @@ -1161,6 +1175,7 @@ Mat Animation::getFrameVideo(int index) */ } +#ifndef STEREO_DISABLED else if (mStereo && mCaptureStereo)// stereo video { if (index/640 != mCurrentStereoFileNumber) // 640 stereo frames in one file @@ -1169,12 +1184,14 @@ Mat Animation::getFrameVideo(int index) } mImage = cvarrToMat(mCaptureStereo->readFrame(index - mCurrentStereoFileNumber * 640)); } +#endif // We set the current frame index mCurrentFrame = index; } +#ifndef STEREO_DISABLED else if (mStereo && (index == mCurrentFrame)) // da mgl anderes Bild rechte/links angefordert wird mImage = cvarrToMat(mCaptureStereo->readFrame(index - mCurrentStereoFileNumber * 640)); - +#endif // Return the pointer to the IplImage :-) return mImage; } @@ -1205,8 +1222,8 @@ bool Animation::getInfoVideo(QString fileName) // We get the FPS number with the cvGetCaptureProperty function // Note that this doesn't work if no frame has already retrieved!! ////setFPS(cvGetCaptureProperty(mCapture,CV_CAP_PROP_FPS)); - if (mVideoCapture.get(CV_CAP_PROP_FPS)) - setFPS(mVideoCapture.get(CV_CAP_PROP_FPS)); + if (mVideoCapture.get(CAP_PROP_FPS)) + setFPS(mVideoCapture.get(CAP_PROP_FPS)); // Since the Xine implementation is kaputt, we have to do a hack to get the length of the video // We will do two cases : @@ -1263,7 +1280,7 @@ bool Animation::getInfoVideo(QString fileName) //#endif // detect the used video codec - int fourCC = static_cast<int>( mVideoCapture.get(CV_CAP_PROP_FOURCC) ); + int fourCC = static_cast<int>( mVideoCapture.get(CAP_PROP_FOURCC) ); char FOURCC[] = {(char)( fourCC & 0XFF) , (char)((fourCC & 0XFF00) >> 8), (char)((fourCC & 0XFF0000) >> 16), @@ -1272,31 +1289,31 @@ bool Animation::getInfoVideo(QString fileName) //debout << "used video codec: " << FOURCC << endl; ////mNumFrames = (int) cvGetCaptureProperty(mCapture,CV_CAP_PROP_FRAME_COUNT); - mMaxFrames = (int) mVideoCapture.get(CV_CAP_PROP_FRAME_COUNT); //mNumFrame + mMaxFrames = (int) mVideoCapture.get(CAP_PROP_FRAME_COUNT); //mNumFrame mSourceOutFrame = mMaxFrames-1; //debout << "OpenCV FRAME_COUNT: " << mMaxFrames << endl; // Set videocapture to the last frame if CV_CAP_PROP_POS_FRAMES is supported by used video codec - if( mVideoCapture.set(CV_CAP_PROP_POS_FRAMES, mMaxFrames) > 0 ) + if( mVideoCapture.set(CAP_PROP_POS_FRAMES, mMaxFrames) > 0 ) { // Set videoCapture to the really correct last frame - mVideoCapture.set(CV_CAP_PROP_POS_FRAMES, mVideoCapture.get(CV_CAP_PROP_POS_FRAMES)-1); + mVideoCapture.set(CAP_PROP_POS_FRAMES, mVideoCapture.get(CAP_PROP_POS_FRAMES)-1); // Check if mNumFrames agrees with last readable frame - if( mMaxFrames != (mVideoCapture.get(CV_CAP_PROP_POS_FRAMES)+1) ) + if( mMaxFrames != (mVideoCapture.get(CAP_PROP_POS_FRAMES)+1) ) { - debout << "Warning: number of frames detected by OpenCV library (" << mMaxFrames << ") seems to be incorrect! (set to estimated value: "<< (mVideoCapture.get(CV_CAP_PROP_POS_FRAMES)+1) << ") [video codec: " << FOURCC << "]" << endl; - mMaxFrames = mVideoCapture.get(CV_CAP_PROP_POS_FRAMES)+1; + debout << "Warning: number of frames detected by OpenCV library (" << mMaxFrames << ") seems to be incorrect! (set to estimated value: "<< (mVideoCapture.get(CAP_PROP_POS_FRAMES)+1) << ") [video codec: " << FOURCC << "]" << endl; + mMaxFrames = mVideoCapture.get(CAP_PROP_POS_FRAMES)+1; mSourceOutFrame = mMaxFrames-1; } // Check if the last frame of the video is readable/OK? Mat frame; while( !mVideoCapture.read(frame) ){ - mVideoCapture.set(CV_CAP_PROP_POS_FRAMES,mVideoCapture.get(CV_CAP_PROP_POS_FRAMES)-2); - mMaxFrames = mVideoCapture.get(CV_CAP_PROP_POS_FRAMES)+1; - if( mVideoCapture.get(CV_CAP_PROP_POS_FRAMES) < 0 ){ + mVideoCapture.set(CAP_PROP_POS_FRAMES,mVideoCapture.get(CAP_PROP_POS_FRAMES)-2); + mMaxFrames = mVideoCapture.get(CAP_PROP_POS_FRAMES)+1; + if( mVideoCapture.get(CAP_PROP_POS_FRAMES) < 0 ){ cerr << "Warning: video file seems to be broken!" << endl; mMaxFrames = -1; mSourceOutFrame = mMaxFrames-1; @@ -1346,8 +1363,8 @@ bool Animation::getCameraInfo() // We get the FPS number with the cvGetCaptureProperty function // Note that this doesn't work if no frame has already retrieved!! ////setFPS(cvGetCaptureProperty(mCapture,CV_CAP_PROP_FPS)); - if (mVideoCapture.get(CV_CAP_PROP_FPS)) - setFPS(mVideoCapture.get(CV_CAP_PROP_FPS)); + if (mVideoCapture.get(CAP_PROP_FPS)) + setFPS(mVideoCapture.get(CAP_PROP_FPS)); return true; } diff --git a/src/autoCalib.cpp b/src/autoCalib.cpp index e4c5ed6987d1009eb9dfe822f6f617b60054ad13..efebbbe954a293573e902656345de0407325140f 100644 --- a/src/autoCalib.cpp +++ b/src/autoCalib.cpp @@ -4,12 +4,14 @@ #include <QProgressDialog> #include <QApplication> -#include "highgui.h" +#include "highgui.hpp" #include "autoCalib.h" #include "petrack.h" #include "control.h" +using namespace::cv; + #define SHOW_CALIB_MAINWINDOW // definieren, wenn das Schachbrett im Mainwindow und nicht separat angezeigt werden soll: // fuehrt nach Calibration dazu dass play des originalvideos abstuerzt, insb wenn intr apply nicht ausgewaehlt war @@ -94,7 +96,7 @@ void AutoCalib::autoCalib() } #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 +#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 Size board_size(mBoardSizeX, mBoardSizeY); #endif float square_size = mSquareSize; //5.25f; // 3.f; // da 3x3cm hat Schachbrett, was ich ausgedruckt habe @@ -191,7 +193,7 @@ void AutoCalib::autoCalib() { // improve the found corners' coordinate accuracy // view_gray = cvCreateImage(imgSize, 8, 1); - cvtColor(view,view_gray,CV_BGR2GRAY); + cvtColor(view,view_gray,COLOR_BGR2GRAY); // cvCvtColor(view, view_gray, CV_BGR2GRAY); cornerSubPix(view_gray,corners,Size(11,11), Size(-1,-1),TermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,0.1)); diff --git a/src/aviFileWriter.cpp b/src/aviFileWriter.cpp index 65549e4bd8f5ff0b26c5a0d7f4ded2d9939b58d9..5041ffb4fedd36418b8d47d0e529165dc84fe452 100644 --- a/src/aviFileWriter.cpp +++ b/src/aviFileWriter.cpp @@ -13,6 +13,8 @@ //============================================================================= #include "aviFileWriter.h" //#include "helper.h" +#include <opencv2/videoio/videoio_c.h> + using namespace::cv; using namespace::std; diff --git a/src/backgroundFilter.cpp b/src/backgroundFilter.cpp index 61c86507687dbbe11da116e99577698af1b8b895..9643b9d4d26ecfe84eaac8173de4a36b6fac948a 100644 --- a/src/backgroundFilter.cpp +++ b/src/backgroundFilter.cpp @@ -2,7 +2,7 @@ #include "stereoContext.h" // nur temporaer fuer anzeige -#include "highgui.h" +#include "highgui.hpp" #include "helper.h" // spaeter entfernen naechsten beiden zeilen @@ -102,6 +102,7 @@ void BackgroundFilter::setFilename(const QString &fn) // rueckgabe, ob speichern geklappt hat bool BackgroundFilter::save(QString dest) //default = "" { +#ifndef STEREO_DISABLED if (*stereoContext() && !mBgPointCloud.empty()) { // if no destination file or folder is given @@ -198,6 +199,7 @@ bool BackgroundFilter::save(QString dest) //default = "" { ; } +#endif return true; } @@ -360,6 +362,7 @@ waitKey(); if (mBgPointCloud.empty() && mBgModel.empty() || mForeground.empty() || mForeground.size != img.size) // initialisierung wenn entwerder stereo oder model { +#ifndef STEREO_DISABLED // For StereoImaging use heightfiled for foreground extraction ------------------------------------------------------------------------------- if (*stereoContext()) { @@ -430,7 +433,9 @@ waitKey(); mForeground.create(Size(img.cols,img.rows),CV_8UC1); // mForeground = cvCreateImage(cvSize(img->width, img->height), IPL_DEPTH_8U, 1); // CV_8UC1 8, 1 } + else // nicht stereo +#endif // STEREO_DISABLED { // GaussBGStatModel --------------------------------------------------------------------------------------------------------------------- @@ -547,6 +552,7 @@ waitKey(); // SteroBild beruecksichtigen nur disparity -------------------------------------------------------------------------------------------------------- if (*stereoContext()) { +#ifndef STEREO_DISABLED // fuer update waere bei stereo denkbar: mittelwert der disp/zwerte, aber Achtung: invalidDisp beruecksichtigen! @@ -612,7 +618,7 @@ waitKey(); bgPcData = (bgyPcData += mBgPointCloud.cols/sizeof(float)); } - +#endif } else // nicht stereo { @@ -707,7 +713,7 @@ waitKey(); // CvPoint* pointArray; // find contours and store them all as a list // CvMemStorage *storage = cvCreateMemStorage(0); - cv::findContours(mForeground,contours,CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE); + cv::findContours(mForeground,contours,cv::RETR_LIST,cv::CHAIN_APPROX_SIMPLE); // cvFindContours(mForeground, storage, &contour, sizeof(CvContour), // CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE); // foreground wird auch veraendert??? // test each contour diff --git a/src/backgroundItem.cpp b/src/backgroundItem.cpp index 1f1f57775f1629b7bd31964236a583db10a006cf..652f43da5876f35f6fb24ef36b94439fc93543dd 100644 --- a/src/backgroundItem.cpp +++ b/src/backgroundItem.cpp @@ -4,6 +4,8 @@ #include "view.h" #include "backgroundItem.h" +using namespace::cv; + // in x und y gleichermassen skaliertes koordinatensystem, // da von einer vorherigen intrinsischen kamerakalibrierung ausgegenagen wird, // so dass pixel quadratisch diff --git a/src/blurFilter.cpp b/src/blurFilter.cpp index ff9f986b406cde7b8fbafe941d4313afe15bdeac..cd6c522063843d9a81b2cff1a3fee7bbc9f792ce 100644 --- a/src/blurFilter.cpp +++ b/src/blurFilter.cpp @@ -1,5 +1,9 @@ #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/borderFilter.cpp b/src/borderFilter.cpp index 0091d80fd1a500f872997c48cbc75eabca353274..6ffa73b50d489b80eca35825f8b5adf9655e838b 100644 --- a/src/borderFilter.cpp +++ b/src/borderFilter.cpp @@ -1,6 +1,8 @@ #include "borderFilter.h" #include "helper.h" +using namespace::cv; + BorderFilter::BorderFilter() :Filter() { diff --git a/src/brightContrastFilter.cpp b/src/brightContrastFilter.cpp index 2e6ce06e32ea3c96b9feee9c29a7701f92eb85b3..2641e17b72fb0dc8651caa0315f759b71b2b8045 100644 --- a/src/brightContrastFilter.cpp +++ b/src/brightContrastFilter.cpp @@ -1,5 +1,7 @@ #include "brightContrastFilter.h" +using namespace::cv; + BrightContrastFilter::BrightContrastFilter() :Filter() { diff --git a/src/brightFilter.cpp b/src/brightFilter.cpp index 9bcc6acc5d7414f36d0e8a7057bb6cf73e089162..550b8352cad9814b4f659468e2bb606f97a9c572 100644 --- a/src/brightFilter.cpp +++ b/src/brightFilter.cpp @@ -9,6 +9,7 @@ BrightFilter::BrightFilter() mB.setFilter(this); } +#ifndef STEREO_DISABLED IplImage* BrightFilter::act(IplImage *img, IplImage *res) { int x, y; @@ -54,7 +55,7 @@ IplImage* BrightFilter::act(IplImage *img, IplImage *res) // { // return Filter::changed() || mB.changed(); // } - +#endif Parameter* BrightFilter::getBrightness() { return &mB; diff --git a/src/calibFilter.cpp b/src/calibFilter.cpp index 7b79556cf46dc5cadb997677669683fb22ab535e..a5ca96087a7cabb37d0b5e854c49978acab57e28 100644 --- a/src/calibFilter.cpp +++ b/src/calibFilter.cpp @@ -1,6 +1,8 @@ #include "calibFilter.h" #include "helper.h" +using namespace::cv; + CalibFilter::CalibFilter() :Filter() { diff --git a/src/calibStereoFilter.cpp b/src/calibStereoFilter.cpp index 61a490e3ba6df95c3bf652b929c91ea77e34eb7d..3ac01e54f22a0bb8d5f43735f5bc5870a553db58 100644 --- a/src/calibStereoFilter.cpp +++ b/src/calibStereoFilter.cpp @@ -8,9 +8,15 @@ CalibStereoFilter::CalibStereoFilter() setOnCopy(false); // da in stereoContext der Speicherplatz fuer res liegt } + + 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/codeMarkerItem.cpp b/src/codeMarkerItem.cpp index 0ad072c4302f7849a13d02b8525a7ed0fd7cf837..6006aef6760d75e5dc52dacd22ad2a3a11d51dcb 100644 --- a/src/codeMarkerItem.cpp +++ b/src/codeMarkerItem.cpp @@ -7,6 +7,8 @@ #include "tracker.h" #include "animation.h" +using namespace::cv; + // in x und y gleichermassen skaliertes koordinatensystem, // da von einer vorherigen intrinsischen kamerakalibrierung ausgegenagen wird, // so dass pixel quadratisch diff --git a/src/colorMarkerItem.cpp b/src/colorMarkerItem.cpp index fc6bfb4069467e59154da34d2691b76bc0e36ce5..08d9bcf2c78775072426038d03324520f7880e0d 100644 --- a/src/colorMarkerItem.cpp +++ b/src/colorMarkerItem.cpp @@ -7,6 +7,8 @@ #include "tracker.h" #include "animation.h" +using namespace::cv; + // in x und y gleichermassen skaliertes koordinatensystem, // da von einer vorherigen intrinsischen kamerakalibrierung ausgegenagen wird, // so dass pixel quadratisch diff --git a/src/contrastFilter.cpp b/src/contrastFilter.cpp index 76ebd197de7d8b61645894c7ef4812851a07f863..689d11d809b1b08f2727ddf7e8792981ea014ea3 100644 --- a/src/contrastFilter.cpp +++ b/src/contrastFilter.cpp @@ -8,7 +8,7 @@ ContrastFilter::ContrastFilter() mC.setValue(0.); mC.setFilter(this); } - +#ifndef STEREO_DISABLED IplImage* ContrastFilter::act(IplImage *img, IplImage *res) { int x, y; @@ -62,7 +62,7 @@ IplImage* ContrastFilter::act(IplImage *img, IplImage *res) return res; } - +#endif Parameter* ContrastFilter::getContrast() { return &mC; diff --git a/src/control.cpp b/src/control.cpp index 2ab365fba8eefe79723aac7308fdad046ad96ec7..b6d3b5d8118efefc4c84c56acdd9203a41e29d3c 100644 --- a/src/control.cpp +++ b/src/control.cpp @@ -942,7 +942,7 @@ void Control::on_trackReset_clicked() { if (mMainWindow->getImage()) { - Size size; + cv::Size size; size.width = mMainWindow->getTrackRoiItem()->rect().width(); size.height = mMainWindow->getTrackRoiItem()->rect().height(); mMainWindow->setTrackChanged(true);// flag changes of track parameters diff --git a/src/ellipse.cpp b/src/ellipse.cpp index 5d4dc72d53692c53d01b64c61de3c02831eaa924..40a04c1bd59c77e9093f771ba7f463ceb82df317 100644 --- a/src/ellipse.cpp +++ b/src/ellipse.cpp @@ -95,8 +95,10 @@ void MyEllipse::draw(cv::Mat &img, int r, int g, int b) const // CvSize size; size.width = myRound(mR1); size.height = myRound(mR2); + Vec2F centerVec = center(); + cv::Point centerPoint(centerVec.x(), centerVec.y()); // cvEllipse(img, center().toCvPoint(), size, 180*mAngle/PI, 0, 360, CV_RGB(r, g, b), 1, CV_AA, 0); - cv::ellipse(img, center().toCvPoint(), size, 180*mAngle/PI, 0, 360, CvScalar(r,g,b), 1, CV_AA, 0); + cv::ellipse(img, centerPoint, size, 180*mAngle/PI, 0, 360, cv::Scalar(r,g,b), 1, cv::LINE_AA, 0); } diff --git a/src/extrCalibration.cpp b/src/extrCalibration.cpp index 3b9d7b1b0726493e3c509f7d92faefee17b7cce4..609fa233e8c5cef0566b05d30fc4873426ff3d5d 100644 --- a/src/extrCalibration.cpp +++ b/src/extrCalibration.cpp @@ -7,6 +7,9 @@ #include "petrack.h" #include "control.h" +using namespace std; +using namespace cv; + #define MAX_AV_ERROR 20 ExtrCalibration::ExtrCalibration() @@ -906,7 +909,7 @@ Point3f ExtrCalibration::get3DPoint(Point2f p2d, double h) pointBeforeCam.z = 50; if( debug ) cout << "Point before Camera: [" << pointBeforeCam.x << ", " << pointBeforeCam.y << ", " << pointBeforeCam.z << "]" << endl; // 3D-Punkt vor Kamera in Weltkoordinaten - CvPoint3D32f pBCInWorld = transformRT(pointBeforeCam); + Point3f pBCInWorld = transformRT(pointBeforeCam); if( debug ) cout << "Point before Camera in World-Coordinatesystem: [" << pBCInWorld.x << ", " << pBCInWorld.y << ", " << pBCInWorld.z << "]" << endl; if( debug ) cout << "Camera in World-Coordinatesystem: [" << camInWorld.x << ", " << camInWorld.y << ", " << camInWorld.z << "]" << endl; // Berechnung des Richtungsvektors der Gerade von der Kamera durch den Pixel diff --git a/src/gridItem.cpp b/src/gridItem.cpp index ecb54f08af21c1f2888cd88ec1cefa83ac6d92ad..c774e415c1ea41b29018b1f6a8b3a6c995f8db3a 100644 --- a/src/gridItem.cpp +++ b/src/gridItem.cpp @@ -7,6 +7,8 @@ #include "view.h" #include "gridItem.h" +using namespace::cv; + GridItem::GridItem(QWidget *wParent, QGraphicsItem * parent) : QGraphicsItem(parent) { diff --git a/src/helper.cpp b/src/helper.cpp index 080603390c01d59981b557ff9a265a72cfe0640c..4f68e9eeadb8e78754fa4f60eaf57e672f206919 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -172,12 +172,15 @@ void copyToQImage(QImage *qImg, cv::Mat &img) // war static functin in animatiol // debout << "copyImage ende" << endl; } +#ifndef STEREO_DISABLED void copyToQImage(QImage *qImg, IplImage *iplImg) { Mat tempMat = cvarrToMat(iplImg); copyToQImage(qImg,tempMat); } +#endif +#ifndef STEREO_DISABLED void showImg(QLabel *l, IplImage *i) { QImage qImg(i->width, i->height, QImage::Format_RGB32); @@ -185,6 +188,7 @@ void showImg(QLabel *l, IplImage *i) l->setPixmap(QPixmap::fromImage(qImg)); l->show(); } +#endif // get roi // no copy of data, only new header which allows to access rect diff --git a/src/imageItem.cpp b/src/imageItem.cpp index ab9455141c7e30e8ca49f1c8baad005e1aa85516..efd68e8889142769e23463a65553d01f0a5e1aa1 100644 --- a/src/imageItem.cpp +++ b/src/imageItem.cpp @@ -101,11 +101,11 @@ QPointF ImageItem::getCmPerPixel(float px, float py, float h){ bool debug = false; - Point3f p3x1 = mMainWindow->getExtrCalibration()->get3DPoint(Point2f(px-0.5,py),h); - Point3f p3x2 = mMainWindow->getExtrCalibration()->get3DPoint(Point2f(px+0.5,py),h); + cv::Point3f p3x1 = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(px-0.5,py),h); + cv::Point3f p3x2 = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(px+0.5,py),h); - Point3f p3y1 = mMainWindow->getExtrCalibration()->get3DPoint(Point2f(px,py-0.5),h); - Point3f p3y2 = mMainWindow->getExtrCalibration()->get3DPoint(Point2f(px,py+0.5),h); + cv::Point3f p3y1 = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(px,py-0.5),h); + cv::Point3f p3y2 = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(px,py+0.5),h); if( debug ) debout << "Punkte: " << p3x1.x << ", " << p3x1.y << ", " << p3x1.z << endl; if( debug ) debout << "Punkte: " << p3x2.x << ", " << p3x2.y << ", " << p3x2.z << endl; @@ -133,16 +133,16 @@ double ImageItem::getAngleToGround(float px, float py, float height){ bool debug = false; - Point3f cam( - mControlWidget->getCalibCoord3DTransX() - mControlWidget->getCalibExtrTrans1(), + cv::Point3f cam( - mControlWidget->getCalibCoord3DTransX() - mControlWidget->getCalibExtrTrans1(), - mControlWidget->getCalibCoord3DTransY() - mControlWidget->getCalibExtrTrans2(), - mControlWidget->getCalibCoord3DTransZ() - mControlWidget->getCalibExtrTrans3() ); - Point3f posInImage = mMainWindow->getExtrCalibration()->get3DPoint(Point2f(px-mMainWindow->getImageBorderSize(),py-mMainWindow->getImageBorderSize()),height); + cv::Point3f posInImage = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(px-mMainWindow->getImageBorderSize(),py-mMainWindow->getImageBorderSize()),height); if( debug ) debout << "Camera: " << cam.x << ", " << cam.y << ", " << cam.z << endl; if( debug ) debout << "posInImage: " << posInImage.x << ", " << posInImage.y << ", " << posInImage.z << endl; - Point3f a(cam.x-posInImage.x,cam.y-posInImage.y,cam.z-posInImage.z), + cv::Point3f a(cam.x-posInImage.x,cam.y-posInImage.y,cam.z-posInImage.z), b(0,0,1); if( debug ) debout << "a: (" << a.x << ", " << a.y << ", " << a.z << ")" << endl; @@ -155,12 +155,12 @@ QPointF ImageItem::getPosImage(QPointF pos, float height) //QPointF ImageItem::getPosImage(QPointF pos) { bool debug = false; - Point2f p2d; + cv::Point2f p2d; if( mImage ) { if( mControlWidget->getCalibCoordDimension() == 0 ) { - p2d = mMainWindow->getExtrCalibration()->getImagePoint(Point3f(pos.x(),pos.y(),height)); + p2d = mMainWindow->getExtrCalibration()->getImagePoint(cv::Point3f(pos.x(),pos.y(),height)); pos.setX(p2d.x); pos.setY(p2d.y); }else @@ -233,9 +233,9 @@ QPointF ImageItem::getPosReal(QPointF pos, double height) if( mControlWidget->getCalibCoordDimension() == 0 ) { // New 3D mapping of Pixelpoints to RealPositions - Point3f p3d = mMainWindow->getExtrCalibration()->get3DPoint(Point2f(pos.x()-bS,pos.y()-bS),height); + cv::Point3f p3d = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(pos.x()-bS,pos.y()-bS),height); - Point2f p2d = debug ? mMainWindow->getExtrCalibration()->getImagePoint(p3d) : Point2f(0,0); + cv::Point2f p2d = debug ? mMainWindow->getExtrCalibration()->getImagePoint(p3d) : cv::Point2f(0,0); if( debug ) debout << "########## INFO ###############" << endl; if( debug ) debout << "Org. 2D Point: (" << pos.x() << ", " << pos.y() << ") Hoehe: "<< height << endl; @@ -330,7 +330,7 @@ void ImageItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) debout << "Pixel unter der Camera: " << pixUnderCam.x() << ", " << pixUnderCam.y() << endl; - Point2f pixUnderCam2f = mMainWindow->getExtrCalibration()->getImagePoint(Point3f( + cv::Point2f pixUnderCam2f = mMainWindow->getExtrCalibration()->getImagePoint(cv::Point3f( -mControlWidget->getCalibCoord3DTransX()-mControlWidget->getCalibExtrTrans1(), -mControlWidget->getCalibCoord3DTransY()-mControlWidget->getCalibExtrTrans2(), 0)); diff --git a/src/markerCasern.cpp b/src/markerCasern.cpp index df23a06e4674bcdee603c1ed22b2bdcd2b9dcd2e..76535b9df36164b756635b3184b6065f3e9a8eb4 100644 --- a/src/markerCasern.cpp +++ b/src/markerCasern.cpp @@ -1,5 +1,5 @@ //folgende zeile spaeter raus -#include <highgui.h> +#include <highgui.hpp> // spaeter entfernen naechsten beiden zeilen //#include "control.h" @@ -21,6 +21,8 @@ #include "helper.h" #include "tracker.h" +using namespace::cv; + // bei marker koennnte sich fuer jeden spot eine liste gemerkt werden und spaeter ausgleich // regressionsgrade legen um optimale linie durch marker zu erhalten MarkerCasern::MarkerCasern(MyEllipse head) @@ -625,7 +627,7 @@ void MarkerCasern::draw(cv::Mat &img) const pt.push_back(Point(mQuadrangle[i].x(),mQuadrangle[i].y())); // pt[i] = mQuadrangle[i].toCvPoint(); // draw the square as a closed polyline - cv::polylines(img,pt,true,CV_RGB(0,255,0),1,CV_AA,0); + cv::polylines(img,pt,true,CV_RGB(0,255,0),1,LINE_AA,0); // cvPolyLine(img, &rect, &count, 1, 1, CV_RGB(0,255,0), 1, CV_AA, 0); //3, CV_AA, 0 } } diff --git a/src/markerColor.cpp b/src/markerColor.cpp index d2e19c9d3bdb01f3e12f8e108d1b4e56fc272c72..5bac8bb561aaba3b9b514fe37967096652cf0424 100644 --- a/src/markerColor.cpp +++ b/src/markerColor.cpp @@ -1,5 +1,5 @@ //folgende zeile spaeter raus -#include <highgui.h> +#include <highgui.hpp> // spaeter entfernen naechsten beiden zeilen //#include "control.h" @@ -21,6 +21,8 @@ #include "helper.h" #include "tracker.h" +using namespace::cv; + // bei marker koennnte sich fuer jeden spot eine liste gemerkt werden und spaeter ausgleich // regressionsgrade legen um optimale linie durch marker zu erhalten MarkerColor::MarkerColor(MyEllipse head) @@ -625,7 +627,7 @@ void MarkerColor::draw(Mat &img) const pt.push_back(Point(mQuadrangle[i].x(),mQuadrangle[i].y())); // pt[i] = mQuadrangle[i].toCvPoint(); // draw the square as a closed polyline - cv::polylines(img,pt,true,CV_RGB(0,255,0),1,CV_AA,0); + cv::polylines(img,pt,true,CV_RGB(0,255,0),1,LINE_AA,0); // cvPolyLine(img, &rect, &count, 1, 1, CV_RGB(0,255,0), 1, CV_AA, 0); //3, CV_AA, 0 } } diff --git a/src/markerHermes.cpp b/src/markerHermes.cpp index 18f1991e4a4b691239122497ac35a2b13211c01e..71f2e79ce2cdf81b0c2653a695cd61bf6d16185d 100644 --- a/src/markerHermes.cpp +++ b/src/markerHermes.cpp @@ -1,5 +1,5 @@ //folgende zeile spaeter raus -#include <highgui.h> +#include <highgui.hpp> // spaeter entfernen naechsten beiden zeilen //#include "control.h" @@ -17,6 +17,8 @@ #include "helper.h" #include "tracker.h" +using namespace::cv; + // bei marker koennnte sich fuer jeden spot eine liste gemerkt werden und spaeter ausgleich // regressionsgrade legen um optimale linie durch marker zu erhalten MarkerHermes::MarkerHermes(MyEllipse head) diff --git a/src/markerJapan.cpp b/src/markerJapan.cpp index 7726af09f400047c656d2d121bd72348f800eb2c..23aed9ec0d21e8f48160b87772a7eabbca707173 100644 --- a/src/markerJapan.cpp +++ b/src/markerJapan.cpp @@ -1,5 +1,5 @@ //folgende zeile spaeter raus -#include <highgui.h> +#include <highgui.hpp> // spaeter entfernen naechsten beiden zeilen //#include "control.h" @@ -18,6 +18,8 @@ #include "helper.h" #include "tracker.h" +using namespace::cv; + // bei marker koennnte sich fuer jeden spot eine liste gemerkt werden und spaeter ausgleich // regressionsgrade legen um optimale linie durch marker zu erhalten MarkerJapan::MarkerJapan(MyEllipse head) @@ -426,7 +428,7 @@ void MarkerJapan::draw(Mat &img) const pt.push_back(Point(mQuadrangle[i].x(),mQuadrangle[i].y())); // pt[i] = mQuadrangle[i].toCvPoint(); // draw the square as a closed polyline - cv::polylines(img,pt,true,CV_RGB(0,255,0),1,CV_AA,0); + cv::polylines(img,pt,true,CV_RGB(0,255,0),1,LINE_AA,0); // cvPolyLine(img, &rect, &count, 1, 1, CV_RGB(0,255,0), 1, CV_AA, 0); //3, CV_AA, 0 } } diff --git a/src/multiColorMarkerItem.cpp b/src/multiColorMarkerItem.cpp index 3e4ff75d3e7fa1901bf08c10b2478e0672481a4c..99b0c8c262c007174d297ca871ab979a776c3dc8 100644 --- a/src/multiColorMarkerItem.cpp +++ b/src/multiColorMarkerItem.cpp @@ -7,6 +7,8 @@ #include "tracker.h" #include "animation.h" +using namespace::cv; + // in x und y gleichermassen skaliertes koordinatensystem, // da von einer vorherigen intrinsischen kamerakalibrierung ausgegenagen wird, // so dass pixel quadratisch diff --git a/src/person.cpp b/src/person.cpp index 131fb97b70e8b379bc33fbd0e946129bf9473296..bb233999ef4991e300b779ecd412062dd7061303 100644 --- a/src/person.cpp +++ b/src/person.cpp @@ -10,11 +10,14 @@ //#define TIME_MEASUREMENT +using namespace::cv; + PersonList::PersonList() { mSc = NULL; } +#ifndef STEREO_DISABLED // searching for ellipses from isolines in a height field void PersonList::searchEllipses(pet::StereoContext *sc, QRect &roi, BackgroundFilter* bgFilter) { @@ -975,5 +978,5 @@ void PersonList::calcPersonPos(const Mat &img, QRect &roi, QList<TrackPoint> &pe */ } - +#endif // STEREO_DISABLED diff --git a/src/petrack.cpp b/src/petrack.cpp index 9383cc7eef35ae9563e5bda13981fd28d374da94..4c0cd93715bb462b1824d77a95dad634e6cd99b0 100644 --- a/src/petrack.cpp +++ b/src/petrack.cpp @@ -43,6 +43,8 @@ #include <iomanip> +#include "opencv.hpp" + // Zeitausgabe aktivieren //#define TIME_MEASUREMENT @@ -678,7 +680,11 @@ void Petrack::saveXml(QDomDocument &doc) // kein rect oder so gefunden, was den sichtbaren bereich in viewport angibt // elem.setAttribute("TRANSFORMATION", QString("%1 %2 %3 %4 %5 %6").arg(mat.m11()).arg(mat.m12()).arg(mat.m21()).arg(mat.m22()).arg(mat.dx()).arg(mat.dy())); elem.setAttribute("TRANSFORMATION", QString("%1 %2 %3 %4").arg(mViewWidget->getZoomLevel()).arg(mViewWidget->getRotateLevel()).arg(mView->horizontalScrollBar()->value()).arg(mView->verticalScrollBar()->value())); +#ifndef STEREO_DISABLED elem.setAttribute("CAMERA", mAnimation->getCamera()); +#else + elem.setAttribute("CAMERA", cameraUnset); +#endif elem.setAttribute("HIDE_CONTROLS", mHideControlsAct->isChecked()); root.appendChild(elem); @@ -1144,7 +1150,7 @@ void Petrack::saveSequence(bool saveVideo, bool saveView, QString dest) // defau if ((mImgFiltered.channels() == 1) /* && convert8To24bit*/) { //cvCvtColor(mIplImgFiltered, iplImgFilteredBGR, CV_GRAY2BGR); - cvtColor(mImg, iplImgFilteredBGR, CV_GRAY2BGR); + cvtColor(mImg, iplImgFilteredBGR, COLOR_GRAY2BGR); if( saveView ) writeFrameRet = aviFile.appendFrame((const unsigned char*) viewImage->bits(), true); // 2. param besagt, ob vertikal gespiegel werden soll else @@ -1569,6 +1575,7 @@ void Petrack::showHideControlWidget() void Petrack::setCamera() { +#ifndef STEREO_DISABLED if (mAnimation) { if (mCameraLeftViewAct->isChecked()) @@ -1595,6 +1602,8 @@ void Petrack::setCamera() //mPlayerWidget->skipToFrame(mPlayerWidget->getPos()); // machtpasue!! //updateImage(true); // nur dies aufrufen, wenn nicht links rechts gleichzeitig gehalten wird } + +#endif } void Petrack::createActions() @@ -3455,12 +3464,13 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n #endif if (borderChanged) updateControlImage(mImgFiltered); - +#ifndef STEREO_DISABLED if (imageChanged || swapChanged || brightContrastChanged || borderChanged || calibChanged) { if (mStereoContext) mStereoContext->init(mImgFiltered); } +#endif #ifdef TIME_MEASUREMENT // "==========: " @@ -3513,6 +3523,7 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n } else { +#ifndef STEREO_DISABLED // calculate position in 3D space and height of person for "old" trackPoints, if checked "even" if (mStereoContext && mStereoWidget->stereoUseForHeightEver->isChecked() && mStereoWidget->stereoUseForHeight->isChecked()) { @@ -3521,6 +3532,7 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n mTracker->calcPosition(frameNum); } +#endif } if (borderChanged) borderChangedForTracking = true; @@ -3544,10 +3556,11 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n mTrackingRoiItem->checkRect(); } +#ifndef STEREO_DISABLED // buildt disparity picture if it should be used for height detection if (mStereoContext && mStereoWidget->stereoUseForHeight->isChecked()) mStereoContext->getDisparity(); - +#endif Rect rect; getRoi(mImgFiltered, roi, rect); @@ -3584,10 +3597,11 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n ((lastRecoFrame-mControlWidget->recoStep->value()) >= frameNum)) && imageChanged) || mAnimation->isCameraLiveStream() || swapChanged || brightContrastChanged || borderChanged || calibChanged || recognitionChanged()) { +#ifndef STEREO_DISABLED // buildt disparity picture if it should be used for height detection or recognition if (mStereoContext && (mStereoWidget->stereoUseForHeight->isChecked() || mStereoWidget->stereoUseForReco->isChecked())) mStereoContext->getDisparity(); // wird nicht neu berechnet, wenn vor tracking schon berechnet wurde - +#endif if (borderChanged) mRecognitionRoiItem->checkRect(); //#cvReleaseImage(&tempImg); @@ -3621,11 +3635,13 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n // cout << persList.at(i) << endl; // } } +#ifndef STEREO_DISABLED if (mStereoContext && mStereoWidget->stereoUseForReco->isChecked()) { PersonList pl; pl.calcPersonPos(mImgFiltered, rect, persList, mStereoContext, getBackgroundFilter(), markerLess); } +#endif #ifdef TIME_MEASUREMENT // "==========: " debout << "nach reco: " << getElapsedTime() <<endl; diff --git a/src/recognition.cpp b/src/recognition.cpp index ff2cbf4ef12d1e35d6cc4c7815490db67c893b8c..883403dd49a3b4b3c6f073659435f429fd14f5c4 100644 --- a/src/recognition.cpp +++ b/src/recognition.cpp @@ -1,7 +1,8 @@ #include <QPointF> #include <QRect> - +#if not CV_MAJOR_VERION == 4 #include <cv.h> +#endif #include <opencv.hpp> #include <opencv2/aruco.hpp> @@ -31,6 +32,8 @@ #include "tracker.h" #include "control.h" +using namespace::cv; + //#include "Psapi.h" //#define WITH_RECT @@ -73,7 +76,7 @@ void thresholdHSV (const Mat &src, Mat &bin, const ColorParameters ¶m) // cvCvtColor(srcIpl ,hsvIpl, CV_BGR2HSV); // convert to HSV color space - cvtColor(src, hsv, CV_BGR2HSV); + cvtColor(src, hsv, COLOR_BGR2HSV); // unsigned char* dataImg = ((unsigned char*) hsvIpl->imageData); // unsigned char* yDataImg = dataImg; @@ -121,12 +124,14 @@ void thresholdHSV (const Mat &src, Mat &bin, const ColorParameters ¶m) // cvReleaseImage(&hsvIpl); } +#ifndef STEREO_DISABLED void thresholdHSV (const IplImage *srcIpl, IplImage *binIpl, const ColorParameters ¶m) { const Mat src = cvarrToMat(srcIpl); Mat bin = cvarrToMat(binIpl); thresholdHSV(src,bin,param); } +#endif void setColorParameter(const QColor &fromColor, const QColor &toColor, bool inversHue, ColorParameters ¶m) @@ -280,7 +285,7 @@ void findMultiColorMarker(Mat &img, QList<TrackPoint> *crossList, Control *contr int threshold; #if CV_MAJOR_VERSION == 2 CvBox2D32f subBox; -#elif CV_MAJOR_VERSION == 3 +#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 RotatedRect subBox; #endif @@ -359,7 +364,7 @@ void findMultiColorMarker(Mat &img, QList<TrackPoint> *crossList, Control *contr // IplImage *clone = cvCloneImage(binary); // clone, da binary sonst veraendert wird // Mat clone(binary); // storage = cvCreateMemStorage(0); - cv::findContours(clone,contours,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_SIMPLE); + cv::findContours(clone,contours,cv::RETR_EXTERNAL,cv::CHAIN_APPROX_SIMPLE); // cvFindContours(clone, storage, &contour, sizeof(CvContour), CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE); // clone wird auch veraendert!!! // findContours(clone,contours,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_SIMPLE); // firstContour = contour; @@ -613,11 +618,11 @@ void findMultiColorMarker(Mat &img, QList<TrackPoint> *crossList, Control *contr //for (threshold = 40; threshold < 251 ; threshold += 30) // 40, 70, 100, 130, 160, 190, 220, 250 for (threshold = 5; threshold < maxThreshold; threshold += step) // col.value() { - cv::threshold(subGray,subBW,threshold,255,CV_THRESH_BINARY); + cv::threshold(subGray,subBW,threshold,255,cv::THRESH_BINARY); // cvThreshold(subGray, subBW, threshold, 255, CV_THRESH_BINARY); // find contours and store them all as a list - cv::findContours(subBW,subContours,CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE); + cv::findContours(subBW,subContours,cv::RETR_LIST,cv::CHAIN_APPROX_SIMPLE); // cvFindContours(subBW, subStorage, &subFirstContour, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE); // gray wird auch veraendert!!! // test each contour @@ -861,7 +866,7 @@ void findColorMarker(Mat &img, QList<TrackPoint> *crossList, Control *controlWid // IplImage *clone = cvCloneImage(binary); // clone, da binary sonst veraendert wird Mat clone = binary.clone();//(cvarrToMat(binary),true); - cv::findContours(clone,contours,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_SIMPLE); + cv::findContours(clone,contours,cv::RETR_EXTERNAL,cv::CHAIN_APPROX_SIMPLE); // cvFindContours(clone, storage, &contour, sizeof(CvContour), // CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE); // clone wird auch veraendert!!! @@ -1057,7 +1062,12 @@ void findCodeMarker(Mat &img, QList<TrackPoint> *crossList, Control *controlWidg detectorParams->minCornerDistanceRate = minCornerDistanceRate; detectorParams->minDistanceToBorder = codeMarkerWidget->minDistanceToBorder->value(); detectorParams->minMarkerDistanceRate = minMarkerDistanceRate; - detectorParams->doCornerRefinement = codeMarkerWidget->doCornerRefinement->isChecked(); + // No refinement is default value + // TODO Check if this is the best MEthod for our usecase + if(codeMarkerWidget->doCornerRefinement->isChecked()){ + detectorParams->cornerRefinementMethod = cv::aruco::CornerRefineMethod::CORNER_REFINE_CONTOUR; + } + //detectorParams->cornerRefinementMethod = codeMarkerWidget->doCornerRefinement->isChecked(); detectorParams->cornerRefinementWinSize = codeMarkerWidget->cornerRefinementWinSize->value(); detectorParams->cornerRefinementMaxIterations = codeMarkerWidget->cornerRefinementMaxIterations->value(); detectorParams->cornerRefinementMinAccuracy = codeMarkerWidget->cornerRefinementMinAccuracy->value(); @@ -1166,7 +1176,7 @@ void findContourMarker(Mat &img, QList<TrackPoint> *crossList, int markerBrightn #if CV_MAJOR_VERSION == 2 CvPoint2D32f* PointArray2D32f; CvBox2D32f box; -#elif CV_MAJOR_VERSION == 3 +#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 // Mat PointArray2D32f; RotatedRect box; //CvBox2D box; @@ -1206,7 +1216,7 @@ void findContourMarker(Mat &img, QList<TrackPoint> *crossList, int markerBrightn // greyData = (yGreyData += tgray->widthStep); // because sometimes widthStep != width // // } - cvtColor(img,tgray,CV_RGB2GRAY); + cvtColor(img,tgray,COLOR_RGB2GRAY); // cvCvtColor(img, tgray, CV_RGB2GRAY); } //debout << "Threshold" << endl; @@ -1266,11 +1276,11 @@ namedWindow("img", CV_WINDOW_AUTOSIZE); // 0 wenn skalierbar sein soll // data = (yData += gray->widthStep); // because sometimes widthStep != width // greyData = (yGreyData += tgray->widthStep); // because sometimes widthStep != width // } - cv::threshold(tgray,gray,threshold, 255, CV_THRESH_BINARY); + cv::threshold(tgray,gray,threshold, 255, cv::THRESH_BINARY); // cvThreshold(tgray, gray, threshold, 255, CV_THRESH_BINARY); } else if (img.channels() == 1) - cv::threshold(img,gray,threshold,255, CV_THRESH_BINARY);//cvThreshold(img, gray, threshold, 255, CV_THRESH_BINARY); + cv::threshold(img,gray,threshold,255, cv::THRESH_BINARY);//cvThreshold(img, gray, threshold, 255, CV_THRESH_BINARY); else debout << "Error: Wrong number of channels: " << img.channels() <<endl; grayFix = gray.clone();// = cvCloneImage(gray); // make a copy @@ -1285,7 +1295,7 @@ namedWindow("img", CV_WINDOW_AUTOSIZE); // 0 wenn skalierbar sein soll #endif // find contours and store them all as a list //#if CV_MAJOR_VERSION == 2 - findContours(gray,contours,CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE); + findContours(gray,contours,cv::RETR_LIST,cv::CHAIN_APPROX_SIMPLE); // cvFindContours(gray, storage, &firstContour, sizeof(CvContour), // CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE); // gray wird auch veraendert!!! // contours = firstContour; @@ -1374,7 +1384,7 @@ cvWaitKey(); // Fits ellipse to current contour. //debout << "count: " << count << endl; cvFitEllipse(PointArray2D32f, count, &box); -#elif CV_MAJOR_VERSION == 3 +#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 // PointArray2D32f.create(count,2, CV_32F); // //Mat(cvarrToMat(contours)).convertTo(PointArray2D32f.at(i), CV_32F); diff --git a/src/recognitionRoiItem.cpp b/src/recognitionRoiItem.cpp index 710cc9acdc62cdda2fba86e6f82c1521ed627eea..cb03450e31c2a1d0acbdfacd18744c1f5598821a 100644 --- a/src/recognitionRoiItem.cpp +++ b/src/recognitionRoiItem.cpp @@ -247,7 +247,7 @@ void RecognitionRoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) // check rect because bordersize changes and without mouse event nothing changes the rect void RecognitionRoiItem::checkRect() { - Mat img = mMainWindow->getImageFiltered(); + cv::Mat img = mMainWindow->getImageFiltered(); // nicht QImage *img = mMainWindow->getImage(); da groesse noch nicht angepasst if (!img.empty()) { diff --git a/src/stereoAviFile.cpp b/src/stereoAviFile.cpp index 94a5ede51a82cae4500ff817f9298bf039230510..5af0ac5a0fe51bc9a8978f0f88e8eb96673faf81 100644 --- a/src/stereoAviFile.cpp +++ b/src/stereoAviFile.cpp @@ -1,3 +1,4 @@ +#ifndef STEREO_DISABLED #include <stdio.h> //============================================================================= @@ -161,3 +162,4 @@ void StereoAviFile::setCamera(enum Camera c) // } } +#endif diff --git a/src/stereoContext.cpp b/src/stereoContext.cpp index d83e0c79b7637fab931a2e4d6d88415ba1a5ee93..e726bdd9f8e81649f9c9f0db9a94c18d3dd2a9c3 100644 --- a/src/stereoContext.cpp +++ b/src/stereoContext.cpp @@ -31,6 +31,8 @@ #endif +using namespace::cv; + //#define TIME_MEASUREMENT pet::StereoContext::StereoContext(Petrack* main) @@ -148,13 +150,13 @@ pet::StereoContext::StereoContext(Petrack* main) #endif mMin = USHRT_MAX; mMax = 0; - +#ifndef STEREO_DISABLED mBMState = NULL; #if CV_MAJOR_VERSION == 2 mSgbm = NULL; #endif mBMdisparity16 = NULL; - +#endif // unsigned char value; // triclopsGetSurfaceValidationMapping(mTriclopsContext, &value); // debout << (int) value <<endl; @@ -183,6 +185,7 @@ pet::StereoContext::~StereoContext() //delete [] m_pTempBuffer; } +#ifndef STEREO_DISABLED // wenn viewImg NULL dann werden die nativ eingelesenen stereobilder genommen // default: IplImage *viewImg = NULL void pet::StereoContext::init(Mat &viewImg) // = NULL @@ -886,7 +889,7 @@ IplImage *pet::StereoContext::getDisparity(bool *dispNew) mSgbm->speckleWindowSize = 3; mSgbm->speckleRange = 3; mSgbm->disp12MaxDiff = 1; -#elif CV_MAJOR_VERSION == 3 +#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 int SADWindowSize = 11; int nDisparities = ( mMain->getStereoWidget()->maxDisparity->value() - mMain->getStereoWidget()->minDisparity->value() ) / 16; //mSgbm = StereoSGBM::create(nDisparities, SADWindowSize); @@ -915,7 +918,7 @@ IplImage *pet::StereoContext::getDisparity(bool *dispNew) cv::Mat ML(getRectified(cameraLeft)); cv::Mat MD(mBMdisparity16); (*mSgbm)(MR, ML, MD); -#elif CV_MAJOR_VERSION == 3 +#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 cv::Mat MR(cvarrToMat(getRectified(cameraRight))); cv::Mat ML(cvarrToMat(getRectified(cameraLeft))); @@ -946,7 +949,7 @@ IplImage *pet::StereoContext::getDisparity(bool *dispNew) (-*data16 > (mMain->getStereoWidget()->maxDisparity->value())*16) || // laesst nur den Teil ueber, der in gui eingestellt wurde #if CV_MAJOR_VERSION == 2 (*data16 <= (mSgbm->minDisparity)*16))// enthaelt auch: (*data16 == (mBMState->minDisparity-1)*16)) // marker fuer nicht berechneten wert -#elif CV_MAJOR_VERSION == 3 +#elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4 (*data16 <= (-(mMain->getStereoWidget()->maxDisparity->value())+1)*16)) #endif { @@ -1647,3 +1650,5 @@ bool pet::StereoContext::exportPointCloud(QString dest) //default = "" return false; } } + +#endif diff --git a/src/stereoItem.cpp b/src/stereoItem.cpp index 445dcf81308deba7c5ab927fb4f249a6b7dc2369..212d5aca213259b08561b4abf4f03677520dab8e 100644 --- a/src/stereoItem.cpp +++ b/src/stereoItem.cpp @@ -22,6 +22,8 @@ StereoItem::StereoItem(QWidget *wParent, QGraphicsItem * parent) // einzig move koennte interessant sein, um grid zu verschieben?! // setAcceptsHoverEvents(true); } + + // // bounding box wird durch linke obere ecke und breite/hoehe angegeben // // wenn an den rand gescrollt wurde im view, dann wird durch das dynamische anpassen // // bei trans und scale zwar zuerst alles neu gezeichnet durch update, @@ -78,6 +80,7 @@ void StereoItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) if (mMainWindow->getStereoContext()) { + #ifndef STEREO_DISABLED static int lastX = -1, lastY = -1; QPointF pos = event->scenePos(); pos.setX(pos.x() + mMainWindow->getImageBorderSize()); @@ -98,6 +101,7 @@ void StereoItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) //debout <<lastX<<" "<< lastY<<" "<< x << " " << y << " " << z << endl; } +#endif } // ACHTUNG: border nicht beachtet!!! @@ -118,8 +122,10 @@ void StereoItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) QGraphicsItem::hoverMoveEvent(event); } +#ifndef STEREO_DISABLED void StereoItem::updateData(IplImage *disp) { + if (disp != NULL) { if ((mImage != NULL) && ((mImage->width() != disp->width) || (mImage->height() != disp->height))) @@ -182,9 +188,11 @@ void StereoItem::updateData(IplImage *disp) } } } +#endif void StereoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { +#ifndef STEREO_DISABLED IplImage *disp = NULL; bool mDispNewWhilePainting; @@ -204,9 +212,11 @@ void StereoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option mDispNew = false; } +#endif } void StereoItem::setDispNew(bool d) // default: d = true { mDispNew = d; } + diff --git a/src/swapFilter.cpp b/src/swapFilter.cpp index d6acd38d96abb559a597d92a9c6f8cd3d9acade1..f2bedbd5ce10d0ebe2c2d9498017dd9147cbc370 100644 --- a/src/swapFilter.cpp +++ b/src/swapFilter.cpp @@ -1,6 +1,8 @@ #include "swapFilter.h" #include "helper.h" +using namespace::cv; + SwapFilter::SwapFilter() :Filter() { diff --git a/src/tracker.cpp b/src/tracker.cpp index f70f58e3bf23f2014872f7e250f1fe955ca0537c..315a9b04923eae626b65f0d5f2e1e36fc27de5dd 100644 --- a/src/tracker.cpp +++ b/src/tracker.cpp @@ -1,4 +1,9 @@ +#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> @@ -11,6 +16,7 @@ #include "stereoWidget.h" #include "multiColorMarkerWidget.h" +using namespace::cv; // Measure Time spending in functions //#define TIME_MEASUREMENT @@ -1009,6 +1015,7 @@ int Tracker::calcPosition(int frame) if (sc) { +#ifndef STEREO_DISABLED // for every point of a person, which has already identified at this frame for (int i = 0; i < size(); ++i) // ueber TrackPerson { @@ -1036,6 +1043,7 @@ int Tracker::calcPosition(int frame) //if (notFoundDisp>0) // Meldung zu haeufig // debout << "Warning: No disparity information found for " << (100.*notFoundDisp)/anz << " percent of points." << endl; return anz; +#endif } else return -1; @@ -1052,6 +1060,7 @@ bool Tracker::addPoint(TrackPoint &p, int frame, QSet<int> onlyVisible, int *per float scaleHead; float dist, minDist = 1000000.; +#ifndef STEREO_DISABLED // ACHTUNG: BORDER NICHT BEACHTET bei p.x()... // hier wird farbe nur bei reco bestimmt gegebenfalls auch beim tracken interessant // calculate height with disparity map @@ -1066,7 +1075,7 @@ bool Tracker::addPoint(TrackPoint &p, int frame, QSet<int> onlyVisible, int *per //if (i == 10) // debout << i << " " << mMainWindow->getControlWidget()->coordAltitude->value() - z << " " << z << " " << (*this)[i].height() << endl; } - +#endif // skalierungsfaktor fuer kopfgroesse // fuer multicolor marker groesser, da der schwarze punkt weit am rand liegen kann bool multiColorWithDot = false; @@ -1331,6 +1340,7 @@ int Tracker::insertFeaturePoints(int frame, int count, Mat &img, int borderSize, // set position relative to original image size v += borderSize2F; +#ifndef STEREO_DISABLED // ACHTUNG: BORDER NICHT BEACHTET bei p.x()... // calculate height with disparity map if (mMainWindow->getStereoContext() && mMainWindow->getStereoWidget()->stereoUseForHeight->isChecked()) @@ -1341,6 +1351,7 @@ int Tracker::insertFeaturePoints(int frame, int count, Mat &img, int borderSize, } //(*this)[i].setHeight(z, mMainWindow->getControlWidget()->coordAltitude->value(), frame); } +#endif // // wenn bei punkten, die nicht am rand liegen, der fehler gross ist, // // wird geguckt, ob der sprung sich zur vorherigen richtung stark veraendert hat @@ -1497,7 +1508,7 @@ int Tracker::track(Mat &img,Rect &rect, int frame, bool reTrack, int reQual, int //if (mGrey) debout << "mGrey: " << mGrey << " " << (void *) mGrey->imageData<<endl; //if (img) debout << "img: " << img << " " << (void *) img->imageData<<endl; // cvCvtColor(img, mGrey, CV_BGR2GRAY); - cvtColor(img,mGrey,CV_BGR2GRAY); + cvtColor(img,mGrey,COLOR_BGR2GRAY); } else if (img.channels() == 1) img.copyTo(mGrey);//cvCopy(img, mGrey); //mGrey = cvCloneImage(img); // es waere auch denkbar, dass gar nicht kopiert wird, sondern mit mGrey=img gearbeitet wird, nur bei obigen fkt muesste bei release etc aufgepasst werden diff --git a/src/trackerItem.cpp b/src/trackerItem.cpp index 6717fd1810c48708ba638b44abdf6f338c01162f..834c9e5fafe26c83dcc7008704611a932be75d23 100644 --- a/src/trackerItem.cpp +++ b/src/trackerItem.cpp @@ -8,6 +8,8 @@ #include "tracker.h" #include "animation.h" +using namespace::cv; + // in x und y gleichermassen skaliertes koordinatensystem, // da von einer vorherigen intrinsischen kamerakalibrierung ausgegenagen wird, // so dass pixel quadratisch diff --git a/src/trackingRoiItem.cpp b/src/trackingRoiItem.cpp index 11c02b8f20ad6fa0d7066c823ae67c8e224f4a7d..6a0a8de7b24754919456f026777140b92a7246d4 100644 --- a/src/trackingRoiItem.cpp +++ b/src/trackingRoiItem.cpp @@ -5,6 +5,8 @@ #include "view.h" #include "trackingRoiItem.h" +using namespace::cv; + TrackingRoiItem::TrackingRoiItem(QWidget *wParent, QGraphicsItem *parent) : QGraphicsRectItem(parent) { diff --git a/src/vector.cpp b/src/vector.cpp index a8c077e4bec0f8f4cbe2ac89ee157166f2f60f4c..d483daa14c1f1cdb31b26bf38cfac4c83e3fc38c 100644 --- a/src/vector.cpp +++ b/src/vector.cpp @@ -1,4 +1,9 @@ +#ifndef STEREO_DISABLED #include "cxcore.h" +#else +#include "opencv.hpp" +#endif + #include <QPointF> #include <QPoint>