Skip to content
Snippets Groups Projects
Commit 6270dbb0 authored by d.kilic's avatar d.kilic
Browse files

Added Macro to disable Stereo and upgraded to OpenCV4.

Ref #1
parent 78a53ad8
No related branches found
No related tags found
No related merge requests found
Showing
with 86 additions and 32 deletions
...@@ -23,8 +23,12 @@ they can be represented in QT. ...@@ -23,8 +23,12 @@ they can be represented in QT.
#include <QStringList> #include <QStringList>
#include <QTime> #include <QTime>
#ifndef STEREO_DISABLED
#include "opencv/cv.h" #include "opencv/cv.h"
#include "opencv/highgui.h" #include "opencv/highgui.h"
#else
#include "opencv.hpp"
#endif
#include "filter.h" #include "filter.h"
#include "helper.h" #include "helper.h"
...@@ -123,20 +127,24 @@ public: ...@@ -123,20 +127,24 @@ public:
bool isImageSequence(); bool isImageSequence();
bool isCameraLiveStream(); bool isCameraLiveStream();
#ifndef STEREO_DISABLED
enum Camera getCamera(); enum Camera getCamera();
void setCamera(enum Camera); void setCamera(enum Camera);
#endif
int getFirstFrameSec(); int getFirstFrameSec();
int getFirstFrameMicroSec(); int getFirstFrameMicroSec();
QString getFileBase(); QString getFileBase();
QFileInfo getFileInfo(); QFileInfo getFileInfo();
#ifndef STEREO_DISABLED
// used to get access of both frames only with calibStereoFilter // used to get access of both frames only with calibStereoFilter
#ifdef STEREO #ifdef STEREO
PgrAviFile *getCaptureStereo(); PgrAviFile *getCaptureStereo();
#else #else
StereoAviFile *getCaptureStereo(); StereoAviFile *getCaptureStereo();
#endif #endif
#endif
private: private:
...@@ -149,9 +157,11 @@ private: ...@@ -149,9 +157,11 @@ private:
// Indicate if the current animation is a video or a photo or a stereo video // Indicate if the current animation is a video or a photo or a stereo video
bool mVideo, mImgSeq, mStereo, mCameraLiveStream; bool mVideo, mImgSeq, mStereo, mCameraLiveStream;
#ifndef STEREO_DISABLED
// indicates which camera is used for stereo video // indicates which camera is used for stereo video
enum Camera mCamera; enum Camera mCamera;
#endif
// Pointer that will be used by the animation and that will be returned in the public functions // Pointer that will be used by the animation and that will be returned in the public functions
// IplImage *mImage; // IplImage *mImage;
cv::Mat mImage; cv::Mat mImage;
...@@ -224,7 +234,9 @@ private: ...@@ -224,7 +234,9 @@ private:
// Opens an animation from a sequence of stereo video files // Opens an animation from a sequence of stereo video files
// fileNumber indicates the number of the successive files splited while writing // fileNumber indicates the number of the successive files splited while writing
// nur bei einer ganz neuen sequenz ist stereoImgBuffer != 0 // nur bei einer ganz neuen sequenz ist stereoImgBuffer != 0
#ifndef STEREO_DISABLED
bool openAnimationStereoVideo(int fileNumber, IplImage* stereoImgLeft, IplImage* stereoImgRight); bool openAnimationStereoVideo(int fileNumber, IplImage* stereoImgLeft, IplImage* stereoImgRight);
#endif
bool openAnimationStereoVideo(int fileNumber, cv::Mat &stereoImgLeft, cv::Mat &stereoImgRight); bool openAnimationStereoVideo(int fileNumber, cv::Mat &stereoImgLeft, cv::Mat &stereoImgRight);
// like above for the first time with new filename // like above for the first time with new filename
...@@ -251,11 +263,12 @@ private: ...@@ -251,11 +263,12 @@ private:
#if CV_MAJOR_VERSION == 2 #if CV_MAJOR_VERSION == 2
// Capture structure from OpenCV 2 // Capture structure from OpenCV 2
CvCapture *mCapture; CvCapture *mCapture;
#elif CV_MAJOR_VERSION == 3 #else
// Capture structure from OpenCV 3 // Capture structure from OpenCV 3/4
cv::VideoCapture mVideoCapture; cv::VideoCapture mVideoCapture;
#endif #endif
#ifndef STEREO_DISABLED
// Capture structure from pgrAviFile for Stereo Videos // Capture structure from pgrAviFile for Stereo Videos
#ifdef STEREO #ifdef STEREO
PgrAviFile *mCaptureStereo; PgrAviFile *mCaptureStereo;
...@@ -271,7 +284,7 @@ private: ...@@ -271,7 +284,7 @@ private:
// A list with all the filenames of the stereo video series // A list with all the filenames of the stereo video series
QStringList mStereoVideoFilesList; QStringList mStereoVideoFilesList;
#endif
}; };
#endif #endif
...@@ -3,8 +3,12 @@ ...@@ -3,8 +3,12 @@
#include "filter.h" #include "filter.h"
#ifndef STEREO_DISABLED
#include "cvaux.h" #include "cvaux.h"
#include "opencv/cvaux.h" #include "opencv/cvaux.h"
#else
#include "opencv2/opencv.hpp"
#endif
#include "opencv2/video/background_segm.hpp" #include "opencv2/video/background_segm.hpp"
...@@ -20,7 +24,7 @@ class BackgroundFilter : public Filter ...@@ -20,7 +24,7 @@ class BackgroundFilter : public Filter
private: private:
#if CV_MAJOR_VERSION == 2 #if CV_MAJOR_VERSION == 2
CvBGStatModel* mBgModel; CvBGStatModel* mBgModel;
#elif CV_MAJOR_VERSION == 3 #elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4
cv::Ptr<cv::BackgroundSubtractorMOG2> mBgModel; cv::Ptr<cv::BackgroundSubtractorMOG2> mBgModel;
//Ptr<BackgroundSubtractor> mBgModel; //Ptr<BackgroundSubtractor> mBgModel;
#endif #endif
......
...@@ -2,7 +2,11 @@ ...@@ -2,7 +2,11 @@
#define BLURFILTER_H #define BLURFILTER_H
#include "filter.h" #include "filter.h"
#if not CV_MAJOR_VERSION == 4
#include "cv.h" #include "cv.h"
#else
#include "opencv.hpp"
#endif
class BlurFilter : public Filter class BlurFilter : public Filter
{ {
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "filter.h" #include "filter.h"
using namespace::cv;
class BorderFilter : public Filter class BorderFilter : public Filter
{ {
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "filter.h" #include "filter.h"
#include "helper.h" #include "helper.h"
using namespace::cv;
class BrightContrastFilter : public Filter class BrightContrastFilter : public Filter
{ {
......
...@@ -10,8 +10,9 @@ private: ...@@ -10,8 +10,9 @@ private:
public: public:
BrightFilter(); BrightFilter();
#ifndef STEREO_DISABLED
IplImage* act(IplImage *img, IplImage *res); IplImage* act(IplImage *img, IplImage *res);
#endif
// bool changed(); // bool changed();
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "filter.h" #include "filter.h"
using namespace::cv;
class CalibFilter : public Filter class CalibFilter : public Filter
{ {
......
...@@ -16,7 +16,7 @@ private: ...@@ -16,7 +16,7 @@ private:
// QImage *mImage; // QImage *mImage;
vector<int> mIds; vector<int> mIds;
vector<vector<Point2f> > mCorners, mRejected; vector<vector<cv::Point2f> > mCorners, mRejected;
Vec2F mUlc; // upper left corner to draw Vec2F mUlc; // upper left corner to draw
public: public:
...@@ -24,8 +24,8 @@ public: ...@@ -24,8 +24,8 @@ public:
QRectF boundingRect() const; QRectF boundingRect() const;
void setRect(Vec2F& v); void setRect(Vec2F& v);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void setDetectedMarkers(vector<vector<Point2f> > corners, vector<int> ids); void setDetectedMarkers(vector<vector<cv::Point2f> > corners, vector<int> ids);
void setRejectedMarkers(vector<vector<Point2f> > rejected); void setRejectedMarkers(vector<vector<cv::Point2f> > rejected);
}; };
#endif #endif
...@@ -11,8 +11,9 @@ private: ...@@ -11,8 +11,9 @@ private:
public: public:
ContrastFilter(); ContrastFilter();
#ifndef STEREO_DISABLED
IplImage* act(IplImage *img, IplImage *res); IplImage* act(IplImage *img, IplImage *res);
#endif
// bool changed(); // bool changed();
......
#ifndef ELLIPSE_H #ifndef ELLIPSE_H
#define ELLIPSE_H #define ELLIPSE_H
#ifndef STEREO_DISABLED
#include <cxcore.h> #include <cxcore.h>
#else
#include "opencv.hpp"
#endif
#include "vector.h" #include "vector.h"
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#define EXTRCALIBRATION_H #define EXTRCALIBRATION_H
#include <iostream> #include <iostream>
#include <vector>
#include <QString>
#include <QVector>
//#include <opencv.hpp> //#include <opencv.hpp>
...@@ -12,17 +16,16 @@ ...@@ -12,17 +16,16 @@
#include <opencv.hpp> #include <opencv.hpp>
#ifndef STEREO_DISABLED
#include "cxcore.h" #include "cxcore.h"
#include "cvaux.h" #include "cvaux.h"
#endif
#include "opencv.hpp" #include "opencv.hpp"
class Petrack; class Petrack;
class Control; class Control;
using namespace cv;
using namespace std;
class ExtrCalibration class ExtrCalibration
{ {
...@@ -30,8 +33,8 @@ private: ...@@ -30,8 +33,8 @@ private:
Petrack *mMainWindow; Petrack *mMainWindow;
Control *mControlWidget; Control *mControlWidget;
vector<Point3f> points3D; std::vector<cv::Point3f> points3D;
vector<Point2f> points2D; std::vector<cv::Point2f> points2D;
// Mat mRotation; // Mat mRotation;
// Mat mTranslation; // Mat mTranslation;
...@@ -66,27 +69,27 @@ public: ...@@ -66,27 +69,27 @@ public:
bool fetch2DPoints(); bool fetch2DPoints();
void calibExtrParams(); void calibExtrParams();
bool calcReprojectionError(); bool calcReprojectionError();
Point2f getImagePoint(Point3f p3d); cv::Point2f getImagePoint(cv::Point3f p3d);
Point3f get3DPoint(Point2f p2d, double h); cv::Point3f get3DPoint(cv::Point2f p2d, double h);
Point3f transformRT(Point3f p); cv::Point3f transformRT(cv::Point3f p);
bool isOutsideImage(Point2f p2d); bool isOutsideImage(cv::Point2f p2d);
inline bool isOutsideImage(Point3f p3d) inline bool isOutsideImage(cv::Point3f p3d)
{ {
return isOutsideImage(getImagePoint(p3d)); return isOutsideImage(getImagePoint(p3d));
} }
inline vector<Point3f> get3DList() inline std::vector<cv::Point3f> get3DList()
{ {
return points3D; return points3D;
} }
inline void set3DList(vector<Point3f> list3D) inline void set3DList(std::vector<cv::Point3f> list3D)
{ {
this->points3D = list3D; this->points3D = list3D;
} }
inline vector<Point2f> get2DList() inline std::vector<cv::Point2f> get2DList()
{ {
return points2D; return points2D;
} }
inline void set2DList(vector<Point2f> list2D) inline void set2DList(std::vector<cv::Point2f> list2D)
{ {
this->points2D = list2D; this->points2D = list2D;
} }
......
#ifndef FILTER_H #ifndef FILTER_H
#define FILTER_H #define FILTER_H
#ifndef STEREO_DISABLED
#include "cv.h" #include "cv.h"
#include "opencv/cv.h" #include "opencv/cv.h"
#else
#include "opencv2/opencv.hpp"
#endif
class Filter; class Filter;
......
...@@ -31,7 +31,7 @@ public: ...@@ -31,7 +31,7 @@ public:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event);
// void hoverMoveEvent(QGraphicsSceneHoverEvent *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); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
}; };
......
...@@ -54,12 +54,16 @@ inline ostream& operator<<(ostream& s, const QString& t) ...@@ -54,12 +54,16 @@ inline ostream& operator<<(ostream& s, const QString& t)
// Static function that converts an iplImg in a qImg. // 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. // If the images are not the same size, a new qImg will be created with the same size as the iplImg.
#include <QImage> #include <QImage>
#ifndef STEREO_DISABLED
#include "cxcore.h" #include "cxcore.h"
void copyToQImage(QImage *qImg, IplImage *iplImg); // war static functin in animatioln class void copyToQImage(QImage *qImg, IplImage *iplImg); // war static functin in animatioln class
#endif
void copyToQImage(QImage *qImg, cv::Mat &img); void copyToQImage(QImage *qImg, cv::Mat &img);
#include <QLabel> #include <QLabel>
#ifndef STEREO_DISABLED
void showImg(QLabel *l, IplImage *i); void showImg(QLabel *l, IplImage *i);
#endif
cv::Mat getRoi(cv::Mat &img, const QRect &roi, cv::Rect &rect, bool evenPixelNumber = true); cv::Mat getRoi(cv::Mat &img, const QRect &roi, cv::Rect &rect, bool evenPixelNumber = true);
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "ellipse.h" #include "ellipse.h"
class TrackPoint; class TrackPoint;
class MarkerCasern class MarkerCasern
......
...@@ -6,8 +6,10 @@ ...@@ -6,8 +6,10 @@
#include <QKeyEvent> #include <QKeyEvent>
#include <QMouseEvent> #include <QMouseEvent>
#ifndef STEREO_DISABLED
#include "cvaux.h" #include "cvaux.h"
#include "cxcore.h" #include "cxcore.h"
#endif
#include <opencv.hpp> #include <opencv.hpp>
//#include "opencv2/cxcore.h" //#include "opencv2/cxcore.h"
...@@ -32,6 +34,10 @@ ...@@ -32,6 +34,10 @@
#include "animation.h" #include "animation.h"
#include "extrCalibration.h" #include "extrCalibration.h"
#ifdef STEREO_DISABLED
enum Camera {cameraLeft, cameraRight, cameraUnset};
#endif
#define HEAD_SIZE 21. // durchschnittliche Kopflaenge in cm (Kopf 21x14) #define HEAD_SIZE 21. // durchschnittliche Kopflaenge in cm (Kopf 21x14)
#define AXIS_MARKERS_LENGTH 10 #define AXIS_MARKERS_LENGTH 10
...@@ -159,7 +165,7 @@ public: ...@@ -159,7 +165,7 @@ public:
void playAll(); void playAll();
int winSize(QPointF *pos=NULL, int pers=-1, int frame=-1, int level=-1); int winSize(QPointF *pos=NULL, int pers=-1, int frame=-1, int level=-1);
void updateImage(bool imageChanged = false); void updateImage(bool imageChanged = false);
void updateImage(const Mat &img); void updateImage(const cv::Mat &img);
// void updateImage(IplImage *iplImg); // void updateImage(IplImage *iplImg);
void updateSequence(); void updateSequence();
// void calcBackground(); // void calcBackground();
......
...@@ -9,7 +9,11 @@ ...@@ -9,7 +9,11 @@
#else #else
#include "aviFileWriter.h" #include "aviFileWriter.h"
#endif #endif
#ifndef STEREO_DISABLED
#include "cv.h" #include "cv.h"
#else
#include "opencv.hpp"
#endif
class QLabel; class QLabel;
class QSlider; class QSlider;
......
#ifndef STEREO_DISABLED
#ifndef STEREOAVIFILE_H #ifndef STEREOAVIFILE_H
#define STEREOAVIFILE_H #define STEREOAVIFILE_H
#undef UNICODE #undef UNICODE
...@@ -117,3 +117,4 @@ private: ...@@ -117,3 +117,4 @@ private:
}; };
#endif // STEREOAVIFILE_H #endif // STEREOAVIFILE_H
#endif // STEREO_DISABLED
...@@ -41,10 +41,11 @@ public: ...@@ -41,10 +41,11 @@ public:
void init(cv::Mat &viewImg); void init(cv::Mat &viewImg);
void preprocess(); void preprocess();
#ifndef STEREO_DISABLED
IplImage *getRectified(enum Camera camera=cameraRight); IplImage *getRectified(enum Camera camera=cameraRight);
IplImage *getDisparity(bool *dispNew = NULL); IplImage *getDisparity(bool *dispNew = NULL);
#endif
// von person.cpp benoetigt, um frame nummer zu erhalten // von person.cpp benoetigt, um frame nummer zu erhalten
inline Animation *getAnimation() inline Animation *getAnimation()
...@@ -124,13 +125,16 @@ protected: ...@@ -124,13 +125,16 @@ protected:
#endif #endif
BackgroundFilter *mBackgroundFilterLeft; BackgroundFilter *mBackgroundFilterLeft;
BackgroundFilter *mBackgroundFilterRight; BackgroundFilter *mBackgroundFilterRight;
#ifndef STEREO_DISABLED
IplImage mRectLeft; IplImage mRectLeft;
IplImage mRectRight; IplImage mRectRight;
IplImage mDisparity; IplImage mDisparity;
CvStereoBMState *mBMState; CvStereoBMState *mBMState;
#endif
#if CV_MAJOR_VERSION == 2 #if CV_MAJOR_VERSION == 2
cv::StereoSGBM *mSgbm; cv::StereoSGBM *mSgbm;
#elif CV_MAJOR_VERSION == 3 #elif CV_MAJOR_VERSION == 3 || CV_MAJOR_VERSION == 4
cv::Ptr<cv::StereoSGBM> mSgbm; cv::Ptr<cv::StereoSGBM> mSgbm;
#endif #endif
CvMat *mBMdisparity16; CvMat *mBMdisparity16;
......
...@@ -19,7 +19,9 @@ public: ...@@ -19,7 +19,9 @@ public:
StereoItem(QWidget *wParent, QGraphicsItem * parent = NULL); StereoItem(QWidget *wParent, QGraphicsItem * parent = NULL);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void hoverMoveEvent(QGraphicsSceneHoverEvent *event); void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
#ifndef STEREO_DISABLED
void updateData(IplImage *disp); void updateData(IplImage *disp);
#endif
QRectF boundingRect() const; QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void setDispNew(bool d = true); void setDispNew(bool d = true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment