From 8f25a930c6ae673a163b0f18c8c82ab49aa9a311 Mon Sep 17 00:00:00 2001 From: "d.kilic" <d.kilic@fz-juelich.de> Date: Tue, 4 May 2021 12:59:46 +0000 Subject: [PATCH] Resolve "Remove commented code" --- include/analysePlot.h | 18 - include/animation.h | 41 +- include/autoCalib.h | 3 +- include/aviFileWriter.h | 6 - include/backgroundFilter.h | 1 - include/borderFilter.h | 1 - include/brightContrastFilter.h | 4 - include/calibStereoFilter.h | 1 - include/codeMarkerWidget.h | 7 - include/colorMarkerItem.h | 1 - include/colorMarkerWidget.h | 6 - include/colorPlot.h | 16 - include/colorRangeWidget.h | 4 - include/control.h | 18 - include/coordItem.h | 13 +- include/extrCalibration.h | 5 - include/filter.h | 6 - include/gridItem.h | 7 +- include/helper.h | 27 -- include/imageItem.h | 5 - include/logoItem.h | 4 - include/markerCasern.h | 1 - include/multiColorMarkerWidget.h | 11 - include/person.h | 3 - include/petrack.h | 41 +- include/player.h | 3 - include/recognitionRoiItem.h | 6 - include/stereoContext.h | 1 - include/stereoItem.h | 3 - include/swapFilter.h | 1 - include/tracker.h | 42 +- include/trackerItem.h | 3 - include/trackerReal.h | 110 ----- include/trackingRoiItem.h | 10 +- include/vector.h | 18 - include/view.h | 2 - src/analysePlot.cpp | 198 +------- src/animation.cpp | 313 +------------ src/autoCalib.cpp | 6 +- src/backgroundFilter.cpp | 364 +-------------- src/backgroundItem.cpp | 12 +- src/borderFilter.cpp | 93 +--- src/brightContrastFilter.cpp | 31 -- src/codeMarkerItem.cpp | 1 - src/codeMarkerWidget.cpp | 4 +- src/colorMarkerItem.cpp | 1 - src/colorMarkerWidget.cpp | 31 +- src/colorPlot.cpp | 317 +------------ src/colorRangeWidget.cpp | 32 +- src/control.cpp | 15 +- src/coordItem.cpp | 204 +-------- src/ellipse.cpp | 8 +- src/extrCalibration.cpp | 104 +---- src/filter.cpp | 24 +- src/gridItem.cpp | 144 +----- src/helper.cpp | 68 --- src/imageItem.cpp | 57 +-- src/logoItem.cpp | 38 -- src/main.cpp | 8 +- src/markerCasern.cpp | 207 +-------- src/markerHermes.cpp | 35 +- src/markerJapan.cpp | 63 +-- src/multiColorMarkerItem.cpp | 29 +- src/person.cpp | 2 - src/petrack.cpp | 748 +------------------------------ src/player.cpp | 37 +- src/recognition.cpp | 627 +------------------------- src/recognitionRoiItem.cpp | 43 +- src/stereoContext.cpp | 21 +- src/stereoItem.cpp | 53 +-- src/swapFilter.cpp | 98 ---- src/tracker.cpp | 238 +--------- src/trackerItem.cpp | 262 +---------- src/trackerReal.cpp | 116 ----- src/trackingRoiItem.cpp | 46 +- src/vector.cpp | 73 +-- src/view.cpp | 96 ---- 77 files changed, 215 insertions(+), 5101 deletions(-) diff --git a/include/analysePlot.h b/include/analysePlot.h index b68b5b234..8c3e861a2 100644 --- a/include/analysePlot.h +++ b/include/analysePlot.h @@ -44,13 +44,10 @@ public: void setPen(const QPen &pen); -// void setModel(int model, int x, int y); - void setTrackerReal(TrackerReal* trackerReal); private: TrackerReal *mTrackerReal; -// int mModel, mX, mY; QPen mPen; }; @@ -63,12 +60,8 @@ class AnalysePlot: public QwtPlot public: AnalysePlot(QWidget *parent = nullptr); - void setCursor(const QColor &col); - QPoint getPos(const QColor &col) const; -// double map(const QColor &col) const; - inline void setControlWidget(Control *control) { mControlWidget = control; @@ -87,7 +80,6 @@ public: } void setTrackerReal(TrackerReal* TR); void setScale(); -// void updateTracker(); inline double symbolSize() const { @@ -116,19 +108,9 @@ private: double mXMin, mXMax, mYMin, mYMax; Control *mControlWidget; TrackerReal *mTrackerReal; -// ImagePlotItem *mImageItem; TrackerRealPlotItem *mTrackerRealItem; -// RectPlotItem *mRectItem; -// ViewAnalysePlotItem *mViewAnalyseItem; QwtPlotZoomer *mZoomer; int mActFrame; }; -//#else // QWT nicht verfuegbar -//class AnalysePlot: public QWidget -//{ -// Q_OBJECT -//} -//#endif - #endif diff --git a/include/animation.h b/include/animation.h index 6713dbf54..9c1b83a4d 100644 --- a/include/animation.h +++ b/include/animation.h @@ -18,20 +18,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* - -Class Animation -First setup: Ricardo Martin Brualla, 01.02.2007 -Later: Maik Boltes - -This class will hold an animation in form of a video or a sequence of images. -In case of a video, you can only get the next frame. If it is a sequence of images, -you can select the frame you want to get. -Appart from that, there is a static function that converts IplImages to QPixmaps, so -they can be represented in QT. - -*/ - #ifndef ANIMATION_H #define ANIMATION_H @@ -73,25 +59,20 @@ public: Animation(QWidget *wParent); ~Animation(); - // Returns a pointer to the next frame of the animation -// IplImage* getNextFrame(); + // Returns the next frame of the animation cv::Mat getNextFrame(); - // Returns a pointer to the previous frame of the animation -// IplImage* getPreviousFrame(); + // Returns the previous frame of the animation cv::Mat getPreviousFrame(); - // Returns a pointer to the frame at the index index -// IplImage* getFrameAtIndex(int index); + // Returns the frame at the index index cv::Mat getFrameAtIndex(int index); - // Returns a pointer to the frame at the position position + // Returns the frame at the position position // positions is a double between 0 and 1 that indicates the position in the animation -// IplImage* getFrameAtPos(double position); cv::Mat getFrameAtPos(double position); - // Returns a pointer to the current frame -// IplImage* getCurrentFrame(); + // Returns the current frame cv::Mat getCurrentFrame(); void skipFrame(int num = 1); @@ -184,8 +165,7 @@ private: enum Camera mCamera; #endif - // Pointer that will be used by the animation and that will be returned in the public functions -// IplImage *mImage; + // Image that will be used by the animation and that will be returned in the public functions cv::Mat mImage; // Size of the frame @@ -226,8 +206,7 @@ private: bool openAnimationPhoto(QString fileName); // Implementation of getFrameAtIndex for photo series - // Returns a pointer to the frame at index index in the serie -// IplImage* getFramePhoto(int index); + // Returns the frame at index index in the serie cv::Mat getFramePhoto(int index); // Gets Size and Frame number information of the recently open animation @@ -267,8 +246,7 @@ private: bool openAnimationVideo(QString fileName); // Implementation of getFrameAtIndex for videos - // Returns a pointer to the frame at index index in the video -// IplImage* getFrameVideo(int index); + // Returns the frame at index index in the video cv::Mat getFrameVideo(int index); // Gets Size and Frame number information of the recently open animation @@ -293,9 +271,6 @@ private: StereoAviFile *mCaptureStereo; #endif // stereo image allocated in animation to use space for a sequence of stereo files -// IplImage* mStereoImgLeft; -// IplImage* mStereoImgRight; - cv::Mat mStereoImgLeft; cv::Mat mStereoImgRight; diff --git a/include/autoCalib.h b/include/autoCalib.h index c9a103cd1..582ffea34 100644 --- a/include/autoCalib.h +++ b/include/autoCalib.h @@ -84,8 +84,7 @@ public: private: int runCalibration(std::vector<std::vector<cv::Point2f> > corners, cv::Size img_size, cv::Size board_size, float square_size, float aspect_ratio, int flags, - cv::Mat &camera_matrix, cv::Mat &dist_coeffs, double *reproj_errs);//, Mat *extr_params);//, - // double &reproj_errs);//, double* avg_reproj_err); + cv::Mat &camera_matrix, cv::Mat &dist_coeffs, double *reproj_errs); Petrack *mMainWindow; Control *mControlWidget; diff --git a/include/aviFileWriter.h b/include/aviFileWriter.h index 131ddd07d..45d6bf2d0 100644 --- a/include/aviFileWriter.h +++ b/include/aviFileWriter.h @@ -27,14 +27,11 @@ // Byte Number (nicht alle Zahlen gehen?: 2*1280*960*32*20) enstehen avi mit einem bild // unter 2GB fuer reader und unter 4 GB fuer writer bleiben!!! -//#define AVI_FILE_SPLIT_SIZE ( (__int64)( 1024 * 1024 * 1024 ) ) -//#define AVI_FILE_SPLIT_SIZE ( (__int64)( 2*1280*960*32*20 ) ) #define AVI_FILE_SPLIT_SIZE ( ( 2*1280*960*32*20 ) ) // 2*1280*960*32*20 = 1,5 GB = 40 Sekunden = 640 Bilder /** * A simple wrapper for an .AVI file . - * */ class AviFileWriter { @@ -153,7 +150,6 @@ protected: std::string m_szAVIDestFile; char* m_fourCC; - //int m_fourCC; /** Defines is color avi */ bool m_isColor; @@ -168,8 +164,6 @@ private: /** Writes to the opened AVI-File */ cv::VideoWriter m_vWriter; - }; - #endif // #ifndef AVIFILEWRITER_H diff --git a/include/backgroundFilter.h b/include/backgroundFilter.h index 39055eef6..fb2c4a0d1 100644 --- a/include/backgroundFilter.h +++ b/include/backgroundFilter.h @@ -36,7 +36,6 @@ class BackgroundFilter : public Filter private: cv::Ptr<cv::BackgroundSubtractorMOG2> mBgModel; - //Ptr<BackgroundSubtractor> mBgModel; bool mUpdate; // if 0, kein update des models, sonst schon pet::StereoContext** mStereoContext; ///< zeiger auf den zeiger in petrack mit stereocontext diff --git a/include/borderFilter.h b/include/borderFilter.h index df70b0cad..d1dab6b90 100644 --- a/include/borderFilter.h +++ b/include/borderFilter.h @@ -34,7 +34,6 @@ private: public: BorderFilter(); -// IplImage* act(IplImage *img, IplImage *res); cv::Mat act(cv::Mat &img, cv::Mat &res); Parameter *getBorderSize(); diff --git a/include/brightContrastFilter.h b/include/brightContrastFilter.h index 8ce1a9894..8285df95c 100644 --- a/include/brightContrastFilter.h +++ b/include/brightContrastFilter.h @@ -31,13 +31,9 @@ private: Parameter mB; Parameter mC; -// uchar mLut[256]; -// CvMat* mLutMat; - public: BrightContrastFilter(); -// IplImage* act(IplImage *img, IplImage *res); cv::Mat act(cv::Mat &img, cv::Mat &res); Parameter *getBrightness(); diff --git a/include/calibStereoFilter.h b/include/calibStereoFilter.h index 0d50465c4..21d2088a2 100644 --- a/include/calibStereoFilter.h +++ b/include/calibStereoFilter.h @@ -32,7 +32,6 @@ private: public: CalibStereoFilter(); -// IplImage* act(IplImage *img, IplImage *res); cv::Mat act(cv::Mat &img, cv::Mat &res); void setStereoContext(pet::StereoContext* stereoContext); diff --git a/include/codeMarkerWidget.h b/include/codeMarkerWidget.h index 3b5d02d8e..6e1fad955 100644 --- a/include/codeMarkerWidget.h +++ b/include/codeMarkerWidget.h @@ -43,10 +43,6 @@ public: // read data from xml node void getXml(QDomElement &elem); -#if 0 // Maik temporaer, damit es auf dem Mac laeuft - aruco::Dictionary usedDictionary; - aruco::DetectorParameters detectParams; -#endif private slots: @@ -54,9 +50,6 @@ private slots: { mMainWindow->getCodeMarkerItem()->setVisible(i); -// mMainWindow->setRecognitionChanged(true);// flag indicates that changes of recognition parameters happens -// mMainWindow->getCodeMarkerItem()->setVisible(mMainWindow->getCodeMarkerWidget()->showDetectedCandidates->isChecked() || mMainWindow->getCodeMarkerWidget()->showMask->isChecked()); -// mMainWindow->getScene()->update(); if( !mMainWindow->isLoading() ) mMainWindow->getScene()->update(); } diff --git a/include/colorMarkerItem.h b/include/colorMarkerItem.h index 8b501a824..2bb7ef52e 100644 --- a/include/colorMarkerItem.h +++ b/include/colorMarkerItem.h @@ -34,7 +34,6 @@ class ColorMarkerItem : public QGraphicsItem private: Petrack *mMainWindow; QImage *mImage; -// IplImage *mMask; cv::Mat mMask; Vec2F mUlc; // upper left corner to draw diff --git a/include/colorMarkerWidget.h b/include/colorMarkerWidget.h index b79bd134a..a5c67e695 100644 --- a/include/colorMarkerWidget.h +++ b/include/colorMarkerWidget.h @@ -54,13 +54,7 @@ private slots: { mMainWindow->getColorMarkerItem()->setVisible(i); mMainWindow->getScene()->update(); - // mMainWindow->updateImage(); } -// void on_colorMarkerColor_currentIndexChanged(int i) -// { -// if (mMainWindow && (mMainWindow->getScene())) -// mMainWindow->getScene()->update(); -// } void on_maskMask_stateChanged(int /*i*/) { mMainWindow->getScene()->update(); diff --git a/include/colorPlot.h b/include/colorPlot.h index 6be2a9399..3b4120217 100644 --- a/include/colorPlot.h +++ b/include/colorPlot.h @@ -55,7 +55,6 @@ public: private: Tracker *mTracker; -// int mModel, mX, mY; QPen mPen; }; @@ -133,7 +132,6 @@ public: bool mColored; double mMapHeight; - // bool contains ( qreal x, qreal y ) const gibt zurueck, ob pkt x, y in rect liegt QColor mFromCol; QColor mToCol; bool mInversHue; @@ -201,7 +199,6 @@ public: void setControlWidget(Control *control); void setTracker(Tracker *tracker); void setScale(); -// void updateTracker(); void generateImage(); inline double symbolSize() const @@ -239,10 +236,6 @@ public: { return mRectItem; } -// inline ImagePlotItem *getImageItem() const -// { -// return mImageItem; -// } private: double mSymbolSize; @@ -255,15 +248,6 @@ private: ViewColorPlotItem *mViewColorItem; Zoomer *mZoomer; int mGreyDiff; -// QwtPlotCurve *mTpc; -// Tracker *mTracker; - -// public slots: -// void showContour(bool on); -// void showSpectrogram(bool on); - -// private: -// QwtPlotSpectrogram *d_spectrogram; }; #endif diff --git a/include/colorRangeWidget.h b/include/colorRangeWidget.h index 4f8af6024..9d096fbca 100644 --- a/include/colorRangeWidget.h +++ b/include/colorRangeWidget.h @@ -47,7 +47,6 @@ public: void setControlWidget(int toHue, int fromHue, int toSat, int fromSat); private slots: - // functions which force a new recognition void on_inversHue_stateChanged(int i); @@ -58,9 +57,6 @@ private slots: void on_toColor_clicked(); private: - - - Petrack *mMainWindow; ColorPlot *mColorPlot; }; diff --git a/include/control.h b/include/control.h index 875de3943..0327b73e4 100644 --- a/include/control.h +++ b/include/control.h @@ -27,7 +27,6 @@ #include "recognition.h" class Petrack; -//class Image; class QGraphicsScene; class QDomElement; @@ -227,13 +226,6 @@ public: } private slots: - //temp: -// void on_temp1_valueChanged(int i); -// void on_temp2_valueChanged(int i); -// void on_temp3_valueChanged(int i); -// void on_temp4_valueChanged(int i); -// void on_temp5_valueChanged(int i); - void on_anaCalculate_clicked(); void on_anaStep_valueChanged(int i); void on_anaMarkAct_stateChanged(int i); @@ -287,7 +279,6 @@ private slots: void on_trackShowSearchSize_stateChanged(int i); void on_trackShowOnlyVisible_stateChanged(int /*i*/) { if (!isLoading()) mScene->update(); } -// void on_trackShowOnlyNr_valueChanged(int i) { if (!isLoading()) mScene->update(); } void on_trackShowCurrentPoint_stateChanged(int /*i*/) { if (!isLoading()) mScene->update(); } void on_trackGotoNr_clicked(); void on_trackGotoStartNr_clicked(); @@ -324,14 +315,11 @@ private slots: void on_roiFix_stateChanged(int i); void on_filterBrightContrast_stateChanged(int i); -// void on_filterContrast_stateChanged(int i); void on_filterContrastParam_valueChanged(int i); -// void on_filterBright_stateChanged(int i); void on_filterBrightParam_valueChanged(int i); void on_filterBorder_stateChanged(int i); void on_filterBorderParamSize_valueChanged(int i); void on_filterBorderParamCol_clicked(); -// void on_filterBgCalc_clicked(); void on_filterBg_stateChanged(int i); void on_filterBgShow_stateChanged(int i); void on_filterBgUpdate_stateChanged(int i); @@ -352,10 +340,6 @@ private slots: void on_r6_valueChanged(double d); void on_tx_valueChanged(double d); void on_ty_valueChanged(double d); - /// Weitere Entzerrungsparameter fuer spaeter - //void on_k4_valueChanged(double d); - //void on_k5_valueChanged(double d); - //void on_k6_valueChanged(double d); void on_quadAspectRatio_stateChanged(int i); void on_fixCenter_stateChanged(int i); void on_tangDist_stateChanged(int i); @@ -430,8 +414,6 @@ private slots: void on_trackRoiFix_stateChanged(int arg1); - //void on_trackExport_released(); - private: Petrack *mMainWindow; QGraphicsScene *mScene; diff --git a/include/coordItem.h b/include/coordItem.h index 26707f719..b3ac2cace 100644 --- a/include/coordItem.h +++ b/include/coordItem.h @@ -35,35 +35,34 @@ private: Petrack *mMainWindow; ExtrCalibration *extCalib; Control *mControlWidget; - //QGraphicsScene *mScene; cv::Point2f ursprung, x, y, z; cv::Point2f calibPointsMin, calibPointsMax; cv::Point3f x3D, y3D, z3D; float mouse_x,mouse_y; int coordTrans_x,coordTrans_y; - //Dimension *coordDimension int coordDimension; public: - inline void setCoordDimension(int dim/*Dimension *cDimension*/) + inline void setCoordDimension(int dim) { this->coordDimension = dim; } - inline int /*Dimension*/ getCoordDimension() const + inline int getCoordDimension() const { return this->coordDimension; } // Constructor - CoordItem(QWidget *wParent/*, QGraphicsScene * scene*/, QGraphicsItem * parent = nullptr); - // mouseMoveEvent-Trigger + CoordItem(QWidget *wParent, QGraphicsItem * parent = nullptr); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event); - //void hoverMoveEvent(QGraphicsSceneHoverEvent *event); + // Update the transformation matrix void updateData(); + // defines the minimal rect which contains the coordinate system QRectF boundingRect() const; + // paint method to draw the perspectiv coordinate-system void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); }; diff --git a/include/extrCalibration.h b/include/extrCalibration.h index 9efb81973..0887e02fd 100644 --- a/include/extrCalibration.h +++ b/include/extrCalibration.h @@ -129,11 +129,6 @@ private: std::vector<cv::Point3f> points3D; std::vector<cv::Point2f> points2D; -// Mat mRotation; -// Mat mTranslation; -// Mat mCamera; -// Mat mDistCoeffs; - double *rotation_matrix; double *translation_vector; double *translation_vector2; diff --git a/include/filter.h b/include/filter.h index 23b3a7297..19c155f9b 100644 --- a/include/filter.h +++ b/include/filter.h @@ -80,13 +80,10 @@ private: bool mChg; // if filter paramater were changed bool mEnable; // if filter is actice bool mOnCopy; // if filter works on a copy -// bool mResStored; // if storage space was allocated -// IplImage *mRes; // result of filter cv::Mat mRes; // pure virtual function, where to implement the filter conversion // returns the result over pointer res and as result -// virtual IplImage* act(IplImage *img, IplImage *res)=0; virtual cv::Mat act(cv::Mat &img, cv::Mat &res)=0; public: @@ -97,14 +94,11 @@ public: bool getChanged(); void setChanged(bool b); -// void setResStored(bool b); // apply on original Data -// IplImage* apply(IplImage *img); cv::Mat apply(cv::Mat &img); cv::Mat getLastResult(); -// IplImage* getLastResult(); void freeLastResult(); void enable(); diff --git a/include/gridItem.h b/include/gridItem.h index fcba1d5c4..f1a6fce9d 100644 --- a/include/gridItem.h +++ b/include/gridItem.h @@ -34,14 +34,14 @@ private: Control *mControlWidget; float mouse_x, mouse_y; int gridTrans_x, gridTrans_y; - int/*Petrack::Dimension*/ gridDimension; + int gridDimension; public: - inline void setGridDimension(int/*Petrack::Dimension*/ gDimension) + inline void setGridDimension(int gDimension) { this->gridDimension = gDimension; } - inline int/*Petrack::Dimension*/ getGridDimension() const + inline int getGridDimension() const { return this->gridDimension; } @@ -49,7 +49,6 @@ public: QRectF boundingRect() const; void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event); -// void hoverMoveEvent(QGraphicsSceneHoverEvent *event); 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 4395e82f7..2046998f3 100644 --- a/include/helper.h +++ b/include/helper.h @@ -27,14 +27,6 @@ extern QString commandLineOptionsString; -// debug Beispiel - keines besonders gut -//qDebug() << "Widget" << this << "at position" << this->pos(); -//Q_ASSERT(1); -//dumpObjectTree(); -//dumpObjectInfo(); -// stefans ansatz steht in svt_system (nicht besser); noetig: #include "imagehlp.h" -// this ausserhalb von objekt nicht verfuegbar: #define debout cout << typeid(this).name() << "." << __func__ << " in " << __FILE__ << " line " << __LINE__ << ": " - constexpr const char* file_name(const char* path) { const char* file = path; while (*path) { @@ -118,12 +110,6 @@ inline double getMedianOf3(double a, double b, double c) } } -// // round double to int -// inline int round(double d) -// { -// return (int) (d<0 ? d-.5 : d+.5); -// } -// da obige Fkt manchmal schon existiert: // d darf keine seiteneffekte haben!!! // myround genommen, da round manchmal in math.h existiert, aber nicht immer #define myRound(d) (static_cast<int>(((d)<0 ? (d)-.5 : (d)+.5))) @@ -134,10 +120,8 @@ inline double getMedianOf3(double a, double b, double c) #define getG(img,x,y) ((int)*(uchar*)((img)->imageData + (img)->widthStep*(y) + (img)->nChannels*(x) + 1)) #define getB(img,x,y) ((int)*(uchar*)((img)->imageData + (img)->widthStep*(y) + (img)->nChannels*(x))) -//#define getRGB(img,x,y) ((QRgb) QColor(img.at<Vec3b>(y,x)[2],img.at<Vec3b>(y,x)[1],img.at<Vec3b>(y,x)[0]).rgb()); // get image grey value from grey-images with values 0..255 (may be also 3 channels???) #define getGrey(img,x,y) ((int)*(uchar*)((img)->imageData + (img)->widthStep*(y) + (x))) -//#define getGreyS(img,x,y) ((int) img.at<int>(y,x)) inline cv::Scalar qcolor2scalar(QColor color) { @@ -175,17 +159,6 @@ inline QColor getValue(const cv::Mat &img ,int x, int y) } #include <QColor> #include <QTextStream> -// inline QTextStream& operator<<(QTextStream& s, const QColor& col) -// { -// // s << "RGB "<< col.red() << " " << col.green() << " " << col.blue() << " / HSV " << col.hue() << " " << col.saturation() << " " << col.value(); -// s << col.hue() << " " << col.saturation() << " " << col.value(); -// return s; -// } -// inline ostream& operator<<(ostream& s, const QColor& col) -// { -// s << "RGB "<< col.red() << " " << col.green() << " " << col.blue() << " / HSV " << col.hue() << " " << col.saturation() << " " << col.value(); -// return s; -// } inline std::ostream& operator<<(std::ostream& s, const QColor& col) { if (col.isValid()) diff --git a/include/imageItem.h b/include/imageItem.h index 810cfc556..fb0890a06 100644 --- a/include/imageItem.h +++ b/include/imageItem.h @@ -31,7 +31,6 @@ class ImageItem: public QGraphicsItem private: Petrack *mMainWindow; Control *mControlWidget; -// QPixmap *mImage; QImage *mImage; QGraphicsItem *mCoordItem; public: @@ -40,7 +39,6 @@ public: QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); -// void setLogo(QImage *img); void setImage(QImage *img); void setCoordItem(QGraphicsItem *ci); double getCmPerPixel(); @@ -49,11 +47,8 @@ public: QPointF getPosImage(QPointF pos, float height = 0.); QPointF getPosReal(QPointF pos, double height = 0.); -// void dragEnterEvent(QDragEnterEvent *event); -// void dropEvent(QDropEvent * event); void mouseMoveEvent(QGraphicsSceneMouseEvent * event); void hoverMoveEvent(QGraphicsSceneHoverEvent * event); -// bool sceneEvent(QEvent * event); }; #endif diff --git a/include/logoItem.h b/include/logoItem.h index ac8aaeff0..faedd838d 100644 --- a/include/logoItem.h +++ b/include/logoItem.h @@ -48,9 +48,6 @@ public: QRectF boundingRect() const; -// void dragEnterEvent(QDragEnterEvent *event); -// void dropEvent(QDropEvent *event); - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); inline float getOpacity() const { @@ -64,7 +61,6 @@ public: private: Petrack *mMainWindow; - //QGraphicsScene *mScene; erhaelt man mit scene() QImage *mImage; float mOpacity; Fader fader; diff --git a/include/markerCasern.h b/include/markerCasern.h index af5c6c993..bdba3cf2e 100644 --- a/include/markerCasern.h +++ b/include/markerCasern.h @@ -108,7 +108,6 @@ public: void organize(const cv::Mat &img, bool autoWB); //draw ... Qt - void draw(cv::Mat &img) const; void toCrossList(QList<TrackPoint> *crossList, bool ignoreWithoutMarker) const; diff --git a/include/multiColorMarkerWidget.h b/include/multiColorMarkerWidget.h index 7bf8bb1d1..d9506eb64 100644 --- a/include/multiColorMarkerWidget.h +++ b/include/multiColorMarkerWidget.h @@ -95,13 +95,7 @@ private slots: { mMainWindow->getMultiColorMarkerItem()->setVisible(i); mMainWindow->getScene()->update(); - // mMainWindow->updateImage(); } -// void on_colorMarkerColor_currentIndexChanged(int i) -// { -// if (mMainWindow && (mMainWindow->getScene())) -// mMainWindow->getScene()->update(); -// } void on_maskMask_stateChanged(int /*i*/) { mMainWindow->getScene()->update(); @@ -159,17 +153,12 @@ private slots: QPointF cmPerPixel1 = mMainWindow->getImageItem()->getCmPerPixel(0, 0, mMainWindow->getControlWidget()->mapDefaultHeight->value()); QPointF cmPerPixel2 = mMainWindow->getImageItem()->getCmPerPixel(mMainWindow->getImage()->width()-1, mMainWindow->getImage()->height()-1, mMainWindow->getControlWidget()->mapDefaultHeight->value()); double cmPerPixelAvg = (cmPerPixel1.x()+cmPerPixel1.y()+cmPerPixel2.x()+cmPerPixel2.y())/4.; - //debout <<cmPerPixel1.x()<<" "<<cmPerPixel1.y()<<" "<<cmPerPixel2.x()<<" "<<cmPerPixel2.y()<<endl; - //debout << 21./cmPerPixelAvg<<endl; if (cmPerPixelAvg > 0) { double area = PI*0.25 * HEAD_SIZE/cmPerPixelAvg * 14./cmPerPixelAvg; // 14. Kopfbreite // Elipse: A=Pi*a*b (a,b Halbachsen) - //debout <<area <<endl; mOldMinArea = minArea->value(); mOldMaxArea = maxArea->value(); - //debout << oldMinArea <<endl; - //debout << oldMaxArea <<endl; minArea->setValue(area*0.75); maxArea->setValue(area*2.5); } diff --git a/include/person.h b/include/person.h index b6618aaf8..80da4d96f 100644 --- a/include/person.h +++ b/include/person.h @@ -45,8 +45,6 @@ public: Person(const MyEllipse &e, float d) : mDistTopEllipse(d), mActLevel(false) { -// if (d < mDistTopEllipse) // naeher dran an Kamera -// mDistTopEllipse = d; append(e); } inline void setActLevel(bool b) @@ -79,7 +77,6 @@ private: pet::StereoContext *mSc; public: PersonList(); - //~PersonList(); void searchEllipses(pet::StereoContext *sc, QRect &roi, BackgroundFilter* bgFilter); diff --git a/include/petrack.h b/include/petrack.h index 5ef7a3d8f..36224ddd0 100644 --- a/include/petrack.h +++ b/include/petrack.h @@ -92,15 +92,9 @@ public: Petrack(); ~Petrack(); static int trcVersion; // version numbr for writing TRC-Trajectorie files -// enum class Dimension -// { -// dim2D=2, -// dim3D=3 -// }; protected: void closeEvent(QCloseEvent *event); - //void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE; private slots: void saveVideo(); @@ -168,7 +162,6 @@ public: void updateControlImage(cv::Mat &img); int calculateRealTracker(); void exportTracker(QString dest = ""); -// void load3DCalibPoints(QString src = ""); void importTracker(QString dest = ""); void testTracker(); void trackAll(); @@ -176,9 +169,7 @@ public: int winSize(QPointF *pos=nullptr, int pers=-1, int frame=-1, int level=-1); void updateImage(bool imageChanged = false); void updateImage(const cv::Mat &img); -// void updateImage(IplImage *iplImg); void updateSequence(); -// void calcBackground(); QSet<int> getOnlyVisible(); double getCmPerPixel() const; void setHeadSize(double hS=-1); @@ -264,21 +255,13 @@ public: { return mImage; } -// inline IplImage* getIplImage() -// { -// return mIplImg; -// } inline cv::Mat getImg() { - return mImg;// = cvarrToMat(mIplImg); + return mImg; } -// inline IplImage* getIplImageFiltered() -// { -// return mIplImgFiltered; -// } inline cv::Mat getImageFiltered() { - return mImgFiltered;// = cvarrToMat(mIplImgFiltered); + return mImgFiltered; } inline Tracker* getTracker() { @@ -383,14 +366,6 @@ public: { return &mBrightContrastFilter; } - // ContrastFilter *getContrastFilter() - // { - // return &mContrastFilter; - // } - // BrightFilter *getBrightFilter() - // { - // return &mBrightFilter; - // } inline BorderFilter* getBorderFilter() { return &mBorderFilter; @@ -410,12 +385,10 @@ public: return (int) getBorderFilter()->getBorderSize()->getValue(); else return 0; - //mImageBorderSize; } inline void setImageBorderSize(int sz) { getBorderFilter()->getBorderSize()->setValue(sz); - //mImageBorderSize = sz; } inline AutoCalib* getAutoCalib() @@ -465,7 +438,6 @@ public: private: void createActions(); void createMenus(); - //void createToolBars(); void createStatusBar(); void readSettings(); void writeSettings(); @@ -548,9 +520,6 @@ private: QString mHeightFileName; QString mMarkerIDFileName; - // IplImage *mIplImg; -// IplImage *mPrevIplImgFiltered; -// IplImage *mIplImgFiltered; cv::Mat mImg; cv::Mat mImgFiltered; QImage *mImage; @@ -584,11 +553,8 @@ private: QPointF mMousePosOnImage; - //CalibFilter mCalibFilter; Filter *mCalibFilter; BrightContrastFilter mBrightContrastFilter; -// BrightFilter mBrightFilter; -// ContrastFilter mContrastFilter; BorderFilter mBorderFilter; SwapFilter mSwapFilter; BackgroundFilter mBackgroundFilter; @@ -604,11 +570,9 @@ private: double mHeadSize; double mCmPerPixel; -// QString mDefaultSettings; QDomDocument mDefaultSettings; double mShowFPS; -// clock_t mLastTime; bool mAutoBackTrack; bool mAutoTrackOptimizeColor; @@ -625,5 +589,4 @@ private: QString mCompilerVersion{"Unknown"}; ///< Used compiler version }; - #endif diff --git a/include/player.h b/include/player.h index c3e3e5c64..c77305465 100644 --- a/include/player.h +++ b/include/player.h @@ -93,7 +93,6 @@ public slots: private: -// void paintEvent(QPaintEvent *event); void setSliderMax(int max); bool updateImage(); bool forward(); @@ -119,7 +118,6 @@ private: //GUI QToolButton *mFrameForwardButton, *mFrameBackwardButton, *mPlayForwardButton, *mPlayBackwardButton, *mPauseButton; QToolButton *mRecButton; -// IplImage *mIplImg; cv::Mat mImg; QHBoxLayout *mPlayerLayout; Petrack *mMainWindow; @@ -136,7 +134,6 @@ private: QIntValidator *mFrameInNumValidator; QIntValidator *mFrameOutNumValidator; QDoubleValidator *mFpsNumValidator; - }; #endif diff --git a/include/recognitionRoiItem.h b/include/recognitionRoiItem.h index 7c127b85f..dae902884 100644 --- a/include/recognitionRoiItem.h +++ b/include/recognitionRoiItem.h @@ -37,7 +37,6 @@ class RecognitionRoiItem : public QGraphicsRectItem private: Petrack *mMainWindow; Control *mControlWidget; - //QRectF mPressRect; QRect mPressRect; QPointF mPressPos; enum pressLocation mPressLocation; @@ -47,12 +46,7 @@ public: void mousePressEvent(QGraphicsSceneMouseEvent * event); void mouseReleaseEvent(QGraphicsSceneMouseEvent * event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); -// void hoverEnterEvent(QGraphicsSceneHoverEvent *event); -// void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); void hoverMoveEvent(QGraphicsSceneHoverEvent *event); -// void updateData(); -// QRectF boundingRect() const; -// void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void checkRect(); }; diff --git a/include/stereoContext.h b/include/stereoContext.h index b89f0fe6b..3a5550f6d 100644 --- a/include/stereoContext.h +++ b/include/stereoContext.h @@ -34,7 +34,6 @@ #else #include "stereoAviFile.h" #endif -//#include "backgroundFilter.h" #include "opencv2/calib3d/calib3d_c.h" #include "opencv2/calib3d.hpp" diff --git a/include/stereoItem.h b/include/stereoItem.h index 6eac76eea..4c241b48c 100644 --- a/include/stereoItem.h +++ b/include/stereoItem.h @@ -23,9 +23,6 @@ #include <QGraphicsItem> -//class Petrack; -//class Control; -//class Tracker; #include "petrack.h" class StereoItem : public QGraphicsItem diff --git a/include/swapFilter.h b/include/swapFilter.h index 0b097f25c..22b5892f5 100644 --- a/include/swapFilter.h +++ b/include/swapFilter.h @@ -33,7 +33,6 @@ private: public: SwapFilter(); -// IplImage* act(IplImage *img, IplImage *res); cv::Mat act(cv::Mat &img, cv::Mat &res); Parameter *getSwapHorizontally(); diff --git a/include/tracker.h b/include/tracker.h index efeb7fd32..08e96cec9 100644 --- a/include/tracker.h +++ b/include/tracker.h @@ -30,7 +30,6 @@ #define EXTRAPOLATE_FACTOR 3. // war 1.5, aber bei bildauslassungen kann es ungewollt zuschlagen (bei 3 ist ein ausgelassener frame mgl, bei 2 wieder ein problem) #define MAX_COUNT 1500 // maximale anzahl an gleichzeitig getrackten personen -//#define MIN_DISTANCE 30 // abstand zwischen kopfen !!!! wird nun ueber berechnung der kopfgroesse geregelt !!!! #define MAX_STEP_TRACK 5 // maximale zahl an frames zwischen denen noch getrackt wird #define MAX_TRACK_ERROR 200 // maximaler fehler beim tracken, so das noch punkt hinzugefuegt wird // um am ende des tracking nicht am bildrand herumzukrakseln! @@ -61,10 +60,6 @@ public: { mColPoint = cp; } -// inline Vec2F& colPoint() -// { -// return mColPoint; -// } inline const QColor& color() const { return mCol; @@ -73,10 +68,6 @@ public: { mCol = col; } -// inline QColor color() -// { -// return mCol; -// } inline void setColPoint(const Vec2F &colPoint) { mColPoint = colPoint; @@ -117,26 +108,11 @@ public: mSp.setZ(z); } -// inline void setZdistanceToCam(float z) -// { -// mZdistanceToCam = z; -// } -// inline float zDistanceToCam() const -// { -// return mZdistanceToCam; -// } - -// const TrackPoint& operator=(const TrackPoint& tp); // Zuweisungsoperator const TrackPoint& operator=(const Vec2F& v); const TrackPoint& operator+=(const Vec2F& v); const TrackPoint operator+(const Vec2F& v) const; }; -// inline ostream& operator<< (ostream& s, const TrackPoint& tp) -// { -// s << "(" << tp.x() << ", " << tp.y() << ") " << tp.qual() << " - (" << tp.colPoint().x() << ", " << tp.colPoint().y() << ") (" << tp.color().red() << ", " << tp.color().green() << ", " << tp.color().blue() << ")"; -// return s; -// } inline QTextStream& operator>>(QTextStream& s, TrackPoint& tp) { @@ -158,7 +134,7 @@ inline QTextStream& operator>>(QTextStream& s, TrackPoint& tp) s >> d; sp.setY(d); s >> d; - sp.setZ(d); //setZdistanceToCam(d); + sp.setZ(d); tp.setSp(sp); } s >> qual; @@ -220,7 +196,6 @@ private: public: TrackPerson(); -// TrackPerson(int nr, int frame, const Vec2F &p); TrackPerson(int nr, int frame, const TrackPoint &p); TrackPerson(int nr, int frame, const TrackPoint &p, int markerID); @@ -250,15 +225,11 @@ public: // altitude is height of the camera over floor inline void setHeight(float z, float altitude) // , int frame { - //(*this)[frame-mFirstFrame].setZdistanceToCam(z); - mHeight = (mHeight*mHeightCount+(altitude-z))/(mHeightCount+1); ++mHeightCount; } inline void resetHeight() { - //(*this)[frame-mFirstFrame].setZdistanceToCam(z); - mHeight = MIN_HEIGHT; mHeightCount = 0; } @@ -364,26 +335,19 @@ inline QTextStream& operator>>(QTextStream& s, TrackPerson& tp) QString str = s.readLine(); QTextStream trjInfoLine(&str); - //debout << str << endl; trjInfoLine >> n; tp.setNr(n); - //debout << "Nr: " << tp.nr(); trjInfoLine >> d; tp.setHeight(d); - //cout << " Height: " << tp.height(); trjInfoLine >> n; tp.setFirstFrame(n); - //cout << " 1th frame: " << tp.firstFrame(); trjInfoLine >> n; tp.setLastFrame(n); - //cout << " last frame: " << tp.lastFrame(); trjInfoLine >> n; tp.setColCount(n); - //cout << " ColCount: " << tp.colCount(); trjInfoLine >> col; tp.setColor(col); - //cout << " col: " << tp.color(); if (Petrack::trcVersion > 3) { trjInfoLine >> markerID; @@ -392,13 +356,9 @@ inline QTextStream& operator>>(QTextStream& s, TrackPerson& tp) trjInfoLine >> n; // size of list if (Petrack::trcVersion > 2) // Reading the comment line { - //s.skipWhiteSpace(); // skip white spaces for reading the comment line without this the reading makes some problems // Kommentarzeile lesen str = s.readLine(); tp.setComment(str.replace(QRegularExpression("<br>"), "\n")); - //cout << " comment: " << tp.comment() << endl; - //if ( !comment.isEmpty()) - // s.skipWhiteSpace(); } diff --git a/include/trackerItem.h b/include/trackerItem.h index 63af0f33e..5f110166d 100644 --- a/include/trackerItem.h +++ b/include/trackerItem.h @@ -36,9 +36,6 @@ private: public: TrackerItem(QWidget *wParent, Tracker *tracker, QGraphicsItem * parent = nullptr); -// void mouseMoveEvent(QGraphicsSceneMouseEvent *event); -// void hoverMoveEvent(QGraphicsSceneHoverEvent *event); - void updateData(); void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); diff --git a/include/trackerReal.h b/include/trackerReal.h index 7da500a35..bba495c33 100644 --- a/include/trackerReal.h +++ b/include/trackerReal.h @@ -33,12 +33,10 @@ class TrackPointReal : public Vec3F { private: int mFrameNum; // frame number in animation sequence possibly with missing frames - // TrackPoint* mTrackPoint // NULL, wenn nicht einem TrackPoint zugeordnet, sondern durch Interpolation entstanden Vec2F mViewDir; float mAngleOfView; // angle of view of camera to point int mMarkerID; public: -// TrackPointReal(); TrackPointReal(const Vec3F &p, int frameNum); TrackPointReal(const Vec3F &p, int frameNum, const Vec2F &d); @@ -70,45 +68,13 @@ public: { mMarkerID = markerID; } - -// const TrackPointReal& operator=(const TrackPointReal& tp); // Zuweisungsoperator -// const TrackPointReal& operator=(const Vec2F& v); -// const TrackPointReal& operator+=(const Vec2F& v); -// const TrackPointReal operator+(const Vec2F& v) const; }; -// inline ostream& operator<< (ostream& s, const TrackPointReal& tp) -// { -// s << "(" << tp.x() << ", " << tp.y() << ") " << tp.qual() << " - (" << tp.colPoint().x() << ", " << tp.colPoint().y() << ") (" << tp.color().red() << ", " << tp.color().green() << ", " << tp.color().blue() << ")"; -// return s; -// } - -//inline QTextStream& operator>>(QTextStream& s, TrackPointReal& tp) -//{ -// double d; -// int i; - -// s >> i; -// tp.setFrameNum(i); -// s >> d; -// tp.setX(d); -// s >> d; -// tp.setY(d); -// s >> d; -// tp.setZ(d); - -// return s; -//} inline QTextStream& operator<<(QTextStream& s, const TrackPointReal& tp) { s << tp.x() << " " << tp.y(); // nur x, y wird ausgegeben, z wird nur bei Bedarf mit ausgegeben!!! return s; } -// inline ostream& operator<<(ostream& s, const TrackPointReal& tp) -// { -// s << tp.x() << " " << tp.y() << " " << tp.qual() << " " << tp.colPoint().x() << " " << tp.colPoint().y() << " " << tp.color(); -// return s; -// } //-------------------------------------------------------------------------- @@ -124,7 +90,6 @@ private: public: TrackPersonReal(); -// TrackPersonReal(int nr, int frame, const Vec2F &p); TrackPersonReal(int frame, const TrackPointReal &p); inline double height() const @@ -164,46 +129,12 @@ public: // gibt -1 zurueck, wenn frame oder naechster frame nicht existiert // entfernung ist absolut double distanceToNextFrame(int frame) const; -// double distanceBetweenFrames(int fromFrame, int toFrame) const; -// double distanceXBetweenFrames(int fromFrame, int toFrame) const; -// double distanceYBetweenFrames(int fromFrame, int toFrame) const; -// double velocityToNextFrame(int frame) const; void init(int firstFrame, double height, int markerID); void addEnd(const QPointF& pos, int frame); void addEnd(const Vec3F& pos, int frame); void addEnd(const QPointF& pos, int frame, const QPointF &dir); }; -// // keine Konsistenzueberpruefung -// inline QTextStream& operator>>(QTextStream& s, TrackPersonReal& tp) -// { -// double d; -// QColor col; -// int n; -// TrackPointReal p; - -// s >> n; -// tp.setNr(n); -// s >> d; -// tp.setHeight(d); -// s >> n; -// tp.setFirstFrame(n); -// s >> n; -// tp.setLastFrame(n); -// s >> n; -// tp.setColCount(n); -// s >> col; -// tp.setColor(col); -// s >> n; // size of list - -// for (int i = 0; i < n; ++i) -// { -// s >> p; -// tp.append(p); -// } -// return s; -// } - inline QTextStream& operator<<(QTextStream& s, const TrackPersonReal& tp) { int firstFrame = tp.firstFrame(); @@ -212,15 +143,6 @@ inline QTextStream& operator<<(QTextStream& s, const TrackPersonReal& tp) return s; } - -// inline ostream& operator<<(ostream& s, const TrackPersonReal& tp) -// { -// s << tp.nr() << " " << tp.height() << " " << tp.firstFrame() << " " << tp.lastFrame() << " " << tp.colCount() << " " << tp.color() << " " << tp.size() << endl; -// for (int i = 0; i < tp.size(); ++i) -// s << tp.at(i) << endl; -// return s; -// } - //---------------------------------------------------------------------------- // using tracker: @@ -237,9 +159,6 @@ class TrackerReal : public QList<TrackPersonReal> private: double mXMin, mXMax, mYMin, mYMax; Petrack *mMainWindow; - // int double mFps; -// Tracker* mTracker; -// bool mMissingFramesInserted; public: inline double xMin() const @@ -261,27 +180,6 @@ public: TrackerReal(QWidget *wParent); -// ~TrackerReal(); - -// inline const Tracker* tracker() const -// { -// return mTracker; -// } -// inline void setTracker(Tracker* tracker) -// { -// mTracker = tracker; -// } -// inline const bool missingFramesInserted() const -// { -// return mMissingFramesInserted; -// } -// inline void setMissingFramesInserted(bool b) -// { -// mMissingFramesInserted = b; -// } - -// void init(CvSize size); -// void resize(CvSize size); // calculate height of person @@ -308,12 +206,4 @@ public: void exportXml(QTextStream &outXml, bool alternateHeight, bool useTrackpoints); }; -//inline QTextStream& operator<<(QTextStream& s, const TrackerReal& trackerReal) -//{ -// for (int i = 0; i < trackerReal.size(); ++i) -// for (int j = 0; j < trackerReal.at(i).size(); ++j) -// s << i+1 << " " << trackerReal.at(i).firstFrame()+j << " " << trackerReal.at(i).at(j) << " " << trackerReal.at(i).height() <<endl; //<< " " << tp.qual(); -// return s; -//} - #endif diff --git a/include/trackingRoiItem.h b/include/trackingRoiItem.h index 3bb5dfcde..09dcee4a6 100644 --- a/include/trackingRoiItem.h +++ b/include/trackingRoiItem.h @@ -36,7 +36,6 @@ class TrackingRoiItem : public QGraphicsRectItem private: Petrack *mMainWindow; Control *mControlWidget; - //QRectF mPressRect; QRect mPressRect; QPointF mPressPos; enum pressLocation mPressLocation; @@ -46,13 +45,8 @@ public: void mousePressEvent(QGraphicsSceneMouseEvent * event); void mouseReleaseEvent(QGraphicsSceneMouseEvent * event); void mouseMoveEvent(QGraphicsSceneMouseEvent * event); - // void hoverEnterEvent(QGraphicsSceneHoverEvent *event); - // void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); - void hoverMoveEvent(QGraphicsSceneHoverEvent *event); - // void updateData(); - // QRectF boundingRect() const; - // void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - void checkRect(); + void hoverMoveEvent(QGraphicsSceneHoverEvent *event); + void checkRect(); }; #endif // TRACKINGROIITEM_H diff --git a/include/vector.h b/include/vector.h index 602e1bd33..4597cc104 100644 --- a/include/vector.h +++ b/include/vector.h @@ -56,12 +56,6 @@ public: Vec3F(); Vec3F(double x, double y, double z); Vec3F(const Vec3F& v) = default; -// Vec3F(const QPointF& v); -// Vec3F(const CvPoint* v); - -// CvPoint toCvPoint() const; -// QPoint toQPoint() const; -// QPointF toQPointF() const; double x() const; double y() const; @@ -71,8 +65,6 @@ public: void setZ(double z); void set(double x, double y, double z); -// Vec3F operator=(const CvPoint *v); - Vec3F operator+(const Vec3F& v) const; Vec3F operator-(const Vec3F& v) const; const Vec3F operator+=(const Vec3F& v); @@ -83,24 +75,15 @@ public: Vec3F operator/(double n) const; // scalar divide double operator*(const Vec3F& v) const; // dot product -// double operator%(const Vec3F& v) const; // cross product bool operator==(const Vec3F& v) const; bool operator!=(const Vec3F& v) const; double length() const; -// double angle() const; Vec3F unit() const; -// Vec3F normal() const; void normalize(); double distanceToPoint(const Vec3F& p) const; - -// // return distance from vec to line between p1 and p2 -// double distanceToLine(const Vec3F& p1, const Vec3F& p2) const; -// double angleBetweenVec(const Vec3F& v) const; - -// static Vec3F fromAngle(double angle); }; @@ -156,7 +139,6 @@ public: Vec2F operator/(double n) const; // scalar divide double operator*(const Vec2F& v) const; // dot product -// double operator%(const Vec2F& v) const; // cross product bool operator==(const Vec2F& v) const; bool operator!=(const Vec2F& v) const; diff --git a/include/view.h b/include/view.h index 3508767f9..5b9c9b0c1 100644 --- a/include/view.h +++ b/include/view.h @@ -44,7 +44,6 @@ public: void wheelEvent(QWheelEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override; - //void mouseReleaseEvent(QMouseEvent *event); void keyPressEvent(QKeyEvent *event) override; void mousePressEvent(QMouseEvent *event) override; @@ -58,7 +57,6 @@ signals: void mouseShiftWheel(int delta); void colorSelected(); void setColorEvent(); - //void mouseRightClick(QPointF pos); }; // ------------------------------- diff --git a/src/analysePlot.cpp b/src/analysePlot.cpp index ce7777566..739dab855 100644 --- a/src/analysePlot.cpp +++ b/src/analysePlot.cpp @@ -42,10 +42,6 @@ public: { -////// Macht Probleme mit Qwt 6 -////// setSelectionFlags(QwtPicker::DragSelection | QwtPicker::CornerToCorner); - // default: setRubberBand(QwtPicker::NoRubberBand); - // RightButton: zoom out by 1 // Ctrl+RightButton: zoom out to full size @@ -54,32 +50,9 @@ public: setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); setRubberBand(QwtPicker::RectRubberBand); - //mZoomer->setRubberBandPen(QColor(Qt::green)); setTrackerMode(QwtPicker::AlwaysOn); //ActiveOnly (only when the selection is active), AlwaysOff - //mZoomer->setTrackerPen(QColor(Qt::white)); } -// // ueberschrieben, da so kommazahlen unterdrueckt werden, da intervall mindestens 5 umfasst -// QwtDoubleSize minZoomSize() const //QwtPlotZoomer:: -// { -// return QwtDoubleSize(5., 5.); -// } - -// QwtPlot *plot() -// { -// QObject *w = canvas(); -// if ( w ) -// { -// w = w->parent(); -// if ( w && w->inherits("QwtPlot") ) -// return (QwtPlot *)w; -// } - -// return NULL; -// } - -//widgetWheelEvent ( QWheelEvent * e ) - void widgetMouseMoveEvent(QMouseEvent *e) override { static int lastX = -1; @@ -115,14 +88,6 @@ public: d2 = map.invTransform(i2 - dy); } - //debout << zoomBase().width() << " " << zoomBase().height() << endl; - //debout << plot()->axisScaleDiv(axis)->lBound() << " " << plot()->axisScaleDiv(axis)->hBound() << endl; -// if (d1 < 0) -// { -// d2 = d2-d1; -// d1 = 0; -// } -// else if ((axis == QwtPlot::xBottom) && (d2 > zoomBase().width())) { d1 = d1-(d2-zoomBase().width()); @@ -142,21 +107,6 @@ public: } QwtPlotZoomer::widgetMouseMoveEvent(e); } -// // damit bei pan nicht text angezeigt wird // wenn eingebauter pan benutzt wird!!! -// void widgetMousePressEvent(QMouseEvent *e) -// { -// if (e->button() == Qt::MidButton) -// setTrackerMode(QwtPicker::AlwaysOff); - -// QwtPlotZoomer::widgetMousePressEvent(e); -// } -// void widgetMouseReleaseEvent(QMouseEvent *e) -// { -// if (e->button() == Qt::MidButton) -// setTrackerMode(QwtPicker::AlwaysOn); - -// QwtPlotZoomer::widgetMouseReleaseEvent(e); -// } QwtText trackerTextF(const QPointF &pos) const override { @@ -186,23 +136,11 @@ void TrackerRealPlotItem::draw(QPainter* p, const QwtScaleMap& mapX, const QwtSc int i, j; QPointF point, lastPoint; - // debout << "---" <<endl; - // debout << re.x() << " " << re.y() << " " << re.width() << " " << re.height()<<endl; - // debout << "x:" <<endl; - // debout << mapX.p1() << " "<< mapX.p2() << " " << mapX.s1() << " "<< mapX.s2() << " "<<endl; - // debout << "y:" <<endl; - // debout << mapY.p1() << " "<< mapY.p2() << " " << mapY.s1() << " "<< mapY.s2() << " "<<endl; - p->save(); p->translate(mapX.p1(), mapY.p2()); // in pixelkoordinaten vor skalierung p->scale(sx, sy); p->translate(-mapX.s1(), -mapY.s2()); - // p->drawLine(QPointF(-10, -10), QPointF(-10, 10)); - // p->drawLine(QPointF(-10, 10), QPointF(10, 10)); - // p->drawLine(QPointF(10, 10), QPointF(10, -10)); - // p->drawLine(QPointF(10, -10), QPointF(-10, -10)); - p->setPen(Qt::red); rect.setWidth(circleSize/sx); @@ -221,11 +159,6 @@ void TrackerRealPlotItem::draw(QPainter* p, const QwtScaleMap& mapX, const QwtSc QwtText titleY; if (anaConsiderX && anaConsiderY) { -// if (anaConsiderAbs) -// titleY.setText("|v| [m/s]", QwtText::RichText); -// else if (anaConsiderRev) -// titleY.setText("-v [m/s]", QwtText::RichText); -// else titleY.setText("v [m/s]", QwtText::RichText); } else if (anaConsiderX) @@ -246,54 +179,23 @@ void TrackerRealPlotItem::draw(QPainter* p, const QwtScaleMap& mapX, const QwtSc else titleY.setText("v<sub>y</sub> [m/s]", QwtText::RichText); } - //QwtText titleY("v<sub>y</sub> [m/s]", QwtText::RichText); //"y" titleX.setFont(f); titleY.setFont(f); ((AnalysePlot *) plot())->setAxisTitle(QwtPlot::xBottom, titleX); //"x" ((AnalysePlot *) plot())->setAxisTitle(QwtPlot::yLeft, titleY); //"y" - //setAxisFont(xBottom, f); - //setAxisFont(yLeft, f); - - // for (i = 0; i < mTrackerReal->size(); ++i) -// { -// for (j = 0; j < mTrackerReal->at(i).size(); ++j) -// { -// point = mTrackerReal->at(i).at(j).toQPointF(); -// if (j!=0) -// ;//p->drawLine(point, lastPoint); -// rect.moveLeft(point.x()-sx); -// rect.moveTop(point.y()-sy); -// //p->setPen(Qt::red); -// //p->setBrush(QBrush((*mTracker)[i].color())); -// //p->drawEllipse(rect); -// p->drawPoint(point); -// p->drawRect(rect); -// lastPoint = point; -// } -// } int step = controlWidget->anaStep->value(); //1 int frame, animFrame, velVecActIdx = -1; double vel; // geschwindigkeit int largestLastFrame = mTrackerReal->largestLastFrame(); - QVector<int> velAnzVec(largestLastFrame, 0); //mControlWidget->getMainWindow()->getAnimation()->getNumFrames() + QVector<int> velAnzVec(largestLastFrame, 0); QVector<double> velVec(largestLastFrame, 0.); int actFrame = ((AnalysePlot *) plot())->getActFrame(); - //int actFrame = ((AnalysePlot *) plot())->getControlWidget()->getMainWindow()->getAnimation()->getCurrentFrameNum(); bool markAct = controlWidget->anaMarkAct->isChecked(); double fps = controlWidget->getMainWindow()->getAnimation()->getFPS(); if (fps < 0) fps =DEFAULT_FPS; -// QPen linePen; -// linePen.setColor(Qt::red); -// linePen.setWidthF(3/sx); -// p->setPen(linePen); -// p->pen().setWidth(3); // geht nicht -// p->setPen(Qt::red); -// p->setBrush(Qt::red); - //p->setBrush(Qt::red); //QBrush(Qt::red) - if (!markAct) { p->setPen(Qt::green); @@ -322,9 +224,6 @@ void TrackerRealPlotItem::draw(QPainter* p, const QwtScaleMap& mapX, const QwtSc if (anaConsiderX && anaConsiderY) { -// if (anaConsiderAbs) -// else if (anaConsiderRev) -// else vel = (mTrackerReal->at(i).at(j+step).distanceToPoint(mTrackerReal->at(i).at(j))); } else if (anaConsiderX) @@ -352,15 +251,12 @@ void TrackerRealPlotItem::draw(QPainter* p, const QwtScaleMap& mapX, const QwtSc rect.moveLeft(point.x()-sx); rect.moveTop(point.y()-sy); p->drawEllipse(rect); - //p->drawPoint(point); // j - j+step, da gegen die x-achse gelaufen wird ++velAnzVec[frame]; velVec[frame] += vel; } -// p->setPen(Qt::red); -// p->setBrush(Qt::red); } rect.setWidth(2*rect.width()); @@ -384,11 +280,6 @@ void TrackerRealPlotItem::draw(QPainter* p, const QwtScaleMap& mapX, const QwtSc } } } - //0..getAnimation()->getNumFrames(); - //smallestFirstFrame()..largestLastFrame() - //int smallestFirstFrame = mTrackerReal->smallestFirstFrame(); - //int largestLastFrame = mTrackerReal->largestLastFrame(); - //for (i = smallestFirstFrame; i <= largestLastFrame; ++i) p->restore(); } @@ -410,7 +301,6 @@ AnalysePlot::AnalysePlot(QWidget *parent) // default= NULL : QwtPlot(parent) { setAutoReplot(false); - //setTitle("Frequency Response of a Second-Order System"); setCanvasBackground(QColor(QColor(220, 220, 255))); mControlWidget = nullptr; @@ -426,48 +316,15 @@ AnalysePlot::AnalysePlot(QWidget *parent) // default= NULL setAxisTitle(xBottom, titleX); //"x" setAxisTitle(yLeft, titleY); //"y" - //setAxisFont(xBottom, f); - //setAxisFont(yLeft, f); plotLayout()->setAlignCanvasToScales(true); - //axisScaleEngine(xBottom)->setAttribute(QwtScaleEngine::Floating, false); - //axisScaleEngine(yLeft)->setAttribute(QwtScaleEngine::Floating, false); - //canvas()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - //canvas()->setFixedWidth(400); //geometry().width()- - //canvas()->setFixedHeight(400); //geometry().height()- mZoomer = new AnalyseZoomer(xBottom, yLeft, canvas()); //QwtPlotZoomer - //(new QwtPlotPanner(canvas()))->setMouseButton(Qt::MidButton); - -// mTpc = new QwtPlotCurve("color of tracking points"); -// mTpc->attach(this); -// mTpc->setStyle(QwtPlotCurve::NoCurve); -// mTpc->setSymbol(QwtSymbol(QwtSymbol::XCross, QBrush(Qt::white), QPen(Qt::black), QSize(4, 4))); -// // Ellipse, Rect, Diamond, Triangle, DTriangle, UTriangle, LTriangle, RTriangle, Cross, XCross, HLine, VLine, Star1, Star2, Hexagon, StyleCnt -// // mTpc->setPen(...); - mTrackerRealItem = new TrackerRealPlotItem(); mTrackerRealItem->setZ(1); mTrackerRealItem->attach(this); -// mRectItem = new RectPlotItem(); -// mRectItem->attach(this); - -// mViewAnalyseItem = new ViewAnalysePlotItem(); -// mViewAnalyseItem->attach(this); - -// test: mRectItem->addMap(10, 10, 100, 100, true, 1.40); - - //paintEngine()->hasFeature(QPaintEngine::Antialiasing); - //setAutoReplot(true); - -// setMouseTracking(true); // mouse move events werden auch bei nichtdruecken einer moustaste ausgeloest -// setAxisAutoScale(QwtPlot::xBottom); -// setAxisAutoScale(QwtPlot::yLeft); -// setAxisAutoScale(QwtPlot::xTop); -// setAxisAutoScale(QwtPlot::yRight); - // grid QwtPlotGrid *grid = new QwtPlotGrid; grid->enableXMin(true); @@ -479,30 +336,6 @@ AnalysePlot::AnalysePlot(QWidget *parent) // default= NULL } -// double AnalysePlot::map(const QColor &col) const -// { -// double height = 1.; -// if (height < 0) -// return mControlWidget->mapDefaultHeight->value(); -// else -// return height; -// } - -// void AnalysePlot::mouseMoveEvent(QMouseEvent *event) -// { -// QFrame::mouseMoveEvent(event); -// debout << "moveEvent" << endl; -// } - -void AnalysePlot::setCursor(const QColor &/*col*/) -{ - //QPoint pos = getPos(col); - //QMouseEvent event(QEvent::MouseMove, pos, Qt::NoButton, Qt::NoButton, Qt::NoModifier); -// mViewAnalyseItem->setPoint(getPos(col)); - //mZoomer->mouseMoveEvent(&event); //widgetM - //QFrame::mouseMoveEvent(&event); -} - QPoint AnalysePlot::getPos(const QColor &col) const { QPoint p; @@ -558,30 +391,8 @@ void AnalysePlot::setScale() { if (mControlWidget) { -// int model = mControlWidget->recoColorModel->currentIndex(); -// int x = mControlWidget->recoColorX->currentIndex(); -// int y = mControlWidget->recoColorY->currentIndex(); - -// mXMax = 255.; -// mYMax = 255.; -// if (model == 0) // HSV //mControlWidget->recoColorModel->currentIndex() -// { -// if (x==0) -// mXMax = 359.; -// if (y==0) -// mYMax = 359.; -// } - -// double spacerX = (mTrackerReal->xMax()-mTrackerReal->xMin())/20.; -// double spacerY = (mTrackerReal->yMax()-mTrackerReal->yMin())/20.; -// mXMin = mTrackerReal->xMin()-spacerX; -// mXMax = mTrackerReal->xMax()+spacerX; -// mYMin = mTrackerReal->yMin()-spacerY; -// mYMax = mTrackerReal->yMax()+spacerY; int frameNum = mTrackerReal->largestLastFrame(); //mControlWidget->getMainWindow()->getAnimation()->getNumFrames(); - //double spacerX = frameNum/20.; - //double spacerY = 0.5; mXMin = mTrackerReal->smallestFirstFrame()-10; //0-spacerX; mXMax = frameNum+10; //frameNum+spacerX; mYMin = -0.2; //0-spacerY; @@ -591,13 +402,6 @@ void AnalysePlot::setScale() setAxisScale(QwtPlot::yLeft, mYMin, mYMax); replot(); // why, see: file:///C:/Programme/qwt-5.0.2/doc/html/class_qwt_plot_zoomer.html#7a1711597f441223efdb7d9931fe19b9 mZoomer->setZoomBase(QwtDoubleRect(mXMin, mYMin, mXMax-mXMin, mYMax-mYMin)); - -// setAutoReplot(false); // hiermit koennte temporaer das automatische skalieren auf werte von setaxisscale unterdrueckt werden -// setAutoReplot(true); -// setAxisAutoScale(QwtPlot::xBottom); -// setAxisAutoScale(QwtPlot::yLeft); - - } } diff --git a/src/animation.cpp b/src/animation.cpp index bf15bd88d..3a21c0539 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -73,12 +73,6 @@ Animation::Animation(QWidget *wParent) #ifndef STEREO_DISABLED mCaptureStereo = nullptr; #endif -// mImage = NULL; - -// mStereoImgLeft = NULL; -// mStereoImgRight = NULL; - - mTimeFileLoaded = false; // Set image size mSize.setHeight(0); @@ -121,11 +115,9 @@ cv::Mat Animation::getFrameAtIndex(int index) // If not, it will be set the first or the last index if (index<getSourceInFrameNum()){ return cv::Mat(); - //index=0; } if (index>getSourceOutFrameNum()){ return cv::Mat(); - //index = getNumFrames()-1; } // Call the own methods to get it done if (mVideo) @@ -237,8 +229,7 @@ bool Animation::openTimeFile(QString &timeFileName) in >> dum; } dt.setTime_t(sec); - //fps = frame/((sec-fsec)+0.000001*microSec-0.000001*fmicroSec); // nicht frame+1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - fps = frame/((cycSec-fcycSec+add)+(cycCount-fcycCount)/8000.); //((sec-fsec)+0.000001*microSec-0.000001*fmicroSec); + fps = frame/((cycSec-fcycSec+add)+(cycCount-fcycCount)/8000.); debout << " Recording ends at " << dt.toString("dd.MM.yyyy hh:mm:ss."); // entspricht nicht der in statusbar angezeigten zeit des letzten frames, da in statusbar fps und frameanzahl herangezogen wird (genauer)!!! std::cout << std::setw(6) << std::setfill('0') << microSec << std::endl; debout << " Fps with "<< frame+1 <<" frames: " << fps << " (min "<<1./difMax<<" at frame "<<maxFrame<<" to "<<maxFrame+1<<", max "<<1./difMin<<" at frame "<<minFrame<<" to "<<minFrame+1<<")" << std::endl; @@ -316,7 +307,6 @@ bool Animation::openAnimation(QString fileName) // (fileName.right(4).toLower() == ".mp4") ) //{ // now all videos will be try to open with OpenCV - //openRet = openAnimationVideo(fileName); openRet = openAnimationPhoto(fileName); //} // If it is not a video, then is a photo :-) @@ -497,7 +487,6 @@ void Animation::reset() mFps = -1; mFirstSec = -1; mFirstMicroSec = -1; - ////mCapture = NULL; #ifndef STEREO_DISABLED mCaptureStereo = nullptr; #endif @@ -509,15 +498,6 @@ void Animation::reset() mSize.setWidth(0); } -// void Animation::setFilter(Filter *newFilter){ -// mFilter = newFilter; -// } - -// IplImage* Aniion::applyFilter(IplImage *image){ -// if(mFilter==0)return image; -// else return mFilter->apply(image); //mFilter->setOnCopy(false); geht nicht -// } - /// filename without sequence number and suffix : image0001-left.png => image-left QString Animation::getFileBase() { @@ -574,33 +554,19 @@ bool Animation::openAnimationPhoto(QString fileName) { // check, if cv can open one animation file - // OLD - //if (!cvLoadImage((fileName.toStdString()).c_str(), -1)) - // return false; - cv::Mat tempMat; tempMat = cv::imread(fileName.toStdString(),cv::IMREAD_UNCHANGED);//, IMREAD_UNCHANGED);//CV_LOAD_IMAGE_UNCHANGED); - if(! tempMat.data ) // Check for invalid input + // Check for invalid input + if(! tempMat.data ) { - //debout << "Could not open or find the image" << std::endl ; return false; } -// namedWindow("Test-View"); -// imshow("Test-View",tempMat); -// waitKey(); -// debout << "fileName: " << fileName.toStdString() << " channels: " << tempMat.channels() << " depth: " << tempMat.depth() << endl; if( tempMat.channels() == 4 ){ std::cout << "Warning: PNG-Alpha channel will be ignored." << std::endl; -// tempMat.release(); tempMat = cv::imread(fileName.toStdString(),cv::IMREAD_COLOR); } - - - //if( !mVideoCapture.isOpened() || mVideoCapture.get(CV_CAP_PROP_FRAME_COUNT) > 1) - // return false; - // Destroy anything that was before free(); // Set new video & photo labels @@ -615,11 +581,6 @@ bool Animation::openAnimationPhoto(QString fileName) // Get all files in the same directory QList<QFileInfo> fileList = dir.entryInfoList(QDir::Files,QDir::Name); -// for(int i=0;i<fileList.size();i++) -// { -// debout << "File[" << i << "]: " <<fileList.at(i).completeBaseName() << " suffix: " << fileList.at(i).suffix() << endl; -// } - // series1_0002-left => split into series1_|0002|-left // regexp is greedy - from left to right try to get the most characters QRegExp regExp("(?:[0-9]*)([^0-9]*)$"); //(?: ) zum ignorieren @@ -629,39 +590,18 @@ bool Animation::openAnimationPhoto(QString fileName) { front = mFileInfo.completeBaseName().left(frontLen); back = regExp.cap(1); - //debout << mFileInfo.completeBaseName() << ": " << frontLen << " " << front << " " << back << endl; } else // does not match regExp at all return false; mFileBase = front + back; // completeBaseName to cut suffix and sequence number - // nun wird aus Einzelbildern video erzeugt -// //untersuchen, ob stereo sequence -// if (mFileInfo.completeBaseName().contains("right")) //, !Qt::CaseSensitive // macht das ganze komplizierter; auch deutsche Variante nicht erlaubt -// { -// QString fileNameLeft = mFileInfo.path() + "/" + mFileInfo.completeBaseName().replace("right", "left") + "." + mFileInfo.completeSuffix(); -// if (QFileInfo(fileNameLeft).exists()) -// mStereo = true; -// } -// else if (fileInfo.completeBaseName().contains("left")) -// { -// QString fileNameLeft = mFileInfo.path() + "/" + mFileInfo.completeBaseName().replace("left", "right") + "." + mFileInfo.completeSuffix(); -// if (QFileInfo(fileNameLeft).exists()) -// mStereo = true; -// } -// if (mStereo) -// debout << "Image sequence is interpreted as stereo sequence!" << endl; - // Create a new image files list mImgFilesList.clear(); for (int i = 0; i < fileList.size(); i++) { if ((frontLenList = regExp.indexIn(fileList.at(i).completeBaseName())) > -1) { - // Is the file in the series? - // debout << "|" << fileList.at(i).completeBaseName().left(frontLenList) << "|" << " == " << "|" << front << "|" << endl - // << "|" << regExp.cap(1) << "|" << " == " << "|" << back << "|" << endl - // << "|" << fileList.at(i).suffix() << "|" << " == " << "|" << mFileInfo.suffix() << "|" << endl; + // Is the file in the series? if ((fileList.at(i).completeBaseName().left(frontLenList) == front) && (regExp.cap(1) == back) && (fileList.at(i).suffix() == mFileInfo.suffix())) @@ -671,25 +611,6 @@ bool Animation::openAnimationPhoto(QString fileName) } } -// QRegExp regExpNumAtEnd("[0-9]*$"); -//// QRegExp regExpNoNumAtEnd("[^0-9]*$"); -// // Get the name of the serie; series1_0002-left.png => series1_0002-left -// QString fileBaseName = mFileInfo.completeBaseName(); -// // Get the string after enumeration; series1_0002-left => series1_0002 (attach == -left) -//// QString attach = fileBaseName.right(fileBaseName.size()-regexpNoNumAtEnd.indexIn(fileBaseName)); -// QString fileBaseName = fileBaseName.left(regexpNoNumAtEnd.indexIn(fileBaseName)); -// // series1_0002 => series1_ -// mFileBase = fileBaseName.left(regexpNumAtEnd.indexIn(fileBaseName)); //getSeriesName(fileBaseName); -// // Create a new image files list -// mImgFilesList.clear(); -// for (int i = 0; i < fileList.size(); i++) -// // Is the file in the series? -// //sonst wuerde bei w0 auch wert0 oder bei reiner zahlenkolonne alle genommen werden -// //if(fileList.at(i).fileName().left(mFileBase.length())==mFileBase) -// if((fileList.at(i).completeBaseName().left(regexpNumAtEnd.indexIn(fileList.at(i).completeBaseName())) == mFileBase) && -// (fileList.at(i).suffix() == mFileInfo.suffix())) -// mImgFilesList << fileList.at(i).filePath(); - // Get the information of the animation if (!getInfoPhoto()) return false; @@ -711,16 +632,10 @@ cv::Mat Animation::getFramePhoto(int index) // Check if the index is valid if(index < getSourceInFrameNum() || index > getSourceOutFrameNum()) return cv::Mat(); - // Load the image at a temporary IplImage structure - // We need to do this because a loaded IplImage cannot be accessed directly - // = cvLoadImage((mImgFilesList.at(index).toStdString()).c_str(), -1); - - /// See: http://docs.opencv.org/3.0-beta/modules/imgcodecs/doc/reading_and_writing_images.html#imread -// Mat tempMat; -// tempMat mImage = cv::imread(mImgFilesList.at(index).toStdString(),cv::IMREAD_UNCHANGED);//CV_LOAD_IMAGE_UNCHANGED); + // Check for invalid input if( mImage.empty() ) // Check for invalid input { debout << "Could not open or find the image" << std::endl ; @@ -732,7 +647,6 @@ cv::Mat Animation::getFramePhoto(int index) mImage = imread(mImgFilesList.at(index).toStdString(),cv::IMREAD_COLOR); } // Check image size of each frame - //debout << "mat.cols: " << tempMat.cols << " : " << mSize.width() << " tempMat.rows: " << tempMat.rows << " : " << mSize.height() << endl; if( (mSize.width() > 0 && mSize.height() > 0) && (mImage.cols != mSize.width() || mImage.rows != mSize.height()) ) { debout << "Could not load image: image size differs in image sequence" << std::endl; @@ -747,39 +661,10 @@ cv::Mat Animation::getFramePhoto(int index) return cv::Mat(); } - - //debout << "[" << mImgFilesList.at(index).toStdString() << "]: Channels: " << tempMat.channels() << endl; - - /// - //debout << "mVideoCapture >> tempMat" << endl; - //mVideoCapture.open(mImgFilesList.at(index).toStdString()); - //mVideoCapture >> tempMat; - //debout << "Size: " << tempMat.cols << "x" << tempMat.rows << " channels: " << tempMat.channels() << " depth: " << tempMat.depth() << endl; - //IplImage* tempImg = cvCreateImage(cvSize(tempMat.cols,tempMat.rows), 8, 3); -// IplImage* tempImg = cvCreateImage(cvSize(tempMat.cols,tempMat.rows), 8, tempMat.channels()); -// tempImg->imageData = (char *) tempMat.data; -// debout << "it works!" << endl; -// cvNamedWindow("Test"); -// cvShowImage("Test",tempImg); -// cvWaitKey(); -// // Is it created? -// if (tempImg == NULL) -// return NULL; - // delete first old data - //cvReleaseImage(&mImage); darf nicht freigegeben werden -> absturz, aber speicher wird woanders freigegeben, keine speicheranhaeufung - // We create and copy the frame to our IplImage pointer -// cvReleaseImage(&mImage); // lieber vorher loeschen statt kopieren da ggf borderfilter bild groesser amcht?! -// mImage = cvCloneImage(tempImg); - // naechsten beiden zeilen entsprechen oberer: - //mImage = cvCreateImage(cvGetSize(mTempImg), 8, 3); - //cvCopy(mTempImg, mImage, 0); - // We release the temporary IplImage -// cvReleaseImage(&tempImg); // We set the current frame index mCurrentFrame = index; - // Return the pointer } - return mImage; //applyFilter(mImage); + return mImage; } @@ -825,7 +710,6 @@ void Animation::freePhoto() // Release the image pointer if (!mImage.empty()) { -// cvReleaseImage(&mImage); mImage = cv::Mat(); } // Clear the list of filenames in the serie @@ -984,42 +868,21 @@ bool Animation::openAnimationStereoVideo(QString fileName) /// Opens an animation from a video file bool Animation::openAnimationVideo(QString fileName) { - ///CvCapture *capture = NULL; - - // Create the capture device - ///capture = cvCreateFileCapture(fileName.toStdString().c_str()); - if( !mVideoCapture.open(fileName.toStdString().c_str()) ) return false; - ////if (capture != NULL) if(mVideoCapture.isOpened()) { - ////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 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); - //int convertRgb = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_CONVERT_RGB); - //debout << width << " " << height << " " << fps << " " << fourcc << " "<< frameCount<< " "<< propFormat<< " "<< convertRgb <<endl; - // stereoVideo: 1280 960 16 0 640 0 0 - // JSC_Boltes_Daenemark_DTU_Experimente\Exercise\exam1: 720 480 29 1685288548 3359 0 0 -// debout << "w: " << width << " h: " << height << " fps: " << fps << endl; if ((width == 1280) && (height == 960) && (fps == 16)) // dann gehe ich von einem stereo video der BBX3 aus!!! { - ////cvReleaseCapture(&capture); - ////capture = NULL; mVideoCapture.release(); mStereo = true; } } // Check if it was created succesfully - //debout << "Versuch folgende Datei zu oeffnen " << fileName.toStdString().c_str() <<endl; - ////if(capture == NULL) if(!mVideoCapture.isOpened()) { #if STEREO && not STEREO_DISABLED @@ -1065,7 +928,6 @@ bool Animation::openAnimationVideo(QString fileName) delete mCaptureStereo; } #endif - ////mCapture = capture; // Set new video & photo labels mStereo = false; mVideo = true; @@ -1094,19 +956,11 @@ cv::Mat Animation::getFrameVideo(int index) if (mCameraLiveStream) { -// IplImage* tempImg; -// Mat tempMat; if (mVideoCapture.read(mImage/*tempMat*/) ) { -// tempImg = cvCreateImage(cvSize(tempMat.cols,tempMat.rows), 8, 3); -// tempImg->imageData = (char *) tempMat.data; - if (mImage.empty())//tempImg == NULL) return cv::Mat(); -// cvReleaseImage(&mImage); -// mImage = cvCloneImage(tempImg); -// cvReleaseImage(&tempImg); mCurrentFrame++; } return mImage; @@ -1120,7 +974,6 @@ cv::Mat Animation::getFrameVideo(int index) if (mVideo && !mStereo) { // Check if we have a valid capture device - ////if (mCapture == NULL) if (!mVideoCapture.isOpened()) return cv::Mat(); // Now we need to see if it is necessary to seek for the frame or if we can use @@ -1128,9 +981,6 @@ cv::Mat Animation::getFrameVideo(int index) // This is tested since the seek function takes a lot of time! if (index == getSourceInFrameNum() || mCurrentFrame+1 != index) { - // OLD - ////cvSetCaptureProperty(mCapture, CV_CAP_PROP_POS_FRAMES, index); - // NEW if( !mVideoCapture.set(cv::CAP_PROP_POS_FRAMES, index) ) { debout << "Error: video file does not support skipping." << std::endl; @@ -1138,14 +988,8 @@ cv::Mat Animation::getFrameVideo(int index) } } // Query the frame - // = cvQueryFrame(mCapture); -// IplImage* tempImg; -// Mat tempMat; - if( mVideoCapture.read(mImage))//tempMat) ) + if( mVideoCapture.read(mImage)) { -// tempImg = cvCreateImage(cvSize(tempMat.cols,tempMat.rows), 8, 3); -// tempImg->imageData = (char *) tempMat.data; - if (mImage.empty())//tempImg == NULL) return cv::Mat(); }else @@ -1153,77 +997,8 @@ cv::Mat Animation::getFrameVideo(int index) debout << "Warning: number of frames in the video seems to be incorrect. Frame[" << index << "] is not loadable! Set number of Frames to " << index << "." << std::endl; mSourceOutFrame = index-1; setSourceOutFrameNum(mSourceOutFrame); - //mNumFrames = index - getSourceInFrameNum(); return cv::Mat(); } - // --------------------------------------------------------- diese zwei zeilen - -// cvReleaseImage(&mImage); -// mImage = cvCloneImage(tempImg); -// cvReleaseImage(&tempImg); - //if (mImage) debout << "mImage: " << mImage << " " << (void *)mImage->imageData <<endl; - //if (tempImg) debout << "tempImg: " << tempImg << " " << (void *)tempImg->imageData <<endl; - -// ---------------------------- ersetzen seit 17.07.2012 folgenden Bereich ---- von hier -// // We create and copy the frame to our IplImage pointer -// // es musste mal nicht geswapped/gespiegelt werden um x achse -//#if (CV_MAJOR_VERSION < 2) -// if (tempImg->origin == 0) // pixel begin on top left -// { -// //if (mImage) -// //cvCopy(tempImg, mImage); // geht nicht, da border das bild groesser machen kann -// if (mImage) -// { -// cvReleaseImage(&mImage); -// mImage = NULL; -// } -// mImage = cvCloneImage(tempImg); // cvCreateImage(cvGetSize(tempImg), 8, 3); -// } -// else // tempImg->origin == 1 begin on bottom left (Windows bitmaps style) -//#endif -// { -// if (mImage) -// { -// cvReleaseImage(&mImage); -// mImage = NULL; -// } -// mImage = cvCreateImage(cvGetSize(tempImg), 8, 3); -// // folgende beiden zeilen duerften effizienter sein, aber fuerhte zum absturz im 2. durchlauf -// //if (!mImage) // beim allerersten Aufruf -// // mImage = cvCreateImage(cvGetSize(tempImg), 8, 3); -// char *dataIn; -// char *dataOut = mImage->imageData - 1; -// int lineLen = tempImg->width*tempImg->nChannels; - -// for (int i = mImage->height-1; i >= 0 ; --i) -// { -// dataIn = tempImg->imageData + i*lineLen - 1; // to swap data we go from bottom to top -// for (int j = 0; j < mImage->width; ++j) -// { -// //cout << i << " " << j << endl; -// *(++dataOut) = *(++dataIn); -// *(++dataOut) = *(++dataIn); -// *(++dataOut) = *(++dataIn); -// } -// } -// } -// --------------------------------------------- bis hier - // from now on the image is indexed from top left on windows and linux - //cvCopy(tempImg, mImage, NULL); - - /* - ATTENTION! The temp image cannot be released if we are capturing from a video. - If you try to, you will get a very long to find bug ;-) - (See that we do it when capturing photos!) - //We release the temporary IplImage - cvReleaseImage(&tempImg); -// You must make capture = 0 before releasing it! -// capture = cvQueryFrame(camera); -// [...] -// capture = 0; -// cvReleaseImage( &capture ); - - */ } #ifndef STEREO_DISABLED else if (mStereo && mCaptureStereo)// stereo video @@ -1252,7 +1027,6 @@ bool Animation::getInfoVideo(QString /*fileName*/) { // Set the size of the frames // We will grab the information from a frame of the animation - //mNumFrames = 1000; setSourceInFrameNum(0); cv::Mat tempImg = getFrameVideo(getSourceInFrameNum()); if (tempImg.empty()) @@ -1271,67 +1045,10 @@ bool Animation::getInfoVideo(QString /*fileName*/) // Release the temporary frame // 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)); mOriginalFps = mVideoCapture.get(cv::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 : - // - In Linux will hack it through avinfo - // - In Windows will trust the VfW implementation of OpenCV - -// //Linux Hack! -//#ifdef LINUX -// // We will call avinfo to get the duration of the video in seconds. -// // Avinfo returns the number of seconds rounded down to the next integer. -// // The frames of the last second won't be used, since we don't know how many frames are in the last second. - -// // Build the command string -// // We'll call avinfo so it prints its output to avinfo.tmp - -// QString command = "avinfo "; -// command += fileName; -// command += " >avinfo.tmp"; -// char buffer[256]; -// strcpy(buffer,command.toStdString().c_str()); -// // System needs a const char *, that's why we need the char buffer[256] -// system(buffer); -// // After avinfo being done, we read avinfo.tmp -// ifstream dataFile; -// dataFile.open("avinfo.tmp"); -// char dummy; -// QString file; -// while (dataFile >> dummy) -// file += dummy; -// dataFile.close(); -// // We can delete the temporary file right now! -// strcpy(buffer, "rm avinfo.tmp"); -// system(buffer); -// // With a RegExp evaluator, we find the spot with the duration -// // It's format is (hh:mm:ss) -// QRegExp regExp("\\d\\d:\\d\\d:\\d\\d"); -// int ind = regExp.indexIn(file); -// // If the is no such place in the file, we don't know what to do -// if(ind == -1) -// { -// debout << "The number of frames could not be determined. Strange behaviour!" << endl; -// setSourceOutFrameNum(-1); -// return false; -// } -// QString duration = file.mid(ind,8); -// // Now we read the hours, minutes and seconds -// int hours, minutes, seconds; -// istringstream iss(duration.toStdString()); -// iss >> hours >> dummy >> minutes >> dummy >> seconds; -// // And we finally calculate the number of frames -// mMaxFrames = (int) (((60*hours + minutes)*60 + seconds)*getFPS()); -// ////mNumFrames = (int) cvGetCaptureProperty(mCapture,CV_CAP_PROP_FRAME_COUNT); -// mMaxFrames = (int) mVideoCapture.get(CV_CAP_PROP_FRAME_COUNT); -//#endif - // detect the used video codec int fourCC = static_cast<int>( mVideoCapture.get(cv::CAP_PROP_FOURCC) ); char FOURCC[] = {(char)( fourCC & 0XFF) , @@ -1339,12 +1056,8 @@ bool Animation::getInfoVideo(QString /*fileName*/) (char)((fourCC & 0XFF0000) >> 16), (char)((fourCC & 0XFF000000) >> 24), 0}; - //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 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 ) @@ -1382,7 +1095,6 @@ bool Animation::getInfoVideo(QString /*fileName*/) { debout << "Error: Incorrect number ("<<getNumFrames()<<") of frames. Setting it to "<<defaultFrames<<"." << std::endl; mSourceOutFrame = getSourceInFrameNum()+defaultFrames; - //mNumFrames = defaultFrames; } if (getNumFrames() > maxFrames)// = 6h * 60mins * 60 secs * 25 frames { @@ -1391,9 +1103,6 @@ bool Animation::getInfoVideo(QString /*fileName*/) } setSourceOutFrameNum(mSourceOutFrame); return true; - -// // Print some info about the video.. -// debout << "The video (" << fileName.toStdString() << ") is a " << getSize().width() << "X" << getSize().height() << " with " << getFPS() << "fps and has " << getNumFrames() << " frames." << endl; } bool Animation::getCameraInfo() @@ -1415,7 +1124,6 @@ bool Animation::getCameraInfo() // Release the temporary frame // 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)); mOriginalFps = mVideoCapture.get(cv::CAP_PROP_FPS); @@ -1430,12 +1138,6 @@ bool Animation::getCameraInfo() void Animation::freeVideo() { // Release the capture device - ////if (mCapture != NULL) - ////{ - //// cvReleaseCapture(&mCapture); - //// mCapture = NULL; - ////} - /// Close VideoCapturer if (mVideoCapture.isOpened()) { mVideoCapture.release(); @@ -1443,7 +1145,6 @@ void Animation::freeVideo() // Release the image pointer if (!mImage.empty()) { -// cvReleaseImage(&mImage); mImage = cv::Mat(); } diff --git a/src/autoCalib.cpp b/src/autoCalib.cpp index 1074aad14..8e6c6c023 100644 --- a/src/autoCalib.cpp +++ b/src/autoCalib.cpp @@ -97,7 +97,6 @@ bool AutoCalib::openCalibFiles() mCalibFiles = calibFiles; return true; } - //cout << mCalibFiles.first().toStdString() << endl; //toAscii() .data() Local8Bit().constData() << endl; } return false; } @@ -224,8 +223,7 @@ void AutoCalib::autoCalib() // run calibration bool ok = runCalibration( image_points, view.size(), board_size, - square_size, aspect_ratio, flags, camera_matrix, dist_coeffs, &reproj_errs);//, extr_params);//, -// &reproj_errs);//, &avg_reproj_err ); + square_size, aspect_ratio, flags, camera_matrix, dist_coeffs, &reproj_errs); debout << (ok ? "Calibration succeeded." : "Calibration failed.") << std::endl; // "Avgage reprojection error is " << avg_reproj_err << endl; debout << "Intrinsic reprojection error is: " << reproj_errs << std::endl; @@ -235,13 +233,11 @@ void AutoCalib::autoCalib() debout << "( " << camera_matrix.at<double>(0,0) << " " << camera_matrix.at<double>(0,1) << " " << camera_matrix.at<double>(0,2) << ")" << std::endl; debout << "( " << camera_matrix.at<double>(1,0) << " " << camera_matrix.at<double>(1,1) << " " << camera_matrix.at<double>(1,2) << ")" << std::endl; debout << "( " << camera_matrix.at<double>(2,0) << " " << camera_matrix.at<double>(2,1) << " " << camera_matrix.at<double>(2,2) << ")" << std::endl; - // debout << camera_matrix << endl; debout << "Distortioncoefficients: " << std::endl; debout << "r2: " << dist_coeffs.at<double>(0,0) << " r4: " << dist_coeffs.at<double>(0,1) << " r6: " << dist_coeffs.at<double>(0,4) << std::endl; debout << "tx: " << dist_coeffs.at<double>(0,2) << " ty: " << dist_coeffs.at<double>(0,3) << std::endl; debout << "k4: " << dist_coeffs.at<double>(0,5) << " k5: " << dist_coeffs.at<double>(0,6) << " k6: " << dist_coeffs.at<double>(0,7) << std::endl; - // debout << dist_coeffs << endl; // set calibration values mControlWidget->setCalibFxValue(camera_matrix.at<double>(0,0)); diff --git a/src/backgroundFilter.cpp b/src/backgroundFilter.cpp index e8a76b4ab..4fac998f7 100644 --- a/src/backgroundFilter.cpp +++ b/src/backgroundFilter.cpp @@ -25,7 +25,7 @@ #include <opencv2/highgui.hpp> #include "helper.h" -// spaeter entfernen naechsten beiden zeilen +//TODO spaeter entfernen naechsten beiden zeilen #include "control.h" extern Control *cw; @@ -37,20 +37,12 @@ extern Control *cw; /// Anzahl der Pixel, die ein Vordergrund aufweisen muss #define MIN_FOREGROUND_AREA -1000 // war:-400 -//#define SHOW_TMP_IMG BackgroundFilter::BackgroundFilter() :Filter() { setOnCopy(false); // da img nur ausgelesen, aber bnicht veraendert wird kann auf eine kopie verzichtet werden (true ist default bei filter) - -// mBgModel = createBackgroundSubtractorMOG2().dynamicCast<BackgroundSubtractor>(); - -// mBgModel = method == "knn" ? createBackgroundSubtractorKNN().dynamicCast<BackgroundSubstractor>() : -// createBackgroundSubtractorMOG2().dynamicCast<BackgroundSubstractor>();//.dynamicCast<BackgroundSubtractorMOG2>(); -// mBgPointCloud = NULL; -// mForeground = NULL; mLastFile = ""; } @@ -86,10 +78,7 @@ bool BackgroundFilter::isForeground(int coloumn, int row) /// zuruecksetzen, wenn zB helligkeit veraendert wird oder schaerfe void BackgroundFilter::reset() { - // funktioniert nicht wirklich -// if (!mBgModel.empty()) if (!mForeground.empty()) mForeground = cv::Scalar::all(0); -// mBgModel = createBackgroundSubtractorMOG2();//->initialize(mForeground.size, mForeground.type()); if (!mBgModel.empty()) mBgModel->clear(); setChanged(true); @@ -228,12 +217,7 @@ bool BackgroundFilter::load(QString dest) //default = "" if (!dest.isEmpty()) { - //* CV_LOAD_IMAGE_COLOR the loaded image is forced to be a 3-channel color image - //* CV_LOAD_IMAGE_GRAYSCALE the loaded image is forced to be grayscale - //* CV_LOAD_IMAGE_UNCHANGED the loaded image will be loaded as is. - cv::Mat bgImg = cv::imread(dest.toStdString(),cv::IMREAD_GRAYSCALE); -// IplImage *bgImg = cvLoadImage(dest.toStdString().c_str(), CV_LOAD_IMAGE_GRAYSCALE); if (bgImg.empty()) { debout << "Error: could not read background subtraction file " << dest << "!" <<std::endl; @@ -248,19 +232,6 @@ bool BackgroundFilter::load(QString dest) //default = "" memmove(&min, bgImg.data, sizeof(float)); memmove(&max, bgImg.data+sizeof(float), sizeof(float)); -// debout << bgImg->depth << " " << bgImg->nChannels << endl; -// debout << (int)*((char *) bgImg->imageData) << " " -// << (int)*(((char *) bgImg->imageData)+1) << " " -// << (int)*(((char *) bgImg->imageData)+2) << " " -// << (int)*(((char *) bgImg->imageData)+3) <<endl; -// debout << min << " " << max << endl; -// double dmin, dmax; -// cvMinMaxLoc(bgImg, &dmin, &dmax); -// debout << dmin << " " << dmax << endl; - -//cvNamedWindow("CVdisp", CV_WINDOW_AUTOSIZE); -//cvShowImage("CVdisp", bgImg); - if (sizeof(float) != 4) debout << "Warning: the height range coded inside the background picture is not portable!" << std::endl; @@ -338,34 +309,13 @@ pet::StereoContext** BackgroundFilter::stereoContext() return mStereoContext; } -// interessante dateien zur backgroundsubtraction: -// c:/Programme/OpenCV/samples/c/bgfg_segm.cpp -// c:/Programme/OpenCV/cvaux/include/cvaux.h -// http://opencvlibrary.sourceforge.net/VideoSurveillance -// opencv buch: S. 265 -// opencv pdf: S. 414 cv::Mat BackgroundFilter::act(cv::Mat &img, cv::Mat &res) { -// Mat img = cvarrToMat(imgIpl); -// res = cvarrToMat(resIpl); -// return act(img,res); #ifdef SHOW_TMP_IMG namedWindow("BackgroundFilter"); imshow("BackgroundFilter",img); waitKey(); #endif -// debout << "BackgroundFilter act ... img->nChannels: " << img->nChannels << " res->nChannels: " << res->nChannels << endl; -// static IplImage * img3c = NULL; -// static CvFGDStatModelParams* params = NULL; //new CvFGDStatModelParams; - - -// cvRunningAvg(img, acc, 1./num); -// // nach lernen -// cvAbsDiff(acc, img, mask); -// cvThreshold(mask, mask, 15, 255, CV_THRESH_BINARY); - -//BackgroundSubtractorMOG - if ((mBgPointCloud.empty() && mBgModel.empty()) || mForeground.empty() || mForeground.size != img.size) // initialisierung wenn entwerder stereo oder model { #ifndef STEREO_DISABLED @@ -451,19 +401,9 @@ waitKey(); if(!mBgModel.empty()) mBgModel->clear(); - mBgModel = cv::createBackgroundSubtractorMOG2();//.dynamicCast<BackgroundSubtractor>(); -// mBgModel->setVarThreshold(10); -// mBgModel->setNMixtures(5); -// mBgModel->setHistory(75); -// mBgModel->setDetectShadows(false); -// mBgModel->setBackgroundRatio(2); -// mBgModel->set("noiseSigma", 30); -// mBgModel->setInt("learningRate", 200); -// mForeground = mBgModel->getForegroundImage(); - + mBgModel = cv::createBackgroundSubtractorMOG2(); mForeground.create(cv::Size(img.cols,img.rows),CV_8UC1); - //Mat temp_img, temp_foreg_img; mBgModel->apply(img,mForeground,1); @@ -472,67 +412,11 @@ namedWindow("BackgroundFilter"); imshow("BackgroundFilter",mForeground); waitKey(); #endif - //mBgModel->apply(img,mForegroundMask, update_bg_model ? -1 : 0); - //mBgModel->getForegroundImage(mForeground); - //mBgModel->getBackgroundImage(mBackground); - //mBgModel->apply(img,mForeground); // FGDStatModel --------------------------------------------------------------------------------------------------------------------- // DOCUMENTATION: http://opencv.willowgarage.com/wiki/VideoSurveillance -// if (img3c == NULL) -// img3c = cvCreateImage(cvSize(img->width, img->height), 8, 3); // wird nie freigegeben aber auch nur 1 x angelegt - -// cvConvertImage(img, img3c); - -//// int Lc; /* Quantized levels per 'color' component. Power of two, typically 32, 64 or 128. */ -//// int N1c; /* Number of color vectors used to model normal background color variation at a given pixel. */ -//// int N2c; /* Number of color vectors retained at given pixel. Must be > N1c, typically ~ 5/3 of N1c. */ -//// /* Used to allow the first N1c vectors to adapt over time to changing background. */ - -//// int Lcc; /* Quantized levels per 'color co-occurrence' component. Power of two, typically 16, 32 or 64. */ -//// int N1cc; /* Number of color co-occurrence vectors used to model normal background color variation at a given pixel. */ -//// int N2cc; /* Number of color co-occurrence vectors retained at given pixel. Must be > N1cc, typically ~ 5/3 of N1cc. */ -//// /* Used to allow the first N1cc vectors to adapt over time to changing background. */ - -//// int is_obj_without_holes;/* If TRUE we ignore holes within foreground blobs. Defaults to TRUE. */ -//// int perform_morphing; /* Number of erode-dilate-erode foreground-blob cleanup iterations. */ -//// /* These erase one-pixel junk blobs and merge almost-touching blobs. Default value is 1. */ -// // 0 am schnellsten, 1 glaettet insb raender etwas, 2 wird schon zu viel verworfen - -//// float alpha1; /* How quickly we forget old background pixel values seen. Typically set to 0.1 */ -//// float alpha2; /* "Controls speed of feature learning". Depends on T. Typical value circa 0.005. */ -//// float alpha3; /* Alternate to alpha2, used (e.g.) for quicker initial convergence. Typical value 0.1. */ -// // alpha2 = 0 + alpha3 = 1 laesst nicht neu lernen - -//// float delta; /* Affects color and color co-occurrence quantization, typically set to 2. */ -//// float T; /* "A percentage value which determines when new features can be recognized as new background." (Typically 0.9).*/ -//// float minArea; /* Discard foreground blobs whose bounding box is smaller than this threshold. */ - -// mBgModel = cvCreateFGDStatModel(img3c); // ohne , params werden default-werte gesetzt // <- fkt frueher mit grossen bildern wg speichermengenproblem nicht, nun muss nur noch 3 channel bild sein!!! https://code.ros.org/trac/opencv/ticket/31 -// params = &(((CvFGDStatModel *)mBgModel)->params); // cast, da mBgModel allgemeiner pointer auf model -//// debout << params->Lc << endl; -//// debout << params->N1c << endl; -//// debout << params->N2c << endl; -//// debout << params->Lcc << endl; -//// debout << params->N1cc << endl; -//// debout << params->N2cc << endl; -//// debout << params->is_obj_without_holes << endl; -//// debout << params->perform_morphing << endl; -//// debout << params->alpha1 << endl; -//// debout << params->alpha2 << endl; -//// debout << params->alpha3 << endl; -//// debout << params->delta << endl; -//// debout << params->T << endl; -//// debout << params->minArea << endl; - -// params->perform_morphing = 0; -// params->alpha2 = 0.1; -// params->alpha3 = 1; -// params->minArea = 0; -// cvUpdateBGStatModel(img3c, mBgModel); // das erste mal mit neuen parametern und mit initalem bild - } // nicht stereo } else // nicht initialisierung @@ -612,46 +496,11 @@ waitKey(); else // nicht stereo { - // params = &(((CvFGDStatModel *)mBgModel)->params); - //// params->perform_morphing = cw->r2->value()*1000; - //// params->alpha1 = cw->r4->value()*1000; - //// params->alpha2 = cw->tx->value()*1000; - //// params->alpha3 = cw->ty->value()*1000; - //// debout << params->perform_morphing << endl; - //// debout << params->alpha1 << endl; - //// debout << params->alpha2 << endl; - //// debout << params->alpha3 << endl; - - // cvConvertImage(img, img3c); - - // if (update()) - // { - // params->alpha2 = 0.1; - // cvUpdateBGStatModel(img3c, mBgModel); // default -1 das Hintergrundmodell wird mit aktuellem Bild aktualisiert - // } - // else - // { - // params->alpha2 = 0; - // cvUpdateBGStatModel(img3c, mBgModel, 0); // der letzte Parameter bewirkt bei FGD nichts, daher param geaendert - // } - - // GaussBGStatModel --------------------------------------------------------------------------------------------------------------------- mBgModel->apply(img, mForeground, update() ? -1 : 0); -// if (update()) -// { -// mBgModel->apply(img,mForeground,-1); -// //mBgModel->apply(img,mForeground); -// } -// else -// { -// mBgModel->apply(img,mForeground,0); -// //mBgModel->apply(img,mForeground,0); -// } - #ifdef SHOW_TMP_IMG imshow("BackgroundFilter",img); waitKey(); @@ -685,20 +534,13 @@ waitKey(); imshow("BackgroundFilter",mForeground); waitKey(); #endif - // cvErode(mForeground, mForeground, NULL, 1); -// cvDilate(mForeground, mForeground, NULL, 2); - //cvErode(mForeground, mForeground, NULL, 1); // weggelassen, dadurch hintergrund etwas groesser - // loecher schliessen ------------------------------------------------------------------------------------------------------------ // floodfill den aussenbereich und suchen nach ungefuelltem koennte auch loechder finden alssen std::vector<std::vector<cv::Point> > contours; double contourArea; -// 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); -// cvFindContours(mForeground, storage, &contour, sizeof(CvContour), -// CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE); // foreground wird auch veraendert??? + // test each contour while (!contours.empty()) @@ -708,214 +550,27 @@ waitKey(); contourArea = cv::contourArea(contour, true); if (contourArea > 0 && contourArea < 400) // kleine innere loecher schliessen { -// pointArray = (CvPoint*)malloc(contour->total*sizeof(CvPoint)); // Get contour point set. -// cvCvtSeqToArray(contour, pointArray, CV_WHOLE_SEQ); - //debout << contourArea << " " << pointArray->x << " " << pointArray->y << endl; cv::fillPoly(mForeground,cv::Mat(contour),cv::Scalar::all(1)); -// cvFillPoly(mForeground, &pointArray , &(contour->total), 1, cvScalar(1,1,1,1)); // int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); - // folgende fkt nur fuer konvexe, daher bleiben einige bereiche nicht eingezeichnet - //cvFillConvexPoly(mForeground, pointArray , contour->total, cvScalar(1,1,1,1)); // int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); -// free(pointArray); } else if (contourArea > MIN_FOREGROUND_AREA -400) // kleine Bereiche werden eliminiert, dies koennte in Abhaengigkeit von der disparity gemacht werden!!!!!!!! { -// pointArray = (CvPoint*)malloc(contour->total*sizeof(CvPoint)); // Get contour point set. -// cvCvtSeqToArray(contour, pointArray, CV_WHOLE_SEQ); - //debout << contourArea << " " << pointArray->x << " " << pointArray->y << endl; cv::fillPoly(mForeground,cv::Mat(contour),cv::Scalar::all(0)); -// cvFillPoly(mForeground, &pointArray , &(contour->total), 1, cvScalar(0,0,0,0)); // int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); -// free(pointArray); } - // in rot contouren in eine drehrichtung, in gruen andere - //cvDrawContours(img,contour,CV_RGB(255,0,0),CV_RGB(0,255,0),0,1,8,cvPoint(0,0)); - //cvDrawContours(res,contour,CV_RGB(255,0,0),CV_RGB(0,255,0),0,1,8,cvPoint(0,0)); // take the next contour contours.pop_back(); -// contour = contour->h_next; } #ifdef SHOW_TMP_IMG imshow("BackgroundFilter",mForeground); waitKey(); #endif -// cvReleaseMemStorage(&storage); } -// Bild gemaess maske einfaerben --------------------------------------------------------------------------------------------------------------------- - -// int x, y; - -// // background set to color -// int r = 255; -// int g = 255; -// int b = 0; -//// debout << res->height << " " << res->width << " " << res->nChannels << " " << res->depth << endl; -//// debout << mForeground->height << " " << mForeground->width << " " << mForeground->nChannels << " " << mForeground->depth << endl; - -// // Pointer to the data information in the IplImage -// unsigned char *dataIn = (unsigned char *) img->imageData; -// unsigned char *dataOut = (unsigned char *) res->imageData; -// // foreground ist entweder 0=Hintergrund oder 255=fordergrund -// unsigned char *mask = (unsigned char *) mForeground->imageData; -// // set poiner to value before array, because ++i is more effective than i++ -// --dataIn; --dataOut; --mask; - -// if (res->nChannels == 3) -// { -// for (y = 0; y < res->height; ++y) -// { -// for (x = 0; x < res->width; ++x) -// { - -// if (((int)*(++mask)) != 0) -// { -// *(++dataOut) = *(++dataIn); -// *(++dataOut) = *(++dataIn); -// *(++dataOut) = *(++dataIn); -// } -// else -// { -// dataIn+=3; -// *(++dataOut) = b; -// *(++dataOut) = g; -// *(++dataOut) = r; -// } -// // if ((x < 410) && (y < 410) && (x > 400) && (y > 400)) -// // debout << ((int)*mask)<<endl; -// } -// } -// } -// else -// { -// for (y = 0; y < res->height; ++y) -// { -// for (x = 0; x < res->width; ++x) -// { - -// if (((int)*(++mask)) != 0) // *mask == 1, 2, 130 -// { -// *(++dataOut) = *(++dataIn); -// } -// else -// { -// ++dataIn; -// *(++dataOut) = r; -// } -// // if ((x < 410) && (y < 410) && (x > 400) && (y > 400)) -// // debout << ((int)*mask)<<endl; -// } -// } -// } -//// debout << res->height << " " << res->width << " " << res->nChannels << " " << res->depth << endl; -//// debout << mForeground->height << " " << mForeground->width << " " << mForeground->nChannels << " " << mForeground->depth << endl; -//// cvNamedWindow("BG", 1); -//// cvNamedWindow("FG", 1); -//// cvShowImage("BG", mBgModel->background); -//// cvShowImage("FG", mBgModel->foreground); - -// resIpl = cvCreateImage(cvSize(res.cols,res.rows),8,3); -// IplImage tmpIpl = res; -// cvCopy(&tmpIpl,resIpl); return res; } - -// Three cpp files whose names are starting with "cvbgfg" under OpenCV\cvaux\src -// They are "cvbgfg_common.cpp", "cvbgfg_gaussmix.cpp" and "cvbgfg_acmmm2003.cpp". - -// I'm not sure about "cvbgfg_common.cpp"(Maybe, I guess from the name, -// it has some common functions of background subtraction methods). - -// "cvbgfg_gaussmix.cpp" has to do with CvGaussBGModel and the -// implementation is based on the paper "An Improved Adaptive -// Background Mixture Model for Real-time Tracking and Shadow -// Detection" by P. KaewTraKulPong and R. Bowden in Proc. 2nd European -// Workshp on Advanced Video-Based Surveillance Systems, 2001. - -// "cvbgfg_acmmm2003.cpp" has to do with CvFGDStatModel and the -// implemenation is based on the paper "Foreground Object Detection -// from Videos Containing Complex Background." by Liyuan Li, Weimin -// Huang, Irene Y.H. Gu, and Qi Tian in ACM-MM 2003. - -// So there are two ways of background subtraction I'm not sure about -// the difference between the two approaches. However I'm using -// CvGaussBGModel since I saw the word "real-time" in the paper title, -// even though the paper of CvFGDStatModel is more recent. - -// So if you want to use CvGaussBGModel, the following will be an -// example. - -// IplImage* img = NULL; -// CvCapture* cap = NULL; -// cap = cvCaptureFromFile(file_name); -// img = cvQueryFrame(cap); -// CvBGStatModel* background_model = cvCreateGaussianBGModel(img); -// for(int fr = 1; img; img = cvQueryFrame(cap), fr++) { -// cvUpdateBGStatModel(img, background_model); -// } - -// And if you want to use CvFGDStatModel, you can just change the -// initialization as following. - -// CvBGStatModel* background_model = cvCreateFGDStatModel(img); -// for(int fr = 1; img; img = cvQueryFrame(cap), fr++) { -// cvUpdateBGStatModel(img, background_model); -// } - - -// siehe auch mitgeliefertes Beispiel unter C:\Programme\OpenCV\samples\c\bgfg_segm.cpp - -// cap = cvCaptureFromFile("pedes.avi"); -// tmp_frame = cvQueryFrame(cap); -// if(!tmp_frame) -// { -// printf("bad video \n"); -// exit(0); -// } -// cvNamedWindow("BG", 1); -// cvNamedWindow("FG", 1); -// //create BG model -// CvBGStatModel* bg_model = cvCreateGaussianBGModel( tmp_frame ); -// for( int fr = 1;tmp_frame; tmp_frame = cvQueryFrame(cap), fr++ ) -// { -// double t = (double)cvGetTickCount(); -// cvUpdateBGStatModel( tmp_frame, bg_model ); -// t = (double)cvGetTickCount() - t; -// printf( "%.1f\n", t/(cvGetTickFrequency()*1000.) ); -// cvShowImage("BG", bg_model->background); -// cvShowImage("FG", bg_model->foreground); -// int k = cvWaitKey(5); -// if( k == 27 ) break; -// printf("frame# %d \n", fr); -// } -// cvReleaseBGStatModel( &bg_model ); -// cvReleaseCapture(&cap); - - - -// if you have an image of the background, you can subtract the -// background from the given image with cvSub. - -// Example: cvSub(image_of_background, given_image, destination_image, NULL); - -// To totaly eleminate the background you can compare background_image to -// given_image to create a mask: - -// cvAbsDiff(image_of_background, given_image, mask_image); - -// The outcome of this is a binary mask, which can now be combined with -// given_image: - -// IplImage* tmp = cvCloneImage(given_image); -// cvZero(given_image); -// cvCopy(tmp, given_image, mask); -// cvReleaseImage( &tmp); - -// Now given_image contains only foreground objects. - - // setzt in mat alle bg pixel auf val // bei mehreren Kanaelen nur den letzten Kanal // bisher nur fuer float @@ -923,12 +578,6 @@ void BackgroundFilter::maskBg(cv::Mat &mat, float val) { if (getEnabled() && !mForeground.empty()) { - -// debout << mat->type <<endl; -// debout << CV_32F <<endl; -// debout << CV_32FC3 <<endl; -// if (mat->type == CV_32F) //CV_32FC3 -// { int x, y; int lineLen = mat.cols/sizeof(float); @@ -943,8 +592,8 @@ void BackgroundFilter::maskBg(cv::Mat &mat, float val) { for (x = 0; x < mat.cols; ++x) { - //if (!isForeground(x, y)) - if(!*fgData) // mForeground->imageData[y*mForeground->width+x] 0 background, 1 foreground + // 0 background, 1 foreground + if(!*fgData) { *pcData = val; } @@ -954,8 +603,5 @@ void BackgroundFilter::maskBg(cv::Mat &mat, float val) pcData = (yPcData += lineLen); fgData = (yFgData += mForeground.cols); } -// } -// else -// debout << "Error: only type float is possible." <<endl; } } diff --git a/src/backgroundItem.cpp b/src/backgroundItem.cpp index 4038f56c3..ce803644c 100644 --- a/src/backgroundItem.cpp +++ b/src/backgroundItem.cpp @@ -32,9 +32,8 @@ BackgroundItem::BackgroundItem(QWidget *wParent, QGraphicsItem * parent) { mMainWindow = (class Petrack*) wParent; mImage = nullptr; - // setEnabled(false); // all mouse events connot access this item, but it will be seen + // setEnabled(false); // all mouse events cannot access this item, but it will be seen // einzig move koennte interessant sein, um grid zu verschieben?! -// setAcceptsHoverEvents(true); } /** @@ -80,15 +79,6 @@ void BackgroundItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */* auto* p = mImage->scanLine(y)-1; for (x = 0; x < fg.cols; x++) { -// if (*data == 1) -// { -// value = ((*data-min)*255)/(max-min); // for greyscale -// color.setHsv(0, 0, value<0?0:(value>255?255:value), 255); // 0=rot, 240=blau, nicht 359, da sich Farbkreis wieder schliesst -// } -// else -// { -// color.setRgb(0, 0, 0, (!mMainWindow->getStereoWidget()->hideWrong->isChecked())*255); //.setAlpha(0); -// } *(++p) = 255; // color.red(); *(++p) = 255; // color.green(); *(++p) = 255; // color.blue(); diff --git a/src/borderFilter.cpp b/src/borderFilter.cpp index 4d85e9f36..6e88dd013 100644 --- a/src/borderFilter.cpp +++ b/src/borderFilter.cpp @@ -45,109 +45,18 @@ BorderFilter::BorderFilter() mB.setFilter(this); setOnCopy(false); -// setOnCopy(true); } cv::Mat BorderFilter::act(cv::Mat &img, cv::Mat &res) { - //return img; - - -// int x, y; -// bool useOpenCVBorderFilter = true; - -// debout << "start borderFilter: " << getElapsedTime() <<endl; // border size int s = (int) mS.getValue(); // schon beim zuweisen auf param gemacht (2*, da undistord filter anscheinend sonst probleme hat) int r = (int) mR.getValue(); int g = (int) mG.getValue(); int b = (int) mB.getValue(); -// setResStored(true); // wofuer? - -// if (useOpenCVBorderFilter) -// { -// Mat img = cvarrToMat(imgIpl), -// res = cvarrToMat(resIpl); -// res.create(img.rows+2*s,img.cols+2*s,img.depth());//CV_8UC(img.channels())); -// debout << "res: " << res.cols << "x" << res.rows << endl; - cv::copyMakeBorder(img,res, s, s, s, s,cv::BORDER_CONSTANT,cv::Scalar(b,g,r)); -// debout << "res: " << res.cols << "x" << res.rows << endl; - // cvCopyMakeBorder( img, res, cv::Point2f(0,0), cv::BORDER_CONSTANT , cv::Scalar(r,g,b) ); -// cvReleaseImage(&resIpl); - -// resIpl = cvCreateImage(cvSize(res.cols,res.rows),8,3); -// IplImage tmpIpl = res; -// cvCopy(&tmpIpl,resIpl); - -// }else -// { -// CvSize sz = cvGetSize(imgIpl); - -// sz.width += 2*s; -// sz.height += 2*s; - -// if (imgIpl != resIpl) -// cvReleaseImage(&resIpl); - -// resIpl = cvCreateImage(sz, 8, imgIpl->nChannels); // war 8, 3 -// // resIpl->origin = imgIpl->origin; // because 1 - bottom-left origin (Windows bitmaps style) is not default!!! + cv::copyMakeBorder(img,res, s, s, s, s,cv::BORDER_CONSTANT,cv::Scalar(b,g,r)); -// // Pointer to the data information in the IplImage -// unsigned char *dataIn = (unsigned char *) imgIpl->imageData; -// unsigned char *dataOut = (unsigned char *) resIpl->imageData; -// // set poiner to value before array, because ++i is more effective than i++ -// --dataIn; --dataOut; -// unsigned char *yDataIn=dataIn, *yDataOut=dataOut; -// if (imgIpl->nChannels == 1) -// { -// for (y = 0; y < resIpl->height; ++y) -// { -// for (x = 0; x < resIpl->width; ++x) -// { -// if ((x >= s) && (x < s+imgIpl->width) && (y >= s) && (y < s+imgIpl->height)) -// *(++dataOut) = *(++dataIn); -// else -// // for 1 channel just blue is taken as grey value, because qt does not support grey color dialogs -// *(++dataOut) = b; -// } -// // we need this, because sometimes width != widthstep eg for width%4 != 0 -// if ((y >= s) && (y < s+imgIpl->height)) -// dataIn = (yDataIn+=imgIpl->widthStep); -// dataOut = (yDataOut+=resIpl->widthStep); -// } -// } -// else if (imgIpl->nChannels == 3) -// { -// for (y = 0; y < resIpl->height; ++y) -// { -// for (x = 0; x < resIpl->width; ++x) -// { -// if ((x >= s) && (x < s+imgIpl->width) && (y >= s) && (y < s+imgIpl->height)) -// { -// *(++dataOut) = *(++dataIn); -// *(++dataOut) = *(++dataIn); -// *(++dataOut) = *(++dataIn); -// } -// else -// { -// *(++dataOut) = b; -// *(++dataOut) = g; -// *(++dataOut) = r; -// } -// } -// // we need this, because sometimes width != widthstep eg for width%4 != 0 -// if ((y >= s) && (y < s+imgIpl->height)) -// dataIn = (yDataIn+=imgIpl->widthStep); -// dataOut = (yDataOut+=resIpl->widthStep); -// } -// } -// else -// { -// debout << "Error: Channel different than 1 and 3 should not be allowed!" << endl; -// } -// } -// debout << "end borderFilter: " << getElapsedTime() <<endl; return res; } diff --git a/src/brightContrastFilter.cpp b/src/brightContrastFilter.cpp index c99bc55de..fd236d6ae 100644 --- a/src/brightContrastFilter.cpp +++ b/src/brightContrastFilter.cpp @@ -33,10 +33,6 @@ BrightContrastFilter::BrightContrastFilter() mC.setMaximum(100.); mC.setValue(0.); mC.setFilter(this); - -// mLutMat = cvCreateMatHeader(1, 256, CV_8UC1); -// cvSetData(mLutMat, mLut, 0); -// setOnCopy(true); } cv::Mat BrightContrastFilter::act(cv::Mat &img, cv::Mat &res) @@ -52,42 +48,15 @@ cv::Mat BrightContrastFilter::act(cv::Mat &img, cv::Mat &res) delta = 127.*mC.getValue()/100.; a = 255./(255. - delta*2.); b = a*(mB.getValue() - delta); -// for (i = 0; i < 256; i++) -// { -// v = cvRound(a*i + b); -// if (v < 0) -// v = 0; -// else if (v > 255) -// v = 255; -// mLut[i] = (uchar) v; -// } } else { delta = -128.*mC.getValue()/100.; a = (256.-delta*2.)/255.; b = a*mB.getValue() + delta; -// for (i = 0; i < 256; i++) -// { -// v = cvRound(a*i + b); -// if (v < 0) -// v = 0; -// else if (v > 255) -// v = 255; -// mLut[i] = (uchar) v; -// } } -// cvLUT(imgIpl, resIpl, mLutMat); - img.convertTo(res,-1,a,b); -// LUT(img,mLutMat,res); -// cvReleaseImage(&resIpl); -// resIpl = cvCreateImage(cvSize(res.cols,res.rows),8,3); -// IplImage tmpIpl = res; -// cvCopy(&tmpIpl,resIpl); - - return res; } diff --git a/src/codeMarkerItem.cpp b/src/codeMarkerItem.cpp index f81b77687..e1798e304 100644 --- a/src/codeMarkerItem.cpp +++ b/src/codeMarkerItem.cpp @@ -78,7 +78,6 @@ void CodeMarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */* int nMarkers = mCorners.size(); int nRejected = mRejected.size(); -// debout << "#markers: " << nMarkers << " #rejected: " << nRejected << endl; cv::Point2f p0, p1; for(int i = 0; i < nMarkers; i++) // draws green square/ circle around head if person recognized { diff --git a/src/codeMarkerWidget.cpp b/src/codeMarkerWidget.cpp index f30db3c1b..1ea231268 100644 --- a/src/codeMarkerWidget.cpp +++ b/src/codeMarkerWidget.cpp @@ -50,12 +50,10 @@ CodeMarkerWidget::CodeMarkerWidget(QWidget *parent) dictList->addItem("DICT_ARUCO_ORGINAL"); // 16 dictList->addItem("DICT_mip_36h12");//17 - // Add some other marker dictionaries - //dictList->addItem("ARTOOLKIT"); - dictList->setCurrentIndex(16); } + //<COLOR_MARKER> // <MASK SHOW="0" OPACITY="100" MASK="1"/> // <FROM_COLOR HUE="0" SATURATION="0" VALUE="0"/> diff --git a/src/colorMarkerItem.cpp b/src/colorMarkerItem.cpp index 314840f0a..b9701c50b 100644 --- a/src/colorMarkerItem.cpp +++ b/src/colorMarkerItem.cpp @@ -101,7 +101,6 @@ void ColorMarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */ data = (yData += mMask.cols/sizeof(char)); // because sometimes widthStep != width } painter->setOpacity(mMainWindow->getColorMarkerWidget()->opacity->value()/100.); - //painter->drawImage(mMainWindow->getRecoRoiItem()->rect().x(),mMainWindow->getRecoRoiItem()->rect().y(), *mImage); // during hoverMoveEvent of recognitionRect the painting moves with rect painter->drawImage(mUlc.x(),mUlc.y(), *mImage); } diff --git a/src/colorMarkerWidget.cpp b/src/colorMarkerWidget.cpp index 7afad3eef..f3c380afc 100644 --- a/src/colorMarkerWidget.cpp +++ b/src/colorMarkerWidget.cpp @@ -45,6 +45,8 @@ ColorMarkerWidget::ColorMarkerWidget(QWidget *parent) col.setHsv(toHue, toSat, toVal); toTriangle->setColor(col); } + +// store data in xml node, as: //<COLOR_MARKER> // <MASK SHOW="0" OPACITY="100" MASK="1"/> // <FROM_COLOR HUE="0" SATURATION="0" VALUE="0"/> @@ -173,19 +175,15 @@ void ColorMarkerWidget::on_fromTriangle_colorChanged(const QColor &col) { fromHue = col.hue(); fromSat = col.saturation(); fromVal = col.value(); QString styleString = QString("background-color: hsv(%1,%2,%3)").arg(fromHue).arg(fromSat).arg(fromVal); - //QString styleString = QString("background-color: rgb(%1,%2,%3)").arg(col.red()).arg(col.green()).arg(col.blue()); fromColor->setStyleSheet(styleString); mMainWindow->setRecognitionChanged(true);// flag indicates that changes of recognition parameters happens if( !mMainWindow->isLoading() ) mMainWindow->updateImage(); - - //debout << col.hue() << " " << col.saturation() << " " << col.value() << endl; } void ColorMarkerWidget::on_toTriangle_colorChanged(const QColor &col) { toHue = col.hue(); toSat = col.saturation(); toVal = col.value(); QString styleString = QString("background-color: hsv(%1,%2,%3)").arg(toHue).arg(toSat).arg(toVal); - //QString styleString = QString("background-color: rgb(%1,%2,%3)").arg(col.red()).arg(col.green()).arg(col.blue()); toColor->setStyleSheet(styleString); mMainWindow->setRecognitionChanged(true);// flag indicates that changes of recognition parameters happens if( !mMainWindow->isLoading() ) @@ -196,8 +194,7 @@ void ColorMarkerWidget::on_fromColor_clicked() { // QWindowsXpStyle uses native theming engine which causes some palette modifications not to have any effect. // ueber palette war der button ausser initial nicht zu aendern!!! - - QColor colBefore;//fromColor->palette().color(QPalette::Button); + QColor colBefore; colBefore = QColor::fromHsv(fromHue, fromSat, fromVal); QColor col = (QColorDialog::getColor(colBefore, this, "Select color from which value a pixel belongs to marker")).convertTo(QColor::Hsv); if (col.isValid() && col != colBefore) @@ -211,34 +208,14 @@ void ColorMarkerWidget::on_toColor_clicked() { // QWindowsXpStyle uses native theming engine which causes some palette modifications not to have any effect. // ueber palette war der button ausser initial nicht zu aendern!!! - QColor colBefore;//toColor->palette().color(QPalette::Button); + QColor colBefore; colBefore = QColor::fromHsv(toHue, toSat, toVal); QColor col = (QColorDialog::getColor(colBefore, this, "Select color to which value a pixel belongs to marker")).convertTo(QColor::Hsv); - //QPalette palette = toColor->palette(); - //palette.setColor(QPalette::Button, col); - //toColor->setPalette(palette); - //toColor->setAutoFillBackground(true); if (col.isValid() && col != colBefore) { on_toTriangle_colorChanged(col); toTriangle->setColor(col); } -// Versuch mit hsv stabil werte einzugeben - wandern in hsv und rgb zur folge, wenn auch wenig -// // QWindowsXpStyle uses native theming engine which causes some palette modifications not to have any effect. -// // ueber palette war der button ausser initial nicht zu aendern!!! -// QColor col = QColorDialog::getColor(toColor->palette().color(QPalette::Button).toHsv(), this, "").toHsv(); -// //debout << col.hue()<<endl; -// //debout << col.saturation()<<endl; -// //debout << col.value()<<endl; -// //QPalette palette = toColor->palette(); -// //palette.setColor(QPalette::Button, col); -// //toColor->setPalette(palette); -// //toColor->setAutoFillBackground(true); -// if (col.isValid()) -// { -// QString styleString = QString("background-color: hsv(%1,%2,%3)").arg(col.hue()).arg(col.saturation()).arg(col.value()); -// toColor->setStyleSheet(styleString); -// } } #include "moc_colorMarkerWidget.cpp" diff --git a/src/colorPlot.cpp b/src/colorPlot.cpp index 0912cf0af..165d019a6 100644 --- a/src/colorPlot.cpp +++ b/src/colorPlot.cpp @@ -33,49 +33,15 @@ #include "control.h" #include "tracker.h" -// class SpectrogramData: public QwtRasterData -// { -// public: -// SpectrogramData(): -// QwtRasterData(QwtDoubleRect(-1.5, -1.5, 3.0, 3.0)) -// { -// } - -// virtual QwtRasterData *copy() const -// { -// return new SpectrogramData(); -// } - -// virtual QwtDoubleInterval range() const -// { -// return QwtDoubleInterval(0.0, 10.0); -// } - -// virtual double value(double x, double y) const -// { -// const double c = 0.842; - -// const double v1 = x * x + (y-c) * (y+c); -// const double v2 = x * (y+c) + x * (y+c); - -// return 1.0 / (v1 * v1 + v2 * v2); -// } -// }; class ImagePlotItem: public QwtPlotItem { public: ImagePlotItem() -// : mControlWidget(NULL) { mImage = new QImage(360,360,QImage::Format_RGB32); -// setAxis(QwtPlot::xBottom, QwtPlot::yLeft); } -// QwtDoubleRect boundingRect() const -// { -// return QwtDoubleRect(0., 0., 200., 200.); -// } /** * @brief Draws the mImage at the right position in correct size. * @param p @@ -131,13 +97,6 @@ public: } } -// void setControlWidget(Control *control) -// { -// mControlWidget = control; - -// generateImage(); -// } - inline QImage *getImage() const { return mImage; @@ -145,7 +104,6 @@ public: private: QImage *mImage; -// Control *mControlWidget; }; @@ -175,17 +133,7 @@ void TrackerPlotItem::draw(QPainter* p, const QwtScaleMap& mapX, const QwtScaleM int plotZ = ((ColorPlot *) plot())->zValue(); double diff; - // debout << "---" <<endl; - // debout << re.x() << " " << re.y() << " " << re.width() << " " << re.height()<<endl; - // debout << "x:" <<endl; - // debout << mapX.p1() << " "<< mapX.p2() << " " << mapX.s1() << " "<< mapX.s2() << " "<<endl; - // debout << "y:" <<endl; - // debout << mapY.p1() << " "<< mapY.p2() << " " << mapY.s1() << " "<< mapY.s2() << " "<<endl; - // debout << mModel << " "<< mX << " " << mY<<endl; - - // p->setPen(mPen); - - // ganu leicht verschiebung: eigentlich muessten noch andere werte wie diese einfliessen: + // TODO ganz leicht verschiebung: eigentlich muessten noch andere werte wie diese einfliessen: // p->scale((mx.p2() - mx.p1())/(mx.s2() - mx.s1()), (my.p1() - my.p2())/(my.s2() - my.s1()));// //mx.p1()-mx.s1(), my.s2()+my.p2()-((ColorPlot *) plot())->yMax() @@ -227,13 +175,6 @@ void TrackerPlotItem::setPen(const QPen &pen) mPen = pen; } -// void TrackerPlotItem::setModel(int model, int x, int y) -// { -// mModel = model; -// mX = x; -// mY = y; -// } - void TrackerPlotItem::setTracker(Tracker *tracker) { mTracker = tracker; @@ -243,64 +184,6 @@ Tracker * TrackerPlotItem::getTracker() return mTracker; } -// // wird auch missbraucht, um mX etc zu setzen, da updTr immer bei aenderung aufgerufen werden muss -// void TrackerPlotItem::updateTracker(int model, int x, int y) -// { -// if (mTracker) -// { -// int i; - -// QwtArray<double> xData; // == QVector -// QwtArray<double> yData; - -// // die for-schleife innerhalb der if und nicht anders herum aus performance gruenden -// if (model == 0) // HSV -// { -// if (x==0) -// for (i = 0; i < mTracker->size(); ++i) -// xData.append((*mTracker)[i].color().hue()); -// else if (x==1) -// for (i = 0; i < mTracker->size(); ++i) -// xData.append((*mTracker)[i].color().saturation()); -// else -// for (i = 0; i < mTracker->size(); ++i) -// xData.append((*mTracker)[i].color().value()); -// if (y==0) -// for (i = 0; i < mTracker->size(); ++i) -// yData.append((*mTracker)[i].color().hue()); -// else if (y==1) -// for (i = 0; i < mTracker->size(); ++i) -// yData.append((*mTracker)[i].color().saturation()); -// else -// for (i = 0; i < mTracker->size(); ++i) -// yData.append((*mTracker)[i].color().value()); -// } -// else // RGB -// { -// if (x==0) -// for (i = 0; i < mTracker->size(); ++i) -// xData.append((*mTracker)[i].color().red()); -// else if (x==1) -// for (i = 0; i < mTracker->size(); ++i) -// xData.append((*mTracker)[i].color().green()); -// else -// for (i = 0; i < mTracker->size(); ++i) -// xData.append((*mTracker)[i].color().blue()); -// if (y==0) -// for (i = 0; i < mTracker->size(); ++i) -// yData.append((*mTracker)[i].color().red()); -// else if (y==1) -// for (i = 0; i < mTracker->size(); ++i) -// yData.append((*mTracker)[i].color().green()); -// else -// for (i = 0; i < mTracker->size(); ++i) -// yData.append((*mTracker)[i].color().blue()); -// } - -// //mTpc->setData(xData, yData); -// debout << "data " << xData.size() << " " << yData.size()<<endl; -// } -// } //----------------------------------------------------------------------------------------- @@ -334,14 +217,11 @@ double RectPlotItem::map(const QColor &col) const //const TrackPerson &tp RectMa rightMap(map.x()+map.width(),0,360-map.x()-map.width(),map.height()); contains = leftMap.contains(((ColorPlot *) plot())->getPos(col)) || rightMap.contains(((ColorPlot *) plot())->getPos(col)); - //debout << "Point: " << (((ColorPlot *) plot())->getPos(col)).x() << "," << (((ColorPlot *) plot())->getPos(col)).y() << endl; - //debout << "Map x=" << map.x() << ", y=" << map.y() << ", width=" << map.width() << ", height=" << map.height() << endl; - //contains = map.contains(((ColorPlot *) plot())->getPos(col)); }else { contains = map.contains(((ColorPlot *) plot())->getPos(col)); } - if (!isGrey && map.colored() && contains) // QPoint point = ; + if (!isGrey && map.colored() && contains) return map.mapHeight(); else if (isGrey && !map.colored() && contains) return map.mapHeight(); @@ -355,15 +235,12 @@ double RectPlotItem::map(const QColor &col) const //const TrackPerson &tp RectMa int RectPlotItem::addMap(double x, double y, double w, double h, bool colored, double height, QColor &fromCol, QColor &toCol, bool invHue) { -// debout << "x=" << x << ", y=" << y << ", w=" << w << ", h=" << h << ", colored=" << colored << ", fromCol=" << fromCol << ", toCol=" << toCol << ", invHue=" << invHue << endl; mMaps.append(RectMap(x, y, w, h, colored, height)); mMaps.last().setFromColor(fromCol); mMaps.last().setToColor(toCol); mMaps.last().setInvHue(invHue); -// debout << "mActIndex: " << mActIndex << ", mMaps.size(): " << mMaps.size() << endl; if (mActIndex < 0) mActIndex = 0; -// debout << "mActIndex: " << mActIndex << ", mMaps.size(): " << mMaps.size() << endl; return mMaps.size()-1; } int RectPlotItem::addMap() @@ -488,15 +365,7 @@ void RectPlotItem::draw(QPainter* p, const QwtScaleMap& mapX, const QwtScaleMap& int i; float rX,rW; - // debout << "---" <<endl; - // debout << re.x() << " " << re.y() << " " << re.width() << " " << re.height()<<endl; - // debout << "x:" <<endl; - // debout << mapX.p1() << " "<< mapX.p2() << " " << mapX.s1() << " "<< mapX.s2() << " "<<endl; - // debout << "y:" <<endl; - // debout << mapY.p1() << " "<< mapY.p2() << " " << mapY.s1() << " "<< mapY.s2() << " "<<endl; - // debout << mModel << " "<< mX << " " << mY<<endl; - - // ganu leicht verschiebung: eigentlich muessten noch andere werte wie diese einfliessen: + // TODO ganz leicht verschiebung: eigentlich muessten noch andere werte wie diese einfliessen: // p->scale((mx.p2() - mx.p1())/(mx.s2() - mx.s1()), (my.p1() - my.p2())/(my.s2() - my.s1()));// //mx.p1()-mx.s1(), my.s2()+my.p2()-((ColorPlot *) plot())->yMax() @@ -515,7 +384,7 @@ void RectPlotItem::draw(QPainter* p, const QwtScaleMap& mapX, const QwtScaleMap& if (mMaps[i].invHue()) { - rect = mMaps[i]; //(QRectF) cast nicht noetig + rect = mMaps[i]; rect.moveTop(yMax-rect.y()-rect.height()); // nicht setY!!!!!, da dann height angepast wird rX = rect.x(); rW = rect.width(); @@ -528,7 +397,7 @@ void RectPlotItem::draw(QPainter* p, const QwtScaleMap& mapX, const QwtScaleMap& } else { - rect = mMaps[i]; //(QRectF) cast nicht noetig + rect = mMaps[i]; rect.moveTop(yMax-rect.y()-rect.height()); // nicht setY!!!!!, da dann height angepast wird p->drawRect(rect); } @@ -548,10 +417,6 @@ public: Zoomer(int xAxis, int yAxis, QWidget *canvas) : QwtPlotZoomer(xAxis, yAxis, canvas) { - ////// Macht Probleme mit Qwt 6 - //////setSelectionFlags(QwtPicker::DragSelection | QwtPicker::CornerToCorner); - // default: setRubberBand(QwtPicker::NoRubberBand); - // RightButton: zoom out by 1 // Ctrl+RightButton: zoom out to full size @@ -560,37 +425,19 @@ public: setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); setRubberBand(QwtPicker::RectRubberBand); - //mZoomer->setRubberBandPen(QColor(Qt::green)); setTrackerMode(QwtPicker::AlwaysOn); //ActiveOnly (only when the selection is active), AlwaysOff - //mZoomer->setTrackerPen(QColor(Qt::white)); } // ueberschrieben, da so kommazahlen unterdrueckt werden, da intervall mindestens 5 umfasst -// Qwt 5: QwtDoubleSize minZoomSize() const //QwtPlotZoomer:: QSizeF minZoomSize() const override { return QwtDoubleSize(5., 5.); } -// QwtPlot *plot() -// { -// QObject *w = canvas(); -// if ( w ) -// { -// w = w->parent(); -// if ( w && w->inherits("QwtPlot") ) -// return (QwtPlot *)w; -// } - -// return NULL; -// } - -//widgetWheelEvent ( QWheelEvent * e ) - /** * @brief Allows movement in the zoomed in color plot via dragging with a pressed down middle mouse button. - * @param e - */ + * @param e + */ void widgetMouseMoveEvent(QMouseEvent *e) override { static int lastX = -1; @@ -601,7 +448,6 @@ public: lastX = e->x(); lastY = e->y(); - //if (e->button() == Qt::MidButton) fkt bei move nicht if (e->buttons() == Qt::MiddleButton) { plot()->setAutoReplot(false); @@ -611,8 +457,8 @@ public: { const QwtScaleMap map = plot()->canvasMap(axis); - const int i1 = map.transform(plot()->axisScaleDiv(axis).lowerBound()); // war in aelterer qwt version: axisScaleDiv(axis)->lBound() - const int i2 = map.transform(plot()->axisScaleDiv(axis).upperBound()); // war in aelterer qwt version: axisScaleDiv(axis)->hBound() + const int i1 = map.transform(plot()->axisScaleDiv(axis).lowerBound()); + const int i2 = map.transform(plot()->axisScaleDiv(axis).upperBound()); double d1, d2; if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop ) @@ -626,8 +472,6 @@ public: d2 = map.invTransform(i2 - dy); } - //debout << zoomBase().width() << " " << zoomBase().height() << endl; - //debout << plot()->axisScaleDiv(axis)->lBound() << " " << plot()->axisScaleDiv(axis)->hBound() << endl; if (d1 < 0) { d2 = d2-d1; @@ -652,21 +496,7 @@ public: } QwtPlotZoomer::widgetMouseMoveEvent(e); } -// // damit bei pan nicht text angezeigt wird // wenn eingebauter pan benutzt wird!!! -// void widgetMousePressEvent(QMouseEvent *e) -// { -// if (e->button() == Qt::MidButton) -// setTrackerMode(QwtPicker::AlwaysOff); - -// QwtPlotZoomer::widgetMousePressEvent(e); -// } -// void widgetMouseReleaseEvent(QMouseEvent *e) -// { -// if (e->button() == Qt::MidButton) -// setTrackerMode(QwtPicker::AlwaysOn); - -// QwtPlotZoomer::widgetMouseReleaseEvent(e); -// } + QwtText trackerText(const QPoint &pos) const override { @@ -708,15 +538,8 @@ public: double sy = mapY.p1()/(mapY.s2() - mapY.s1()); double yMax = ((ColorPlot *) plot())->yMax(); double sS = ((ColorPlot *) plot())->symbolSize()*0.35355339; - // debout << "---" <<endl; - // debout << re.x() << " " << re.y() << " " << re.width() << " " << re.height()<<endl; - // debout << "x:" <<endl; - // debout << mapX.p1() << " "<< mapX.p2() << " " << mapX.s1() << " "<< mapX.s2() << " "<<endl; - // debout << "y:" <<endl; - // debout << mapY.p1() << " "<< mapY.p2() << " " << mapY.s1() << " "<< mapY.s2() << " "<<endl; - // debout << mModel << " "<< mX << " " << mY<<endl; - - // ganu leicht verschiebung: eigentlich muessten noch andere werte wie diese einfliessen: + + // TODO ganz leicht verschiebung: eigentlich muessten noch andere werte wie diese einfliessen: // p->scale((mx.p2() - mx.p1())/(mx.s2() - mx.s1()), (my.p1() - my.p2())/(my.s2() - my.s1()));// //mx.p1()-mx.s1(), my.s2()+my.p2()-((ColorPlot *) plot())->yMax() @@ -730,8 +553,6 @@ public: QPointF p1, p2; QPointF point = mPoint; - //point.setY(yMax-mPoint.y()); - p1.setX(point.x()+sS/sx); p1.setY(point.y()+sS/sy); p2.setX(point.x()-sS/sx); @@ -770,42 +591,22 @@ ColorPlot::ColorPlot(QWidget *parent) // default= NULL : QwtPlot(parent) { mControlWidget = nullptr; -// mTracker = NULL; mGreyDiff = 50; mSymbolSize = 10.; - // fkt nicht: - //setFrameShape(Box); // damit rahmen gleich wie alle anderen group boxen - //setFrameShadow(Sunken); QwtText titleX("x"); QwtText titleY("y"); setAxisTitle(xBottom, titleX); //"x" setAxisTitle(yLeft, titleY); //"y" - //setAxisFont(xBottom, f); - //setAxisFont(yLeft, f); plotLayout()->setAlignCanvasToScales(true); - //axisScaleEngine(xBottom)->setAttribute(QwtScaleEngine::Floating, false); - //axisScaleEngine(yLeft)->setAttribute(QwtScaleEngine::Floating, false); - //canvas()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - //canvas()->setFixedWidth(400); //geometry().width()- - //canvas()->setFixedHeight(400); //geometry().height()- mImageItem = new ImagePlotItem(); mImageItem->attach(this); mZoomer = new Zoomer(xBottom, yLeft, canvas()); - //(new QwtPlotPanner(canvas()))->setMouseButton(Qt::MidButton); - -// mTpc = new QwtPlotCurve("color of tracking points"); -// mTpc->attach(this); -// mTpc->setStyle(QwtPlotCurve::NoCurve); -// mTpc->setSymbol(QwtSymbol(QwtSymbol::XCross, QBrush(Qt::white), QPen(Qt::black), QSize(4, 4))); -// // Ellipse, Rect, Diamond, Triangle, DTriangle, UTriangle, LTriangle, RTriangle, Cross, XCross, HLine, VLine, Star1, Star2, Hexagon, StyleCnt -// // mTpc->setPen(...); - mTrackerItem = new TrackerPlotItem(); mTrackerItem->attach(this); @@ -814,13 +615,6 @@ ColorPlot::ColorPlot(QWidget *parent) // default= NULL mViewColorItem = new ViewColorPlotItem(); mViewColorItem->attach(this); - -// test: mRectItem->addMap(10, 10, 100, 100, true, 1.40); - - //paintEngine()->hasFeature(QPaintEngine::Antialiasing); - //setAutoReplot(true); - -// setMouseTracking(true); // mouse move events werden auch bei nichtdruecken einer moustaste ausgeloest } void ColorPlot::replot() @@ -876,19 +670,10 @@ bool ColorPlot::isGrey(const QColor &col) const else return false; } -// void ColorPlot::mouseMoveEvent(QMouseEvent *event) -// { -// QFrame::mouseMoveEvent(event); -// debout << "moveEvent" << endl; -// } void ColorPlot::setCursor(const QColor &col) { - //QPoint pos = getPos(col); - //QMouseEvent event(QEvent::MouseMove, pos, Qt::NoButton, Qt::NoButton, Qt::NoModifier); mViewColorItem->setPoint(getPos(col)); - //mZoomer->mouseMoveEvent(&event); //widgetM - //QFrame::mouseMoveEvent(&event); } @@ -975,7 +760,6 @@ void ColorPlot::setControlWidget(Control *control) void ColorPlot::setTracker(Tracker *tracker) { -// mTracker = tracker; mTrackerItem->setTracker(tracker); } @@ -986,14 +770,12 @@ void ColorPlot::setScale() int model = mControlWidget->recoColorModel->currentIndex(); int x = mControlWidget->recoColorX->currentIndex(); int y = mControlWidget->recoColorY->currentIndex(); - -// mTrackerItem->setModel(model, x, y); QwtDoubleRect base(0., 0., 255., 255.); mXMax = 255.; mYMax = 255.; - if (model == 0) // HSV //mControlWidget->recoColorModel->currentIndex() + if (model == 0) // HSV { if (x==0) mXMax = 359.; @@ -1001,14 +783,8 @@ void ColorPlot::setScale() mYMax = 359.; } -// setAutoReplot(false); // hiermit koennte temporaer das automatische skalieren auf werte von setaxisscale unterdrueckt werden setAxisScale(QwtPlot::xBottom, 0., mXMax); setAxisScale(QwtPlot::yLeft, 0., mYMax); -// setAutoReplot(true); -// replot(); - -// setAxisAutoScale(QwtPlot::xBottom); -// setAxisAutoScale(QwtPlot::yLeft); replot(); // why, see: file:///C:/Programme/qwt-5.0.1/doc/html/class_qwt_plot_zoomer.html#7a1711597f441223efdb7d9931fe19b9 @@ -1018,7 +794,7 @@ void ColorPlot::setScale() } } -void ColorPlot::generateImage() // int model, int x, int y, int z +void ColorPlot::generateImage() { if (mControlWidget) { @@ -1038,7 +814,6 @@ void ColorPlot::generateImage() // int model, int x, int y, int z if (midValue < 130) { mZoomer->setTrackerPen(QColor(Qt::white)); -// mTpc->setPen(QPen(Qt::white)); mTrackerItem->setPen(QPen(Qt::white)); mRectItem->setPen(QPen(Qt::white)); mViewColorItem->setPen(QPen(Qt::white)); @@ -1046,7 +821,6 @@ void ColorPlot::generateImage() // int model, int x, int y, int z else { mZoomer->setTrackerPen(QColor(Qt::black)); -// mTpc->setPen(QPen(Qt::black)); mTrackerItem->setPen(QPen(Qt::black)); mRectItem->setPen(QPen(Qt::black)); mViewColorItem->setPen(QPen(Qt::black)); @@ -1054,69 +828,6 @@ void ColorPlot::generateImage() // int model, int x, int y, int z } } -// void ColorPlot::updateTracker() -// { -// if (mTracker) -// { -// int model = mControlWidget->recoColorModel->currentIndex(); -// int x = mControlWidget->recoColorX->currentIndex(); -// int y = mControlWidget->recoColorY->currentIndex(); -// int i; - -// // mTrackerItem->updateTracker(model, x, y); - -// QwtArray<double> xData; // == QVector -// QwtArray<double> yData; - -// // die for-schleife innerhalb der if und nicht anders herum aus performance gruenden -// if (model == 0) // HSV -// { -// if (x==0) -// for (i = 0; i < mTracker->size(); ++i) -// xData.append((*mTracker)[i].color().hue()); -// else if (x==1) -// for (i = 0; i < mTracker->size(); ++i) -// xData.append((*mTracker)[i].color().saturation()); -// else -// for (i = 0; i < mTracker->size(); ++i) -// xData.append((*mTracker)[i].color().value()); -// if (y==0) -// for (i = 0; i < mTracker->size(); ++i) -// yData.append((*mTracker)[i].color().hue()); -// else if (y==1) -// for (i = 0; i < mTracker->size(); ++i) -// yData.append((*mTracker)[i].color().saturation()); -// else -// for (i = 0; i < mTracker->size(); ++i) -// yData.append((*mTracker)[i].color().value()); -// } -// else // RGB -// { -// if (x==0) -// for (i = 0; i < mTracker->size(); ++i) -// xData.append((*mTracker)[i].color().red()); -// else if (x==1) -// for (i = 0; i < mTracker->size(); ++i) -// xData.append((*mTracker)[i].color().green()); -// else -// for (i = 0; i < mTracker->size(); ++i) -// xData.append((*mTracker)[i].color().blue()); -// if (y==0) -// for (i = 0; i < mTracker->size(); ++i) -// yData.append((*mTracker)[i].color().red()); -// else if (y==1) -// for (i = 0; i < mTracker->size(); ++i) -// yData.append((*mTracker)[i].color().green()); -// else -// for (i = 0; i < mTracker->size(); ++i) -// yData.append((*mTracker)[i].color().blue()); -// } - -// mTpc->setData(xData, yData); -// debout << "data " << xData.size() << " " << yData.size()<<endl; -// } -// } - int ColorPlot::zValue() const { if (mControlWidget) diff --git a/src/colorRangeWidget.cpp b/src/colorRangeWidget.cpp index a743a2aaf..f5d57f7c5 100644 --- a/src/colorRangeWidget.cpp +++ b/src/colorRangeWidget.cpp @@ -58,11 +58,9 @@ void ColorRangeWidget::on_inversHue_stateChanged(int i) mColorPlot->replot(); } -// WARNING Setzt voraus, dass x als Hue und y als Saturation ausgewählt ist -// Zwar Standardeinstellung, aber nicht zwingend der Fall /** * @brief sets x and y slider from colormap widget - * + * @pre x is hue, and y saturation * Sets the x and y slider to the right values according to fromColor and toColor, * which were selected via the color picker. */ @@ -100,7 +98,6 @@ void ColorRangeWidget::on_fromTriangle_colorChanged(const QColor &col) { fromHue = col.hue(); fromSat = col.saturation(); fromVal = col.value(); QString styleString = QString("background-color: hsv(%1,%2,%3)").arg(fromHue).arg(fromSat).arg(fromVal); - //QString styleString = QString("background-color: rgb(%1,%2,%3)").arg(col.red()).arg(col.green()).arg(col.blue()); fromColor->setStyleSheet(styleString); mColorPlot->getMapItem()->changeActMapFromColor(col); @@ -114,7 +111,6 @@ void ColorRangeWidget::on_toTriangle_colorChanged(const QColor &col) { toHue = col.hue(); toSat = col.saturation(); toVal = col.value(); QString styleString = QString("background-color: hsv(%1,%2,%3)").arg(toHue).arg(toSat).arg(toVal); - //QString styleString = QString("background-color: rgb(%1,%2,%3)").arg(col.red()).arg(col.green()).arg(col.blue()); toColor->setStyleSheet(styleString); mColorPlot->getMapItem()->changeActMapToColor(col); @@ -130,7 +126,7 @@ void ColorRangeWidget::on_fromColor_clicked() // QWindowsXpStyle uses native theming engine which causes some palette modifications not to have any effect. // ueber palette war der button ausser initial nicht zu aendern!!! - QColor colBefore;//fromColor->palette().color(QPalette::Button); + QColor colBefore; colBefore = QColor::fromHsv(fromHue, fromSat, fromVal); QColor col = (QColorDialog::getColor(colBefore, this, "Select color from which value a pixel belongs to marker")).convertTo(QColor::Hsv); if (col.isValid() && col != colBefore) @@ -144,39 +140,19 @@ void ColorRangeWidget::on_toColor_clicked() { // QWindowsXpStyle uses native theming engine which causes some palette modifications not to have any effect. // ueber palette war der button ausser initial nicht zu aendern!!! - QColor colBefore;//toColor->palette().color(QPalette::Button); + QColor colBefore; colBefore = QColor::fromHsv(toHue, toSat, toVal); QColor col = (QColorDialog::getColor(colBefore, this, "Select color to which value a pixel belongs to marker")).convertTo(QColor::Hsv); - //QPalette palette = toColor->palette(); - //palette.setColor(QPalette::Button, col); - //toColor->setPalette(palette); - //toColor->setAutoFillBackground(true); if (col.isValid() && col != colBefore) { on_toTriangle_colorChanged(col); toTriangle->setColor(col); } -// Versuch mit hsv stabil werte einzugeben - wandern in hsv und rgb zur folge, wenn auch wenig -// // QWindowsXpStyle uses native theming engine which causes some palette modifications not to have any effect. -// // ueber palette war der button ausser initial nicht zu aendern!!! -// QColor col = QColorDialog::getColor(toColor->palette().color(QPalette::Button).toHsv(), this, "").toHsv(); -// //debout << col.hue()<<endl; -// //debout << col.saturation()<<endl; -// //debout << col.value()<<endl; -// //QPalette palette = toColor->palette(); -// //palette.setColor(QPalette::Button, col); -// //toColor->setPalette(palette); -// //toColor->setAutoFillBackground(true); -// if (col.isValid()) -// { -// QString styleString = QString("background-color: hsv(%1,%2,%3)").arg(col.hue()).arg(col.saturation()).arg(col.value()); -// toColor->setStyleSheet(styleString); -// } } void ColorRangeWidget::setInvHue(bool b) { - inversHue->setChecked(b);//setCheckState(); + inversHue->setChecked(b); } void ColorRangeWidget::setFromColor(const QColor &col) diff --git a/src/control.cpp b/src/control.cpp index e0ad47105..74771dadd 100644 --- a/src/control.cpp +++ b/src/control.cpp @@ -3276,22 +3276,11 @@ void Control::getXml(QDomElement &elem) trackShowOnlyVisible->setCheckState(subSubElem.attribute("ONLY_VISIBLE").toInt() ? Qt::Checked : Qt::Unchecked); if (subSubElem.hasAttribute("ONLY_PEOPLE")) trackShowOnly->setCheckState(subSubElem.attribute("ONLY_PEOPLE").toInt() ? Qt::Checked : Qt::Unchecked); + if (subSubElem.hasAttribute("ONLY_PEOPLE_LIST")) trackShowOnlyList->setCheckState(subSubElem.attribute("ONLY_PEOPLE_LIST").toInt() ? Qt::Checked : Qt::Unchecked); - // wird in petrack.cpp abgewickelt, da es nach dem laden der trajektorien gemacht werden muss -// if (subSubElem.hasAttribute("ONLY_PEOPLE_NR")) -// { -// trackShowOnlyNr->setValue(subSubElem.attribute("ONLY_PEOPLE_NR").toInt()); -// } -// if (subSubElem.hasAttribute("ONLY_PEOPLE_NR")) -// { -// int peopleNr = subSubElem.attribute("ONLY_PEOPLE_NR").toInt(); -// // nur so kann nr vor laden von trajectorien richtig gesetzt werden -// // nicht ganz sauber -// trackShowOnlyNr->setMaximum(peopleNr); -// trackShowOnlyNr->setValue(peopleNr); -// } + // IMPORTANT: reading ONLY_PEOPLE_NR is done in petrack.cpp, as the trajectories need to be loaded before! if (subSubElem.hasAttribute("SHOW_CURRENT_POINT")) trackShowCurrentPoint->setCheckState(subSubElem.attribute("SHOW_CURRENT_POINT").toInt() ? Qt::Checked : Qt::Unchecked); if (subSubElem.hasAttribute("SHOW_POINTS")) diff --git a/src/coordItem.cpp b/src/coordItem.cpp index 3251e6114..400c1f99f 100644 --- a/src/coordItem.cpp +++ b/src/coordItem.cpp @@ -36,7 +36,6 @@ CoordItem::CoordItem(QWidget *wParent,/* QGraphicsScene * scene,*/ QGraphicsItem mMainWindow = (class Petrack*) wParent; extCalib = mMainWindow->getExtrCalibration(); mControlWidget = mMainWindow->getControlWidget(); - //mScene = scene; //Set Min and Max calibPointsMin.x = 50000; @@ -45,10 +44,6 @@ CoordItem::CoordItem(QWidget *wParent,/* QGraphicsScene * scene,*/ QGraphicsItem calibPointsMax.y = 0; updateData(); // um zB setFlags(ItemIsMovable) je nach anzeige zu aendern - //setEnabled(false); // all mouse events connot access this item, but it will be seen - //einzig move koennte interessant sein, um grid zu verschieben?! - - //setAcceptsHoverEvents(true); } /** @@ -61,48 +56,18 @@ CoordItem::CoordItem(QWidget *wParent,/* QGraphicsScene * scene,*/ QGraphicsItem */ QRectF CoordItem::boundingRect() const { - /* double sc = mControlWidget->getCalibCoordScale()/10; - double tX = mControlWidget->getCalibCoordTransX(); - double tY = mControlWidget->getCalibCoordTransY(); - double tZ = mControlWidget->getCalibCoordRotate(); - double cU = mControlWidget->getCalibCoordUnit(); - - Point2f p[4]; - p[0] = extCalib->getImagePoint(Point3f(tX+cU,tY,tZ)); - p[1] = extCalib->getImagePoint(Point3f(tX,tY+cU,tZ)); - p[2] = extCalib->getImagePoint(Point3f(tX,tY,tZ+cU)); - p[3] = extCalib->getImagePoint(Point3f(0,0,0)); - double min_x = 1000, min_y = 1000, max_x = -1000, max_y = -1000; - - double x,y; - - for(int i=0;i<4;i++) - { - x = p[i].x; - y = p[i].y; - max_x = x > max_x ? x : max_x; - min_x = x < min_x ? x : min_x; - max_y = y > max_y ? y : max_y; - min_y = y < min_y ? y : min_y; - }*/ - // bounding box wird in lokalen koordinaten angegeben!!! (+-10 wegen zahl "1") - - if (mControlWidget->getCalibCoordShow() /*|| mControlWidget->getCalibExtrCalibPointsShow()*/) + if (mControlWidget->getCalibCoordShow()) { - //debout << "Items pos: " << this->pos() << " scenePos(): " << this->scenePos() << endl; - if( mControlWidget->getCalibCoordDimension() != 0 ) // 2D view { return QRectF(-110., -110., 220., 220.); } else // 3D view { - //debout << x.x << " " << y.x << " " << z.x << " " << ursprung.x << " " << calibPointsMin.x << " " << calibPointsMax.x << endl; double min_x = std::min(std::min(x.x,y.x),std::min(z.x,ursprung.x)); double max_x = std::max(std::max(x.x,y.x),std::max(z.x,ursprung.x)); - //debout << x.y << " " << y.y << " " << z.y << " " << ursprung.y << " " << calibPointsMin.y << " " << calibPointsMax.y << endl; double min_y = std::min(std::min(x.y,y.y),std::min(z.y,ursprung.y)); double max_y = std::max(std::max(x.y,y.y),std::max(z.y,ursprung.y)); @@ -114,30 +79,13 @@ QRectF CoordItem::boundingRect() const min_y = std::min(float(min_y),calibPointsMin.y); max_y = std::max(float(max_y),calibPointsMax.y); } - //debout << "Bounding Rect: x: " << min_x << " y: " << min_y << ", width: " << max_x << " height: " << max_y << endl; - //debout << "Bounding Rect: " << mapToScene(min_x,min_y) << ", " << mapToItem(this,max_x-min_x,max_y-min_y) << endl; - //return QRectF(mapToItem( this, min_x, min_y),mapToItem( this,max_x-min_x,max_y-min_y)); - //double delta_x = max_x-min_x, delta_y = max_y-min_y; - //return QRectF(-0.5*delta_x,-0.5*delta_y,delta_x, delta_y); return QRectF(min_x-25, min_y-25, max_x-min_x+50, max_y-min_y+50); -// return QRectF(-mMainWindow->getImageBorderSize(), -// -mMainWindow->getImageBorderSize(), -// mControlWidget->getMainWindow()->getImage()->width() -// + 2*mMainWindow->getImageBorderSize(), -// mControlWidget->getMainWindow()->getImage()->height() -// + 2*mMainWindow->getImageBorderSize()); - //return QRectF(-img->width(),-img->height(),img->width()*2,img->height()*2); } } else { return QRectF(0., 0., 0., 0.); } - - // sicher ware diese boundingbox, da alles - // return QRectF(xMin, yMin, xMax-xMin, yMax-yMin); - // eigentlich muesste folgende Zeile reichen, aber beim ranzoomen verschwindet dann koord.sys. - // return QRectF(mControlWidget->getCalibCoordTransX()/10.-scale, mControlWidget->getCalibCoordTransY()/10.-scale, 2*scale, 2*scale); } // event, of moving mouse while button is pressed @@ -154,16 +102,11 @@ void CoordItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) if (event->buttons() == Qt::RightButton) // event->button() doesnt work { mControlWidget->setCalibCoordRotate(mControlWidget->getCalibCoordRotate()-(int)(3.*(diff.x()+diff.y()))); //10* nicht noetig, da eh nur relativ - //cout << diff.x()-diff.y() <<endl; //globalPos() } else if (event->buttons() == Qt::LeftButton) { if( mControlWidget->getCalibCoordDimension() == 0 ) // 3D { - - //debout << "P_cur: " << event->scenePos().x() << "," << event->scenePos().y() << endl; - //debout << "P_last: " << event->lastScenePos().x() << "," << event->lastScenePos().y() << endl; - cv::Point3f p_cur = extCalib->get3DPoint(cv::Point2f(event->scenePos().x(), event->scenePos().y()), mControlWidget->getCalibCoord3DTransZ()); @@ -177,11 +120,8 @@ void CoordItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) // das Kooridnatensystem bewegt sich nicht. Effekt wird noch verstrkt, da das stndig passiert // Besonders schnelle Mausbewegungen lindern den Effekt - mControlWidget->setCalibCoord3DTransX(coordTrans_x/*mControlWidget->getCalibCoord3DTransX()*/-(mControlWidget->getCalibCoord3DSwapX() ? -1 : 1)*round(p_last.x-p_cur.x)); - mControlWidget->setCalibCoord3DTransY(coordTrans_y/*mControlWidget->getCalibCoord3DTransY()*/-(mControlWidget->getCalibCoord3DSwapY() ? -1 : 1)*round(p_last.y-p_cur.y)); - -// mControlWidget->setCalibExtrTrans1(mControlWidget->getCalibExtrTrans1()+round(p_cur.x-p_last.x)); -// mControlWidget->setCalibExtrTrans2(mControlWidget->getCalibExtrTrans2()+round(p_cur.y-p_last.y)); + mControlWidget->setCalibCoord3DTransX(coordTrans_x-(mControlWidget->getCalibCoord3DSwapX() ? -1 : 1)*round(p_last.x-p_cur.x)); + mControlWidget->setCalibCoord3DTransY(coordTrans_y-(mControlWidget->getCalibCoord3DSwapY() ? -1 : 1)*round(p_last.y-p_cur.y)); }else { @@ -204,8 +144,6 @@ void CoordItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { QGraphicsItem::mouseMoveEvent(event); // drag mach ich selber } - //mMainWindow->updateSceneRect(); - } void CoordItem::mousePressEvent(QGraphicsSceneMouseEvent *event) @@ -219,8 +157,6 @@ void CoordItem::mousePressEvent(QGraphicsSceneMouseEvent *event) coordTrans_x = mControlWidget->getCalibCoord3DTransX(); coordTrans_y = mControlWidget->getCalibCoord3DTransY(); - - //debout << ">>>>>>>>MousePressEvent: " << mouse_x << ", " << mouse_y << endl; } }else { @@ -228,24 +164,6 @@ void CoordItem::mousePressEvent(QGraphicsSceneMouseEvent *event) } } - -// event, of moving mouse -//void CoordItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -//{ -// QPointF pos = event->scenePos(); -// pos.setX(pos.x() + mMainWindow->getImageBorderSize()); -// pos.setY(pos.y() + mMainWindow->getImageBorderSize()); -// if (pos.x() >=0 && pos.x() <= mMainWindow->getImage()->width() && pos.y() >=0 && pos.y() <= mMainWindow->getImage()->height()) -// mMainWindow->setMousePosOnImage(pos); - -// if (!mControlWidget->getCalibCoordFix()) -// setCursor(Qt::OpenHandCursor); -// else -// setCursor(Qt::CrossCursor); - -// QGraphicsItem::hoverMoveEvent(event); -//} - void CoordItem::updateData() { if (!mControlWidget->getCalibCoordFix()) @@ -277,7 +195,6 @@ void CoordItem::updateData() if( mMainWindow->getImage()) { - //prepareGeometryChange(); // Reset Matrix - No Matrix Transformations for 3D Coordsystem // aktualisierung der transformationsmatrix QTransform matrix; @@ -285,27 +202,14 @@ void CoordItem::updateData() matrix.translate(0, 0); matrix.rotate(0); matrix.scale(1, 1); - //matrix.shear(tX,tY); setTransform(matrix); -// double tX3D = mControlWidget->getCalibCoord3DTransX(); -// double tY3D = mControlWidget->getCalibCoord3DTransY(); -// double tZ3D = mControlWidget->getCalibCoord3DTransZ(); double axeLen = mControlWidget->getCalibCoord3DAxeLen(); int bS = mMainWindow->getImageBorderSize(); -// int swapX = 1;//mControlWidget->getCalibCoord3DSwapX() ? -1 : 1; -// int swapY = 1;//mControlWidget->getCalibCoord3DSwapY() ? -1 : 1; -// int swapZ = 1;//mControlWidget->getCalibCoord3DSwapZ() ? -1 : 1; - - //debout << "Before isSetExtrCalib..." << endl; // Coordinate-system origin at (tX,tY,tZ) if( extCalib->isSetExtrCalib() ){ - //debout << "X: swap: " << swapX << " T1: " << mControlWidget->getCalibExtrTrans1() << " tX3D: " << tX3D << endl; - //debout << "Y: swap: " << swapY << " T2: " << mControlWidget->getCalibExtrTrans2() << " tY3D: " << tY3D << endl; - //debout << "Z: swap: " << swapZ << " T3: " << mControlWidget->getCalibExtrTrans3() << " tZ3D: " << tZ3D << endl; - ursprung = extCalib->getImagePoint(cv::Point3f(0,0,0)); x3D = cv::Point3f(axeLen,0,0); @@ -315,13 +219,8 @@ void CoordItem::updateData() // Tests if the origin-point of the coordinate-system is outside the image if( extCalib->isOutsideImage(ursprung) ) { - //debout << "Ursprung: " << ursprung.x << ", " <<ursprung.y << endl; return; } - //debout << "Test" << endl; -// x3D.x += swapX; -// y3D.y += swapY; -// z3D.z += swapZ; x3D.x++; y3D.y++; z3D.z++; @@ -330,26 +229,18 @@ void CoordItem::updateData() do{ x3D.x--; x = extCalib->getImagePoint(x3D); - //if( ursprungOutside ){ break; } - //debout << x.x << ", " << x.y << endl; // tests if the coord system axis are inside the view or outside, if outside short them till they are inside the image }while( x.x < -bS || x.x > mMainWindow->getImage()->width()-bS || x.y < -bS || x.y > mMainWindow->getImage()->height()-bS ); do{ y3D.y--; y = extCalib->getImagePoint(y3D); - //if( ursprungOutside ){ break; } - //debout << y.x << ", " << y.y << endl; }while( y.x < -bS || y.x > mMainWindow->getImage()->width()-bS || y.y < -bS || y.y > mMainWindow->getImage()->height()-bS ); do{ z3D.z--; z = extCalib->getImagePoint(z3D); - //if( ursprungOutside ){ break; } - //debout << z.x << ", " << z.y << endl; }while( z.x < -bS || z.x > mMainWindow->getImage()->width()-bS || z.y < -bS || z.y > mMainWindow->getImage()->height()-bS ); } } - //} - prepareGeometryChange(); } @@ -404,8 +295,6 @@ void CoordItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio cv::Point2f p3 = extCalib->getImagePoint(p3d); - //QPointF axis = mMainWindow->getImageItem()->getCmPerPixel(p3.x,p3.y,p3d.z); - painter->drawEllipse(p3.x-4,p3.y-4,8,8); // Connecting-line Pixel-3D-Points @@ -416,17 +305,6 @@ void CoordItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio painter->setBrush(Qt::black); painter->drawText(QPointF(p2.x+10,p2.y+font.pixelSize()), QObject::tr("%1").arg((i+1))); - //painter->setPen(Qt::blue); - //painter->setBrush(Qt::blue); - - // min/max of calibration points for bounding box -// if( i == 0) -// { -// calibPointsMin.x = p2.x; -// calibPointsMin.y = p2.y; -// calibPointsMax.x = p2.x; -// calibPointsMax.y = p2.y; -// } if( p2.x < calibPointsMin.x ) calibPointsMin.x = p2.x; if( p2.x > calibPointsMax.x ) calibPointsMax.x = p2.x; if( p3.x < calibPointsMin.x ) calibPointsMin.x = p3.x; @@ -454,35 +332,18 @@ void CoordItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio ////////////////////////// painter->setPen(QPen(QBrush(Qt::blue),0)); -// double sc = mControlWidget->getCalibCoordScale(); -// double tX = mControlWidget->getCalibCoordTransX(); -// double tY = mControlWidget->getCalibCoordTransY(); -// double tZ = mControlWidget->getCalibCoordRotate(); -// double cU = mControlWidget->getCalibCoordUnit(); static QPointF points[3]; - // //eigentliche BoundingBox: painter->drawRect(QRectF(mControlWidget->getCalibCoordTransX()/10.-scale, mControlWidget->getCalibCoordTransY()/10.-scale, 2*scale, 2*scale)); - // matrix.translate(mControlWidget->getCalibCoordTransX()/10., mControlWidget->getCalibCoordTransY()/10.); - // matrix.rotate((mControlWidget->getCalibCoordRotate())/10.); - // mit folgender zeile wuerde nur der painter bewegt, nicht aber das koord des items!!! - // painter->setWorldMatrix(matrix, true); // true sagt, dass relativ und nicht absolut (also zusaetzlichj zur uebergeordneten matrizen) - // Koordinatenachsen points[0].setX(-10.); points[0].setY(0.); points[1].setX(100.); points[1].setY(0.); painter->drawLine(points[0], points[1]); - //debout << "1. Points[0]: " << points[0].x() << " " << points[0].y() << endl; - //debout << "1. Points[1]: " << points[1].x() << " " << points[1].y() << endl; - points[0].setX(0.); points[0].setY(10.); points[1].setX(0.); points[1].setY(-100.); painter->drawLine(points[0], points[1]); - //debout << "2. Points[0]: " << points[0].x() << " " << points[0].y() << endl; - //debout << "2. Points[1]: " << points[1].x() << " " << points[1].y() << endl; - // Ticks for (int i=1; i<11; i++) // i=10 zeichnen sieht ungewoehnlich aus, laeest sich aber besser mit messen { @@ -513,51 +374,6 @@ void CoordItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio points[1].setX(2.); points[1].setY(-95.); points[2].setX(-2.); points[2].setY(-95.); painter->drawPolygon(points, 3); - - /* - // // Koordinatenachsen - // painter->setPen(Qt::blue); - - // points[0].setX(-.1*scale); points[0].setY(0.); - // points[1].setX(scale); points[1].setY(0.); - // painter->drawLine(points[0], points[1]); - - // points[0].setX(0.); points[0].setY(.1*scale); - // points[1].setX(0.); points[1].setY(-scale); - // painter->drawLine(points[0], points[1]); - - // // Ticks - // for (int i=1; i<10; i++) - // { - // points[0].setX(0.02*scale); points[0].setY(-i*scale/10.); - // points[1].setX(-0.02*scale); points[1].setY(-i*scale/10.); - // painter->drawLine(points[0], points[1]); - // points[0].setX(i*scale/10.); points[0].setY(0.02*scale); - // points[1].setX(i*scale/10.); points[1].setY(-0.02*scale); - // painter->drawLine(points[0], points[1]); - // } - - // // Beschriftung - // points[0].setX(0.97*scale); points[0].setY(0.12*scale); - // painter->drawText(points[0], QObject::tr("1")); - // points[0].setX(-0.08*scale); points[0].setY(-0.97*scale); - // painter->drawText(points[0], QObject::tr("1")); - - // // Pfeilspitzen - // painter->setPen(Qt::NoPen); - // painter->setBrush(Qt::blue); - - // points[0].setX(scale); points[0].setY(0.); - // points[1].setX(0.95*scale); points[1].setY(0.02*scale); - // points[2].setX(0.95*scale); points[2].setY(-0.02*scale); - // painter->drawPolygon(points, 3); - - // points[0].setX(0.); points[0].setY(-scale); - // points[1].setX(0.02*scale); points[1].setY(-0.95*scale); - // points[2].setX(-0.02*scale); points[2].setY(-0.95*scale); - // painter->drawPolygon(points, 3); - */ - }else { double tX3D = mControlWidget->getCalibCoord3DTransX(); @@ -565,10 +381,6 @@ void CoordItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio double tZ3D = mControlWidget->getCalibCoord3DTransZ(); double axeLen = mControlWidget->getCalibCoord3DAxeLen(); -// int swapX = mControlWidget->getCalibCoord3DSwapX() ? -1 : 1; -// int swapY = mControlWidget->getCalibCoord3DSwapY() ? -1 : 1; -// int swapZ = mControlWidget->getCalibCoord3DSwapZ() ? -1 : 1; - qreal coordLineWidth = 2.0; @@ -694,9 +506,6 @@ void CoordItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio painter->drawLine(QPointF(p[0].x,p[0].y),QPointF(p[1].x,p[1].y)); p[1] = extCalib->getImagePoint(cv::Point3f(z3D.x,z3D.y,z3D.z)); painter->drawLine(QPointF(p[0].x,p[0].y),QPointF(p[1].x,p[1].y)); -// painter->drawLine(QPointF(ursprung.x,ursprung.y),QPointF(x.x,x.y)); -// painter->drawLine(QPointF(ursprung.x,ursprung.y),QPointF(y.x,y.y)); -// painter->drawLine(QPointF(ursprung.x,ursprung.y),QPointF(z.x,z.y)); ///////////////////////////////// // Drawing the X,Y,Z - Symbols // @@ -716,7 +525,6 @@ void CoordItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio if( debug ) debout << "Ursprungskoordinaten: " << ursprung.x << ", " << ursprung.y << std::endl; if( debug ) debout << "Bildsize: " << mMainWindow->getImage()->width() << "x" << mMainWindow->getImage()->height() << std::endl; if( debug ) sprintf (coordinaten, "(%f %f %f)", tX3D, tY3D, tZ3D); - //painter->drawText(QPoint(ursprung.x+25,ursprung.y),QString(coordinaten)); ////////////////////////////// // Drawing the tick-markers // @@ -786,7 +594,6 @@ void CoordItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio points[1] = QPointF(p[1].x,p[1].y); points[2] = QPointF(p[2].x,p[2].y); painter->setPen(Qt::green); -// painter->drawPolygon(points,3,Qt::WindingFill); painter->setPen(QPen(QBrush(Qt::blue),coordLineWidth)); painter->drawLine(points[0],points[1]); painter->drawLine(points[0],points[2]); @@ -799,7 +606,6 @@ void CoordItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio points[1] = QPointF(p[1].x,p[1].y); points[2] = QPointF(p[2].x,p[2].y); painter->setPen(Qt::green); -// painter->drawPolygon(points,3,Qt::WindingFill); painter->setPen(QPen(QBrush(Qt::blue),coordLineWidth)); painter->drawLine(points[0],points[1]); painter->drawLine(points[0],points[2]); @@ -822,7 +628,6 @@ void CoordItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio points[1] = QPointF(p[1].x,p[1].y); points[2] = QPointF(p[2].x,p[2].y); painter->setPen(Qt::green); -// painter->drawPolygon(points,3,Qt::WindingFill); painter->setPen(QPen(QBrush(Qt::blue),coordLineWidth)); painter->drawLine(points[0],points[1]); painter->drawLine(points[0],points[2]); @@ -835,7 +640,6 @@ void CoordItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio points[1] = QPointF(p[1].x,p[1].y); points[2] = QPointF(p[2].x,p[2].y); painter->setPen(Qt::green); -// painter->drawPolygon(points,3,Qt::WindingFill); painter->setPen(QPen(QBrush(Qt::blue),coordLineWidth)); painter->drawLine(points[0],points[1]); painter->drawLine(points[0],points[2]); @@ -858,7 +662,6 @@ void CoordItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio points[1] = QPointF(p[1].x,p[1].y); points[2] = QPointF(p[2].x,p[2].y); painter->setPen(Qt::green); -// painter->drawPolygon(points,3,Qt::WindingFill); painter->setPen(QPen(QBrush(Qt::blue),coordLineWidth)); painter->drawLine(points[0],points[1]); painter->drawLine(points[0],points[2]); @@ -871,7 +674,6 @@ void CoordItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio points[1] = QPointF(p[1].x,p[1].y); points[2] = QPointF(p[2].x,p[2].y); painter->setPen(Qt::green); -// painter->drawPolygon(points,3,Qt::WindingFill); painter->setPen(QPen(QBrush(Qt::blue),coordLineWidth)); painter->drawLine(points[0],points[1]); painter->drawLine(points[0],points[2]); diff --git a/src/ellipse.cpp b/src/ellipse.cpp index 093a97785..b91ffc060 100644 --- a/src/ellipse.cpp +++ b/src/ellipse.cpp @@ -36,12 +36,10 @@ // kann auch schief stehen, hat aber keine abfragen, ob punkt innerhalb MyEllipse::MyEllipse() - : // mC(0, 0), default + : mR1(0), mR2(0), mAngle(0) - // mF1(0, 0), default - // mF2(0, 0), default { } MyEllipse::MyEllipse(double x, double y, double r1, double r2, double angle) @@ -61,14 +59,12 @@ MyEllipse::MyEllipse(QPointF center, QSizeF size, double angle) Vec2F MyEllipse::center() const { - //return QPointF(mC.x(), mC.y()); return mC; } QSizeF MyEllipse::size() const { return QSizeF(mR1, mR2); } -// inline fkt muessen im header definiert werden!!! double MyEllipse::area() const { @@ -104,12 +100,10 @@ bool MyEllipse::isNearlyCircle() const void MyEllipse::draw(cv::Mat &img, int r, int g, int b) const { cv::Size size; -// 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, 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 00a0f1f99..2cd75be21 100644 --- a/src/extrCalibration.cpp +++ b/src/extrCalibration.cpp @@ -88,7 +88,6 @@ bool ExtrCalibration::openExtrCalibFile(){ mExtrCalibFile = extrCalibFile; return loadExtrCalibFile(); } - //cout << mCalibFiles.first().toStdString() << endl; //toAscii() .data() Local8Bit().constData() << endl; } return false; @@ -146,6 +145,7 @@ bool ExtrCalibration::loadExtrCalibFile(){ with_3D_data = false, end_loop = false; + // Exit loop when reaching the end of the file while( !in.atEnd() ) { // Neue Zeile einlesen @@ -159,9 +159,6 @@ bool ExtrCalibration::loadExtrCalibFile(){ line.startsWith("!",Qt::CaseInsensitive) ) continue; - // Test-Ausgabe -// debout << "line: " << line << endl; - QTextStream stream(&line); counter = 0; end_loop = false; @@ -199,7 +196,6 @@ bool ExtrCalibration::loadExtrCalibFile(){ py = zahl; break; default: - //debout << "### Error: counter=" << counter << endl; end_loop = true; } @@ -387,19 +383,7 @@ bool ExtrCalibration::saveExtrCalibPoints() } bool ExtrCalibration::isSetExtrCalib(){ - -// bool isSetExtrCalib = false; -// -// if( mControlWidget->getCalibExtrRot1() != 0.00 && -// mControlWidget->getCalibExtrRot2() != 0.00 && -// mControlWidget->getCalibExtrRot3() != 0.00 && -// mControlWidget->getCalibExtrTrans1() != 0.00 && -// mControlWidget->getCalibExtrTrans2() != 0.00 && -// mControlWidget->getCalibExtrTrans3() != 0.00 ) -// { -// isSetExtrCalib = true; -// } - return true;//isSetExtrCalib; + return true; } /** @@ -418,16 +402,6 @@ void ExtrCalibration::calibExtrParams() 0, mControlWidget->fy->value(), mControlWidget->cy->value()-bS, 0, 0, 1); - /* Distortion Params must be 0 because only undistorted images are supported */ -// if( mControlWidget->r2->value() != 0 || mControlWidget->r4->value() != 0 -// || mControlWidget->tx->value() != 0 || mControlWidget->ty->value() != 0 ) -// { -// QMessageBox::warning(mMainWindow, "Petrack", -// "The distortion Parameters are set!\n" -// "The 3D Camera-Calibration is implemented only for images without distortion.\n" -// "There is no waranty of correct results!", -// QMessageBox::Ok,QMessageBox::Ok); -// } cv::Mat distMat = (cv::Mat_<double>(8,1) << 0,//mControlWidget->r2->value(), 0,//mControlWidget->r4->value(), @@ -444,41 +418,12 @@ void ExtrCalibration::calibExtrParams() cv::Mat op(points3D); cv::Mat ip(points2D); - //cout << "3D Punkte: " << endl << " " << format(points3D,"csv") << endl; - //cout << "2D Punkte: " << endl << " " << format(points2D,"csv") << endl; - /* Mat-objects for result rotation and translation vectors */ cv::Mat rvec(3,1,CV_64F),/*,0),*/ tvec(3,1,CV_64F);//,0); // Solve the PnP-Problem to calibrate the camera to its environment cv::solvePnP(op,ip,camMat,distMat,rvec,tvec,false,cv::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); - //bool solvePNPsuccess = solvePnP(op,ip,camMat,distMat,rvec,tvec,false,SOLVEPNP_DLS); - //bool solvePNPsuccess = solvePnP(op,ip,camMat,distMat,rvec,tvec,false,SOLVEPNP_UPNP); - //bool solvePNPsuccess = true; - //solvePnPRansac(op,ip,camMat,distMat,rvec,tvec); - - - -// debout << "The solvePNP-Method " << (solvePNPsuccess ? "" : "doesn't ") << "worked. " << solvePNPsuccess << endl; - -// void decomposeProjectionMatrix(InputArray projMatrix, -// OutputArray cameraMatrix, -// OutputArray rotMatrix, -// OutputArray transVect, -// OutputArray rotMatrixX=noArray(), -// OutputArray rotMatrixY=noArray(), -// OutputArray rotMatrixZ=noArray(), -// OutputArray eulerAngles=noArray() ); - -// debout << "Rotation:" << endl; -// debout << rvec.at<double>(0,0) << ", " << rvec.at<double>(1,0) << ", " << rvec.at<double>(2,0) << endl; -// debout << rvec.at<double>(0,0) << ", " << rvec.at<double>(0,1) << ", " << rvec.at<double>(0,2) << endl; -// debout << "Translation:" << endl; -// debout << tvec.at<double>(0,0) << ", " << tvec.at<double>(1,0) << ", " << tvec.at<double>(2,0) << endl; -// debout << tvec.at<double>(0,0) << ", " << tvec.at<double>(0,1) << ", " << tvec.at<double>(0,2) << endl; cv::Mat rot_mat(3,3,CV_64F);//, 0); // Transform the rotation vector into a rotation matrix with opencvs rodrigues method @@ -534,10 +479,6 @@ void ExtrCalibration::calibExtrParams() mControlWidget->setCalibExtrTrans2(translation_vector2[1]); mControlWidget->setCalibExtrTrans3(translation_vector2[2]); -// mControlWidget->setCalibCoord3DTransX(0); -// mControlWidget->setCalibCoord3DTransY(0); -// mControlWidget->setCalibCoord3DTransZ(0); - if ( !calcReprojectionError() ) { std::cout << "# Warning: extrinsic calibration not possible! Please select other 2D/3D points!" << std::endl; @@ -599,7 +540,6 @@ bool ExtrCalibration::calcReprojectionError() var_px = 0, sd_px = 0, var_pH = 0, sd_pH = 0, var_dH = 0, sd_dH = 0, sum_px = 0, sum_pH = 0, sum_dH = 0; - //int bS = mMainWindow->getImageBorderSize(); size_t num_points = get2DList().size(); if(num_points == 0 || num_points != get3DList().size()){ reprojectionError = ReprojectionError{}; @@ -617,17 +557,11 @@ bool ExtrCalibration::calcReprojectionError() cv::Point2f p3dTo2d = getImagePoint(p3d); // Error measurements metric (cm) - //debout << "Point-Height: " << endl; cv::Point3f p2dTo3d = get3DPoint(p2d,p3d.z); - //debout << p2d.x << " " << p2d.y << " " << p2d.z << endl; - //debout << p3d.x << " " <<p3d.y << " " <<p3d.z << endl; - //debout << "Default-Height: " << endl; cv::Point3f p2dTo3dMapDefaultHeight = get3DPoint(p2d,mControlWidget->mapDefaultHeight->value()); - //debout << p2d_mapDefaultHeight.x << " " << p2d_mapDefaultHeight.y << " " << p2d_mapDefaultHeight.z << endl; cv::Point3f p3dTo2dTo3dMapDefaultHeight = get3DPoint(p3dTo2d,mControlWidget->mapDefaultHeight->value()); - //debout << p3d_mapDefaultHeight.x << " " << p3d_mapDefaultHeight.y << " " << p3d_mapDefaultHeight.z << endl; val = sqrt(pow(p3d.x - p2dTo3d.x,2) + pow(p3d.y - p2dTo3d.y,2)); if ( val > max_pH ) max_pH = val; @@ -657,17 +591,11 @@ bool ExtrCalibration::calcReprojectionError() cv::Point2f p3d_to_2d = getImagePoint(p3d); // Error measurements metric (cm) - //debout << "Point-Height: " << endl; cv::Point3f p2d_to_3d = get3DPoint(p2d,p3d.z); - //debout << p2d.x << " " << p2d.y << " " << p2d.z << endl; - //debout << p3d.x << " " <<p3d.y << " " <<p3d.z << endl; - //debout << "Default-Height: " << endl; cv::Point3f p2d_to_3d_mapDefaultHeight = get3DPoint(p2d,mControlWidget->mapDefaultHeight->value()); // mStatusPosRealHeight->value()); ? - //debout << p2d_mapDefaultHeight.x << " " << p2d_mapDefaultHeight.y << " " << p2d_mapDefaultHeight.z << endl; cv::Point3f p3d_to2d_to3d_mapDefaultHeight = get3DPoint(p3d_to_2d,mControlWidget->mapDefaultHeight->value()); - //debout << p3d_mapDefaultHeight.x << " " << p3d_mapDefaultHeight.y << " " << p3d_mapDefaultHeight.z << endl; val = pow(sqrt(pow(p3d.x-p2d_to_3d.x,2) + pow(p3d.y-p2d_to_3d.y,2))-(sum_pH/num_points),2); var_pH += val; @@ -768,25 +696,17 @@ cv::Point2f ExtrCalibration::getImagePoint(cv::Point3f p3d) std::cout << "\n-.- ESTIMATED ROTATION\n"; for ( size_t p=0; p<3; p++ ) printf("%20.18f, %20.18f, %20.18f\n",rot_mat.at<double>(p,0),rot_mat.at<double>(p,1),rot_mat.at<double>(p,2)); - //cout << rot_mat.at<double>(p,0) << " , " << rot_mat.at<double>(p,1) << " , " << rot_mat.at<double>(p,2) << "\n"; std::cout << "\n-.- ESTIMATED ROTATION^-1\n"; for ( size_t p=0; p<3; p++ ) printf("%20.18f, %20.18f, %20.18f\n",rot_inv.at<double>(p,0),rot_inv.at<double>(p,1),rot_inv.at<double>(p,2)); - //cout << rot_inv.at<double>(p,0) << " , " << rot_inv.at<double>(p,1) << " , " << rot_inv.at<double>(p,2) << "\n"; std::cout << "\n-.- ESTIMATED R^-1*R\n"; for ( size_t p=0; p<3; p++ ) printf("%20.18f, %20.18f, %20.18f\n",e.at<double>(p,0),e.at<double>(p,1),e.at<double>(p,2)); - //cout << e.at<double>(p,0) << " , " << e.at<double>(p,1) << " , " << e.at<double>(p,2) << "\n"; std::cout << "\n-.- ESTIMATED TRANSLATION\n"; printf("%20.15f, %20.15f, %20.15f\n",translation_vector[0],translation_vector[1],translation_vector[2]); - //cout << translation_vector[0] << " , " << translation_vector[1] << " , " << translation_vector[2] << "\n"; - - //cout << this->translation_vector[0] << " = " << translation_vector[0] << endl; - //cout << this->translation_vector[1] << " = " << translation_vector[1] << endl; - //cout << this->translation_vector[2] << " = " << translation_vector[2] << endl; } cv::Point3f point3D; @@ -833,7 +753,6 @@ cv::Point2f ExtrCalibration::getImagePoint(cv::Point3f p3d) cv::Point3f ExtrCalibration::get3DPoint(cv::Point2f p2d, double h) { bool debug = false; -// bool debug = true; if( debug ) std::cout << "get3DPoint: Start Point2D: (" << p2d.x << ", " << p2d.y << ") h: " << h << std::endl; @@ -848,6 +767,7 @@ cv::Point3f ExtrCalibration::get3DPoint(cv::Point2f p2d, double h) // Ergebnis 3D-Punkt cv::Point3f resultPoint, tmpPoint; + bool newMethod = true; /////////////// Start new method if( newMethod ) @@ -884,17 +804,14 @@ cv::Point3f ExtrCalibration::get3DPoint(cv::Point2f p2d, double h) debout << "\n-.- ESTIMATED ROTATION\n"; for ( size_t p=0; p<3; p++ ) printf("%20.18f, %20.18f, %20.18f\n",rot_mat.at<double>(p,0),rot_mat.at<double>(p,1),rot_mat.at<double>(p,2)); - //cout << rot_mat.at<double>(p,0) << " , " << rot_mat.at<double>(p,1) << " , " << rot_mat.at<double>(p,2) << "\n"; debout << "\n-.- ESTIMATED ROTATION^-1\n"; for ( size_t p=0; p<3; p++ ) printf("%20.18f, %20.18f, %20.18f\n",rot_inv.at<double>(p,0),rot_inv.at<double>(p,1),rot_inv.at<double>(p,2)); - //cout << rot_inv.at<double>(p,0) << " , " << rot_inv.at<double>(p,1) << " , " << rot_inv.at<double>(p,2) << "\n"; debout << "\n-.- ESTIMATED R^-1*R\n"; for ( size_t p=0; p<3; p++ ) printf("%20.18f, %20.18f, %20.18f\n",e.at<double>(p,0),e.at<double>(p,1),e.at<double>(p,2)); - //cout << e.at<double>(p,0) << " , " << e.at<double>(p,1) << " , " << e.at<double>(p,2) << "\n"; debout << "\n-.- ESTIMATED TRANSLATION\n"; debout << mControlWidget->getCalibExtrTrans1() << " , " << mControlWidget->getCalibExtrTrans2() << " , " << mControlWidget->getCalibExtrTrans3() << "\n"; @@ -912,13 +829,13 @@ cv::Point3f ExtrCalibration::get3DPoint(cv::Point2f p2d, double h) << rot_inv.at<double>(2,1) << "*" << translation_vector[1] << " + " << rot_inv.at<double>(2,2) << "*" << translation_vector[2] << " = " << z << std::endl; } - z /= (rot_inv.at<double>(2,0)*(p2d.x-/*bS)-(*/(mControlWidget->getCalibCxValue()-bS)/*-bS*/)/mControlWidget->getCalibFxValue() + - rot_inv.at<double>(2,1)*(p2d.y-/*bS)-(*/(mControlWidget->getCalibCyValue()-bS)/*-bS*/)/mControlWidget->getCalibFyValue() + + z /= (rot_inv.at<double>(2,0)*(p2d.x-(mControlWidget->getCalibCxValue()-bS))/mControlWidget->getCalibFxValue() + + rot_inv.at<double>(2,1)*(p2d.y-(mControlWidget->getCalibCyValue()-bS))/mControlWidget->getCalibFyValue() + rot_inv.at<double>(2,2)); if( debug ) std::cout << "###### z: "<< z << std::endl; - resultPoint.x = (p2d.x-/*bS)-(*/(mControlWidget->getCalibCxValue()-bS)/*-bS*/); - resultPoint.y = (p2d.y-/*bS)-(*/(mControlWidget->getCalibCyValue()-bS)/*-bS*/); + resultPoint.x = (p2d.x-(mControlWidget->getCalibCxValue()-bS)); + resultPoint.y = (p2d.y-(mControlWidget->getCalibCyValue()-bS)); resultPoint.z = z; if( debug ) std::cout << "###### (" << resultPoint.x << ", " << resultPoint.y << ", " << resultPoint.z << ")" << std::endl; @@ -1028,15 +945,15 @@ cv::Point3f ExtrCalibration::transformRT(cv::Point3f p) point3D.x = rotation_matrix[0] * p.x + rotation_matrix[3] * p.y + rotation_matrix[6] * p.z - - mControlWidget->trans1->value();//translation_vector2[0]; + mControlWidget->trans1->value(); point3D.y = rotation_matrix[1] * p.x + rotation_matrix[4] * p.y + rotation_matrix[7] * p.z - - mControlWidget->trans2->value();//translation_vector2[1]; + mControlWidget->trans2->value(); point3D.z = rotation_matrix[2] * p.x + rotation_matrix[5] * p.y + rotation_matrix[8] * p.z - - mControlWidget->trans3->value();//translation_vector2[2]; + mControlWidget->trans3->value(); return point3D; } bool ExtrCalibration::isOutsideImage(cv::Point2f p2d) @@ -1048,7 +965,6 @@ bool ExtrCalibration::isOutsideImage(cv::Point2f p2d) return true; if (isnan(p2d.x) || isnan(p2d.y) || isinf(p2d.x) || isinf(p2d.y)) return true; - //return p2d.x < 0 || p2d.x > mMainWindow->getImage()->width() || p2d.y < 0 || p2d.y > mMainWindow->getImage()->height(); return p2d.x < -bS || p2d.x > mMainWindow->getImage()->width()-bS || p2d.y < -bS || p2d.y > mMainWindow->getImage()->height()-bS; }else { diff --git a/src/filter.cpp b/src/filter.cpp index 066d75155..efc1cb879 100644 --- a/src/filter.cpp +++ b/src/filter.cpp @@ -91,11 +91,9 @@ void Parameter::setChanged(bool b) Filter::Filter() { - mEnable = true; //enable(); - mOnCopy = true; //setOnCopy(true); -// mRes = NULL; + mEnable = true; + mOnCopy = true; mChg = false; -// mResStored = false; } /** @@ -165,8 +163,8 @@ cv::Mat Filter::getLastResult() void Filter::freeLastResult() { -// cvReleaseImage(&mRes); -} //free oder delete? - beides falsch + //free oder delete? - beides falsch +} void Filter::enable() { @@ -197,17 +195,3 @@ bool Filter::getOnCopy() const { return mOnCopy; } - -// void Filter::addParam(QString *name, min, max, default) -// { -// } - -// flag zur Anzeige, ob auf Originaldaten Filter angewendet werden kann und somit setoncop(false) moeglich ist - -// flag zur Anzeige, ob Filter Bildgroesse veraendert - -// widget, mit dem parameter einstellbar sind -// grundlegender rahmen mit ok, cancel und preview wie in photoshop -// inneres kann von abgeleiteter klasse kommen - -// einstellen welche parameter: anzahl, name, wertebereich, default diff --git a/src/gridItem.cpp b/src/gridItem.cpp index b29e158a5..a178b4bae 100644 --- a/src/gridItem.cpp +++ b/src/gridItem.cpp @@ -32,8 +32,6 @@ GridItem::GridItem(QWidget *wParent, QGraphicsItem * parent) mMainWindow = (class Petrack*) wParent; extCalib = mMainWindow->getExtrCalibration(); mControlWidget = mMainWindow->getControlWidget(); - //setEnabled(false); // all mouse events connot access this item, but it will be seen - // einzig move koennte interessant sein, um grid zu verschieben?! } /** @@ -59,24 +57,17 @@ QRectF GridItem::boundingRect() const // event, of moving mouse while pressing a mouse button void GridItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - - //debout << ">>>>>>>>MouseMoveEvent: " << mouse_x << ", " << mouse_y << endl; - if (!mControlWidget->getCalibGridFix()) { setCursor(Qt::SizeBDiagCursor); - //setCursor(QPixmap("/home/zam/salden/Desktop/grid_small.png")); - // setCursor(Qt::ClosedHandCursor); QPointF diff = event->scenePos()-event->lastScenePos(); //screenPos()-buttonDownScreenPos(Qt::RightButton) also interesting if (event->buttons() == Qt::RightButton) // event->button() doesnt work { mControlWidget->setCalibGridRotate(mControlWidget->getCalibGridRotate()+(int)(3.*(diff.x()+diff.y()))); - //cout << diff.x()-diff.y() <<endl; //globalPos() } else if (event->buttons() == Qt::LeftButton) { - //debout << "Grid Dimension: " << mControlWidget->getCalibGridDimension() << endl; if( mControlWidget->getCalibGridDimension() == 0 ) { cv::Point3f p3d = extCalib->get3DPoint(cv::Point2f(event->scenePos().x(), @@ -121,8 +112,6 @@ void GridItem::mousePressEvent(QGraphicsSceneMouseEvent *event) gridTrans_x = mControlWidget->getCalibGrid3DTransX(); gridTrans_y = mControlWidget->getCalibGrid3DTransY(); - - //debout << ">>>>>>>>MousePressEvent: " << mouse_x << ", " << mouse_y << endl; } }else { @@ -130,23 +119,6 @@ void GridItem::mousePressEvent(QGraphicsSceneMouseEvent *event) } } -//// event, of moving mouse -//void GridItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -//{ -// QPointF pos = event->scenePos(); -// pos.setX3D(pos.x() + mMainWindow->getImageBorderSize()); -// pos.setY3D(pos.y() + mMainWindow->getImageBorderSize()); -// mMainWindow->setMousePosOnImage(pos); -// -// // cursor doesnt change like coord and roi because complex handling if fixed!!! -//// if (!mControlWidget->getCalibGridFix()) -//// setCursor(Qt::OpenHandCursor); -//// else -//// setCursor(Qt::CrossCursor); -// -// QGraphicsItem::hoverMoveEvent(event); - - int GridItem::drawLine(QPainter *painter, cv::Point2f *p, int y_offset){ int bS = mMainWindow->getImageBorderSize(); @@ -172,9 +144,6 @@ int GridItem::drawLine(QPainter *painter, cv::Point2f *p, int y_offset){ double m = (p[1].y-p[0].y)/(p[1].x-p[0].x), // Steigung b = p[1].y-m*p[1].x; // Achsenabschnitt - //debout << "P1(" << p[0].x << "," << p[0].y << "), P2(" << p[1].x << "," << p[1].y << ")" << endl; - //debout << "Steigung m=" << m << " Achsenabschnitt b=" << b << endl; - // boolean Werte fuer beide Endpunkte der Geraden, am Ende schauen, ob beide gesetzt wurden bool p1IsSet = false, p2IsSet = false; @@ -233,7 +202,7 @@ int GridItem::drawLine(QPainter *painter, cv::Point2f *p, int y_offset){ p1IsSet = true; } } - //debout << "p1: " << p1IsSet << " p2: " << p2IsSet << endl; + // Schauen, ob beide Endpunkte der Geraden gesetzt wurden if( p1IsSet && p2IsSet ) { @@ -247,30 +216,13 @@ void GridItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option { bool debug = false; -// bool debug = true; - - // QMatrix matrix; - // matrix.translate(-mMainWindow->getImageBorderSize(), -mMainWindow->getImageBorderSize()); - // setMatrix(matrix); - - // folgende zeilen waren mal noetig und haben 50% CPU load verursacht, - // weil wahrscheinlich mit setmatrix ein neues paint angestossen wurde - // cpu load 0 war alleine mit grid.setvisible(false) zu erzeugen - // //FAKE!!!!!!!!!!!!!!!!!!!!!!!! - // QMatrix matrix; - // matrix.translate(1, 1); // FEHLER IN QT ????? noetig, damit trotz recognitionroiitem auch image auch ohne border komplett neu gezeichnet wird // wird 2 zeilen weiter zurueckgesetzt, aber mit 0, 0 geht es nicht - // setMatrix(matrix); - // matrix.translate(-1, -1); - // setMatrix(matrix); if (!mControlWidget->getCalibGridFix() && mControlWidget->getCalibGridShow()) { - //setFlags(ItemIsMovable); // noetig, damit mouseEvent leftmousebutton weitergegeben wird, aber drag mach ich selber setFlag(ItemIsMovable); // noetig, damit mouseEvent leftmousebutton weitergegeben wird, aber drag mach ich selber } else { - //setFlags(!ItemIsMovable); setFlag(ItemIsMovable, false); } @@ -308,7 +260,6 @@ void GridItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option debout << "A2d x=" << a2d.x << ", y=" << a2d.y << std::endl; debout << "B2d x=" << b2d.x << ", y=" << b2d.y << std::endl; debout << "C2d x=" << c2d.x << ", y=" << c2d.y << std::endl; - // debout << "D2d x=" << d2d.x << ", y=" << d2d.y << endl; } // y = m*x+n float m1 = (b2d.y-a2d.y)/(b2d.x-a2d.x), @@ -431,21 +382,10 @@ void GridItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option double ro = mControlWidget->getCalibGridRotate()/10.; // transformation nicht des koordinatensystems wie bei coorditem sondern bei grid der painter - - // // aktualisierung der transformationsmatrix - // QMatrix matrix; - // // matrix wird nur bei aenderungen neu bestimmt - // matrix.translate(mControlWidget->getCalibGridTransX()/10., mControlWidget->getCalibGridTransY()/10.); - // matrix.rotate(mControlWidget->getCalibGridRotate()/10.); - // //matrix.scale(sc/100., sc/100.); - // setMatrix(matrix); - // grid painter->save(); // wie opengl matrix aber auch pen etc auf stack matrixPaint.translate(tX, tY); // hier ist translate zusaetzlich auf matrix, bei translate-fkt von item ist absolut - //matrixPaint.translate(iW/2.-bS, iH/2.-bS); matrixPaint.rotate(ro); - //matrixPaint.translate(-iW/2.+bS, -iH/2.+bS); painter->setWorldTransform(matrixPaint, true); // true sagt, dass relativ und nicht absolut (also zusaetzlich zur uebergeordneten matrizen) painter->setPen(Qt::red); @@ -475,7 +415,6 @@ void GridItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option }; painter->setPen(Qt::NoPen); painter->setBrush(Qt::white); - //painter->setBrush(Qt::green); bool drawPolygon = true; @@ -488,29 +427,7 @@ void GridItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option { if( extCalib->isSetExtrCalib() ){ - /*char text[100]; - - painter->setPen(Qt::blue); - Point3f mousePoint = extCalib->get3DPoint(Point2f(mouse_x,mouse_y),tZ3D); - - debout << ">>>>>>>>Mouse Point: " << mousePoint.x << ", " << mousePoint.y << ", " << mousePoint.z << endl; - - sprintf (text, "3D: (%.2f, %.2f, %.2f)", mousePoint.x, mousePoint.y, mousePoint.z); - painter->drawText(mouse_x, mouse_y, QString(text)); - - painter->setPen(Qt::red); - */ double min_x = INT_MAX, min_y = INT_MAX, max_x = INT_MIN, max_y = INT_MIN; - - - - /* - Point2f p2f[4]; - p2f[0] = Point2f(0-bS,0-bS); - p2f[0] = Point2f(0-bS,0-bS); - p2f[0] = Point2f(0-bS,0-bS); - p2f[0] = Point2f(0-bS,0-bS); - */ int y_offset = -bS; if( vanishPointXIsInsideImage ){ @@ -536,22 +453,6 @@ void GridItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option painter->setPen(Qt::green); - // painter->drawLine(QPointF(0-bS+2,y_offset+2),QPointF(iW-bS-2,y_offset+2)); - // painter->drawLine(QPointF(iW-bS-2,y_offset+2),QPointF(iW-bS-2,iH-bS-2)); - // painter->drawLine(QPointF(iW-bS-2,iH-bS-2),QPointF(0-bS+2,iH-bS-2)); - // painter->drawLine(QPointF(0-bS+2,iH-bS-2),QPointF(0-bS+2,y_offset+2)); - - //debout << "Width: " << iW << ", Height: " << iH << endl; - - // painter->setPen(Qt::green); - // painter->drawLine(QPointF(points[0].x,points[0].y),QPointF(points[1].x,points[1].y)); - // painter->drawLine(QPointF(points[3].x,points[3].y),QPointF(points[1].x,points[1].y)); - // painter->drawLine(QPointF(points[2].x,points[2].y),QPointF(points[3].x,points[3].y)); - // painter->drawLine(QPointF(points[0].x,points[0].y),QPointF(points[2].x,points[2].y)); - // painter->setPen(Qt::red); - - //debout << ">>>>>>>>>Eckpunkte: " << endl; - for(int i=0;i<4;i++) { x = points[i].x; @@ -570,10 +471,7 @@ void GridItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option if( debug ) std::cout << "X: min=" << min_x << " min:" << max_x << std::endl; if( debug ) std::cout << "Y: min=" << min_y << " max:" << max_y << std::endl; - //mControlWidget->setGridMinMaxTranslation(min_x, max_x, min_y, max_y); - - cv::Point3f ursprung(0,0,0);// = extCalib->getImagePoint(Point3f(tX3D,tY3D,tZ3D)); - int res = -1; + cv::Point3f ursprung(0,0,0); cv::Point3f xl, xr, yo, yu; cv::Point2f p[4]; @@ -642,8 +540,6 @@ void GridItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option int swapY = mControlWidget->getCalibCoord3DSwapY() ? -1 : 1; int grid_height = tZ3D-mControlWidget->getCalibCoord3DTransZ(); // Da extCalibration immer vom Koordinatensystemursprung ausgeht (Das Grid soll aber unabhngig davon gezeichnet werden) - //int vorzeichenX = 1, vorzeichenY = 1; - if( debug ) debout << "Grid x: " << tX3D << " y: " << tY3D << " z: " << tZ3D << " y_offset: " << y_offset << " bS: " << bS << " iW: " << iW << " iH: " << iH << " min_x: " << min_x << " max_x: " << max_x << " min_y: " << min_y << " max_y: " << max_y << std::endl; @@ -651,67 +547,40 @@ void GridItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option // horizontal lines from the left to the right on height tZ3D the lines start from origin point (tY3D) // until max_y or if tY3D < min_y it starts with min_y because otherwise it is outside the image - //Point3f p3d_center = extCalib->get3DPoint(Point2f(iW/2,iH/2),tZ3D); - - //if( debug ) debout << "Centerpoint 2D: (" << iW/2 << "," << iH/2 << "), 3D: (" << p3d_center.x << "," << p3d_center.y << "," << p3d_center.z << ")" << endl; - // y+ -// for(int i = p3d_center.y+tY3D; i<max_y; i+=resolution) for(int i = -mControlWidget->getCalibCoord3DTransY()+tY3D; i < (swapY > 0 ? max_y : -min_y); i+=resolution) { - - //debout << "i=" << -mControlWidget->getCalibCoord3DTransY()+tY3D << "; i<" << (swapY > 0 ? max_y : min_y) << "; i+=" << resolution << endl; // Bildpunkte zu den Endpunkten der Linie holen p[0] = extCalib->getImagePoint(cv::Point3f(min_x,swapY*i,grid_height)); - //if( debug ) debout << "p[0] x: " << p[0].x << " y: " << p[0].y << endl; p[1] = extCalib->getImagePoint(cv::Point3f(max_x,swapY*i,grid_height)); - //if( debug ) debout << "p[1] x: " << p[1].x << " y: " << p[1].y << endl; - res = drawLine(painter,p,y_offset); - if (debug) debout << "Zeichnung? " << res << std::endl; - //if( debug ) debout << "i: " << i << endl; - + drawLine(painter,p,y_offset); } // see above but now the lines start from origin point (tY3D) until min_y // y- -// for(int i = p3d_center.y+tY3D-resolution; i>min_y; i-=resolution) for(int i = -mControlWidget->getCalibCoord3DTransY()+tY3D-resolution; i > (swapY > 0 ? min_y : -max_y); i-=resolution) { - //debout << "i=" << -mControlWidget->getCalibCoord3DTransY()+tY3D-resolution << "; i<" << (swapY > 0 ? min_y : -max_y) << "; i-=" << resolution << endl; // Bildpunkte zu den Endpunkten der Linie holen p[0] = extCalib->getImagePoint(cv::Point3f(min_x,swapY*i,grid_height)); p[1] = extCalib->getImagePoint(cv::Point3f(max_x,swapY*i,grid_height)); - res = drawLine(painter,p,y_offset); - if (debug) debout << "Zeichnung? " << res << std::endl; - - + drawLine(painter,p,y_offset); } // vertical lines from the top to the bottom on height tZ3D the lines start from origin point(tX3D) // until max_x of if tX3D < minx it starts with min_x because otherwise the lines are outside the image // x+ -// for(int i = p3d_center.x+tX3D; i<max_x; i+=resolution) for(int i = -mControlWidget->getCalibCoord3DTransX()+tX3D; i < (swapX > 0 ? max_x : -min_x); i+=resolution) { - //debout << "i=" << -mControlWidget->getCalibCoord3DTransX()+tX3D << "; i<" << (swapX > 0 ? max_x : -min_x) << "; i+=" << resolution << endl; - //debout << "x+ " << i << endl; // Bildpunkte zu den Endpunkten der Linie holen p[0] = extCalib->getImagePoint(cv::Point3f(swapX*i,min_y,grid_height)); p[1] = extCalib->getImagePoint(cv::Point3f(swapX*i,max_y,grid_height)); - res = drawLine(painter,p,y_offset); - if (debug) debout << "Zeichnung? " << res << std::endl; - + drawLine(painter,p,y_offset); } // see above but now the lines start from origin point until min_x // x- -// for(int i = p3d_center.x+tX3D-resolution; i>min_x; i-=resolution) for(int i = -mControlWidget->getCalibCoord3DTransX()+tX3D-resolution; i > (swapX > 0 ? min_x : -max_x); i-=resolution) { - //debout << "i=" << -mControlWidget->getCalibCoord3DTransX()+tX3D-resolution << "; i<" << (swapX > 0 ? min_x : -max_x) << "; i-=" << resolution << endl; - //debout << "x- " << i << endl; // Bildpunkte zu den Endpunkten der Linie holen p[0] = extCalib->getImagePoint(cv::Point3f(swapX*i,min_y,grid_height)); p[1] = extCalib->getImagePoint(cv::Point3f(swapX*i,max_y,grid_height)); - res = drawLine(painter,p,y_offset); - if (debug) debout << "Zeichnung? " << res << std::endl; - + drawLine(painter,p,y_offset); } @@ -721,5 +590,4 @@ void GridItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option } } - //setVisible(false); } diff --git a/src/helper.cpp b/src/helper.cpp index e57e0267c..45893984b 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -110,11 +110,6 @@ rect wird veraendert, roi nicht */ cv::Mat getRoi(cv::Mat &img, const QRect &roi, cv::Rect &rect, bool evenPixelNumber) { -// Mat tImg; -// IplImage *header; -// CvSize size; -// CvMat *p = NULL; - rect.x = roi.x(); rect.y = roi.y(); rect.width = roi.width(); @@ -157,68 +152,5 @@ cv::Mat getRoi(cv::Mat &img, const QRect &roi, cv::Rect &rect, bool evenPixelNum rect.height -= (rect.y+rect.height-img.rows); } -// PROCESS_MEMORY_COUNTERS pMC; -// DWORD a; -// GetProcessMemoryInfo(GetCurrentProcess(),&pMC, a); -// debout << a << endl; -// debout << pMC.cb << endl; -// debout << pMC.PageFaultCount << endl; -// debout << pMC.PeakWorkingSetSize << endl; -// debout << pMC.WorkingSetSize << endl; -// debout << pMC.QuotaPeakPagedPoolUsage << endl; -// debout << pMC.QuotaPagedPoolUsage << endl; -// debout << pMC.QuotaPeakNonPagedPoolUsage << endl; -// debout << pMC.QuotaNonPagedPoolUsage << endl; -// debout << pMC.PagefileUsage << endl; -// debout << pMC.PeakPagefileUsage << endl; - -// ----------------------------------------- folgende Zeilen ----------------------------------------------------------- -// //cvSetImageROI(img, rect); - absturz! -// // no copy of data, only new header which allows to access rect -// // must be done with mat, no image equivalents! -// if (img->nChannels == 3) -// p = cvCreateMatHeader(rect.height, rect.width, CV_32SC4); // CV_32SC4 mgl Problem bei graubildern -// else if (img->nChannels == 1) -// p = cvCreateMatHeader(rect.height, rect.width, CV_8SC1); -// else -// { -// debout << "Error: wrong number of channels: " << img->nChannels << endl; -// return NULL; -// } -// cvGetSubRect(img, p, rect); // rect ausschnitt von img wird in imageheader p gepackt (keine Datenkopie noetig) -// size.width = rect.width; -// size.height = rect.height; -// header = cvCreateImageHeader(size, img->depth, img->nChannels); -// tImg = cvGetImage(p, header); -// cvFree(&p); // (void**) only header -// -------------------------- durch diese ersetzt, da es beim Verschieben des linken ROI Randes zum Absturz bei Zugriff auf tImg kam!!!!!!!!!!! - /* copy ROI to subimg */ -// tImg = cvCreateImage(cvSize(rect.width,rect.height), img->depth, img->nChannels); -// cvSetImageROI(img, rect); -// cvCopy(img, tImg, NULL); // kopiert nur ROI -// cvResetImageROI(img); - // am schoensten waere natuerlich man wuerde roi setzen und die find-routinen wuerden nur diesen Bereich beachten -//------------------------------------------------------------------------------------------------------- - return img(rect); - - //int x, y; - //int channels = img->nChannels; - //// Pointer to the data information in the IplImage - //unsigned char *data = (unsigned char *) img->imageData; - // // mark white regions green - // for (y = 0; y < img->height; ++y) - // { - // for (x = 0; x < img->width; ++x) - // { - // if (data[0] > 150 && data[1] > 150 && data[2] > 150) - // // eher grautoene statt farben: && data[0]-data[1] < 5 && data[1]-data[2] < 5) - // { - // data[0] = 0; - // data[1] = 255; - // data[2] = 0; - // } - // data += channels; - // } - // } } diff --git a/src/imageItem.cpp b/src/imageItem.cpp index 7d6696e06..fe30658e5 100644 --- a/src/imageItem.cpp +++ b/src/imageItem.cpp @@ -36,7 +36,6 @@ ImageItem::ImageItem(QWidget *wParent, QGraphicsItem * parent) mCoordItem = nullptr; setCursor(Qt::CrossCursor); setAcceptHoverEvents(true); -// setAcceptDrops(true); } /** @@ -51,26 +50,16 @@ QRectF ImageItem::boundingRect() const { if (mImage) { -// debout << "mImage: w=" << mImage->width() << ", h=" << mImage->height() << endl; return QRectF(0, 0, mImage->width(), mImage->height()); -// return QRectF(-mMainWindow->getImageBorderSize(), -mMainWindow->getImageBorderSize(), mImage->width(), mImage->height()); }else return QRectF(0, 0, 0, 0); } void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) { -// painter->drawImage(-mMainWindow->getImageBorderSize(),-mMainWindow->getImageBorderSize(),*mImage); if (mImage) painter->drawImage(0,0,*mImage); } - -// // separate fkt, damit nicht wie bei setimage control-zahlen neu gerechnet werden und recognition-rect angepasst wird -// void ImageItem::setLogo(QImage *img) -// { -// mImage = img; -// mScene->update(); -// } void ImageItem::setImage(QImage *img) { @@ -82,8 +71,6 @@ void ImageItem::setImage(QImage *img) matrix.translate(-mMainWindow->getImageBorderSize()-1, -mMainWindow->getImageBorderSize()-1); setTransform(matrix); - //debout << "mControlWidget->setCalibCxMin(MAX(0," << mImage->width() << "/2.-50)); (" << MAX(0,mImage->width()/2.-50) << ")" << endl; - //debout << "mControlWidget->setCalibCyMin(MAX(0," << mImage->height() << "/2.-50)); (" << MAX(0,mImage->height()/2.-50) << ")" << endl; // value nicht setzen, da mgl mehrere videos mit gleichem objektiv erzeugt mControlWidget->setCalibCxMin(0 /*MAX(0,mImage->width()/2.-50)*/); mControlWidget->setCalibCxMax(mImage->width() /*mImage->width()/2.+50*/); @@ -97,8 +84,6 @@ void ImageItem::setImage(QImage *img) mControlWidget->setCalibCoordTransYMax(10*(mImage->height()-mMainWindow->getImageBorderSize())); mMainWindow->updateSceneRect(); - - //mScene->update(); } void ImageItem::setCoordItem(QGraphicsItem *ci) @@ -141,8 +126,8 @@ QPointF ImageItem::getCmPerPixel(float px, float py, float h){ if( debug ) debout << "Punkte: " << p3y1.x << ", " << p3y1.y << ", " << p3y1.z << std::endl; if( debug ) debout << "Punkte: " << p3y2.x << ", " << p3y2.y << ", " << p3y2.z << std::endl; - double x_dir = norm(p3x1-p3x2); //abs(p3x1.x-p3x2.x); - double y_dir = norm(p3y1-p3y2); //abs(p3y1.y-p3y2.y); + double x_dir = norm(p3x1-p3x2); + double y_dir = norm(p3y1-p3y2); if( debug ) debout << "x_dir: " << x_dir << ", y_dir: " << y_dir << " Durchschnitt: " << (0.5*(x_dir+y_dir)) << std::endl; @@ -237,12 +222,6 @@ QPointF ImageItem::getPosImage(QPointF pos, float height) } -// Liefert die Pixel-Koordinaten zum Punkt senkrecht unter der Kamera -//QPointF ImageItem::getPixelUnderCamera() -//{ - - -//} // eingabe pos als pixelkoordinate des bildes // result in cm (mit y-Achse nach oben gerichtet) @@ -279,7 +258,6 @@ QPointF ImageItem::getPosReal(QPointF pos, double height) { if( debug ) debout << "########## INFO ###############" << std::endl; if( debug ) debout << "Org. 2D Point: (" << pos.x() << ", " << pos.y() << ") Hoehe: "<< height << std::endl; - //double a; // camera altitude // statt mControlWidget->getCalibFx() muesste spaeter wert stehen, der im verzerrten Bild fX=fY angibt //a = mControlWidget->getCalibFxValue()*getMeterPerPixel(); //a = mControlWidget->coordAltitude->value(); @@ -335,9 +313,6 @@ void ImageItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) */ void ImageItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { -// // real coordinate -// mMainWindow->setStatusPosReal(getPosReal(event->pos(), mMainWindow->getStatusPosRealHeight())); - // sets pixel coord on image for further use bool debug = false; @@ -379,33 +354,5 @@ void ImageItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) //QPointF pos = event->pos(); mMainWindow->setMousePosOnImage(event->pos()); -// // pixel coordinate -// //s.sprintf("%4dx%4d", event->pos().x(), event->pos().y()); -// //QTextStream(&s) << event->pos().x() << "x" << event->pos().y(); -// QPoint pos1((int)((event->pos()).x())+1, (int)((event->pos()).y())+1); -// mMainWindow->setStatusPos(pos1); //QString("%1x%2").arg((int)event->pos().x()+1, 4).arg((int)event->pos().y()+1, 4) -// //== event->scenePos().x() -// // Koordinaten auf dem Bildschirm: event->screenPos().x(), event->screenPos().y() - -// // pixel color -// QPoint pos2((int)((event->pos()).x()), (int)((event->pos()).y())); -// mMainWindow->setStatusColor(mImage->pixel(pos2));//(mImage->toImage()).pixel(pos... wenn pixmap - QGraphicsItem::hoverMoveEvent(event); } - -// bool ImageItem::sceneEvent(QEvent * event) -// { -// cout << "event vor allen anderen" <<endl; -// return QGraphicsItem::sceneEvent(event); -// } -//void ImageItem::dragEnterEvent(QDragEnterEvent *event) -//{ -// mMainWindow->dragEnterEvent(event); -//} - -//void ImageItem::dropEvent(QDropEvent * event) -//{ -// mMainWindow->dropEvent(event); -//} - diff --git a/src/logoItem.cpp b/src/logoItem.cpp index cb1958bed..b6d3cce78 100644 --- a/src/logoItem.cpp +++ b/src/logoItem.cpp @@ -49,7 +49,6 @@ void Fader::fadeOut(LogoItem* lI, int frames) mTimer = new QTimer(this); connect(mTimer, SIGNAL(timeout()), this, SLOT(fadeOutStep())); mTimer->start(FRAME_INTERVAL); // fuer 25fps - //QTimer::singleShot(10, this, SLOT(fadeOutSlot())); } void Fader::fadeOutStep() @@ -73,30 +72,13 @@ void Fader::fadeOutStep() } } -// void Fader::fadeOutStep() -// { -// double step = 1./mFrames; -// for (mLogoItem->setOpacity(1.0); mLogoItem->getOpacity()>0.; mLogoItem->setOpacity(mLogoItem->getOpacity()-step)) -// { -// debout << mLogoItem->getOpacity()<<endl; -// // mLogoItem->scene()->update(); // ein neuzeichnen wird erwuenscht und irgendwann bei processEvents gemacht -// // qApp->processEvents(); -// } -// mLogoItem->setVisible(false); -// } - -// -------------------------------------------------- - LogoItem::LogoItem(QWidget *wParent, QGraphicsItem * parent) : QGraphicsItem(parent) { mOpacity = 1.0; mMainWindow = (class Petrack*) wParent; - //mScene = scene; erhaelt man mit scene() mImage = new QImage(":/logo"); // in icons.qrc definiert - //setAcceptDrops(true); - } QRectF LogoItem::boundingRect() const @@ -104,17 +86,6 @@ QRectF LogoItem::boundingRect() const return QRectF(0, 0, mImage->width(), mImage->height()); } -//void LogoItem::dragEnterEvent(QDragEnterEvent *event) -//{ -// debout << "DragEnterEvent(LogoItem)" << endl; -// mMainWindow->dragEnterEvent(event); -//} -//void LogoItem::dropEvent(QDropEvent *event) -//{ -// debout << "DropEvent(LogoItem): " << endl; -// mMainWindow->dropEvent(event); -//} - void LogoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) { int w; @@ -143,15 +114,6 @@ void LogoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*optio void LogoItem::fadeOut(int frames) { fader.fadeOut(this, frames); -// if (frames < 1) -// frames = 1; -// double step = 1./frames; -// for (mOpacity=1.0; mOpacity>0.; mOpacity-=step) -// { -// scene()->update(); // ein neuzeichnen wird erwuenscht und irgendwann bei processEvents gemacht -// qApp->processEvents(); -// } -// setVisible(false); } #include "moc_logoItem.cpp" diff --git a/src/main.cpp b/src/main.cpp index 06e619c66..860ffd432 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,7 +40,7 @@ static QApplication * gApp = nullptr; void quit(int sig_number) { - gApp->quit(); // gPetrack->close(); + gApp->quit(); return; } @@ -84,17 +84,12 @@ int main(int argc, char *argv[]) for (int i = 1; i < arg.size(); ++i) // i=0 ist Programmname { - //cout << arg.at(i).toStdString() << endl; if (arg.at(i) == "-help" || arg.at(i) == "-?") { QTextDocument doc; doc.setHtml(commandLineOptionsString); debout << std::endl << doc.toPlainText() << std::endl; - //debout << commandLineOptionsString <<endl; QMessageBox::about(nullptr, QObject::tr("Command line options"), commandLineOptionsString); - //cout << "Help:\n-----" << endl - // << "Usage: petrack [-help|-?] [[-project] project.pet] [-sequence image_sequence_or_video] [-autoSave|-autosave image_folder_or_video|project.pet|tracker_file] [-autoTrack|-autotrack tracker_file] [-autoPlay|-autoplay tracker_file]" << endl << endl - // << "For more information see http://www.fz-juelich.de/jsc/petrack/." << endl; return 0; // 0 means exit success // 1? } else if (arg.at(i) == "-project") @@ -222,7 +217,6 @@ int main(int argc, char *argv[]) } petrack.exportTracker(autoTrackDest); - if (autoSave && (autoSaveDest.right(4) == ".pet")) { petrack.saveProject(autoSaveDest); diff --git a/src/markerCasern.cpp b/src/markerCasern.cpp index 341e84a26..91fd19b90 100644 --- a/src/markerCasern.cpp +++ b/src/markerCasern.cpp @@ -45,10 +45,6 @@ MarkerCasern::MarkerCasern(MyEllipse head) mHasQuadrangle(false), mCenterIndex(-1), mColorIndex(-1) -// quadrangle[0](0,0), -// quadrangle[1](0,0), -// quadrangle[2](0,0), -// quadrangle[3](0,0) { } MarkerCasern::MarkerCasern() @@ -147,7 +143,7 @@ void MarkerCasern::modifyQuadrangle(const Vec2F v[4]) if (mHasQuadrangle) { // seitenverhaeltnis 2:3 koennte auch bedacht werden - // angle on opposed edge is nearer to 90� + // angle on opposed edge is nearer to 90 if ((fabs((v[3]-v[2]).angleBetweenVec(v[0]-v[3])-PI/2.)+ fabs((v[1]-v[0]).angleBetweenVec(v[2]-v[1])-PI/2.)) < (fabs((mQuadrangle[3]-mQuadrangle[2]).angleBetweenVec(mQuadrangle[0]-mQuadrangle[3])-PI/2.)+ @@ -175,9 +171,6 @@ void MarkerCasern::organize(const cv::Mat &img, bool autoWB) if (mSpots.size() == 0) return; -// for (i = 0; i < mSpots.size(); ++i) -// mSpots[i].draw(img, 0, 255, 0); - // durch mgl wachsen der spots muss ueberprueft werden, ob sich im nachhinnein Ueberlagerungen ergeben for (i = 0; i < mSpots.size(); ++i) for (j = i+1; j < mSpots.size(); ++j) @@ -226,7 +219,7 @@ void MarkerCasern::organize(const cv::Mat &img, bool autoWB) cx = myRound(mSpots[i].x()); cy = myRound(mSpots[i].y()); r = myRound((mSpots[i].r1()+mSpots[i].r2())/2.); // mittlerer radius -// debout << cx+1 << " " << cy+1 << ": "; + int minVal = 256; // groesser als komplett weiss (255) // bildrand muss nicht ueberprueft werden, da sie gar nicht erst hereingekommen waeren for (j = -r; j < r+1; ++j) @@ -237,7 +230,6 @@ void MarkerCasern::organize(const cv::Mat &img, bool autoWB) minVal = col.value(); // Helligkeit } minValList.append(minVal); -// cout << minVal << endl; } // loeschen aller zu hellen spots QList<int> minValListSort = minValList; @@ -245,16 +237,12 @@ void MarkerCasern::organize(const cv::Mat &img, bool autoWB) for (i = 0; i < mSpots.size(); ++i) if (minValList[i] > minValListSort[3]) { -// debout << i << " groesser als " << minValListSort[3]<< endl; deleteSpot(i); minValList.removeAt(i); --i; } } -// for (i = 0; i < mSpots.size(); ++i) -// mSpots[i].draw(img, 255, 0, 0); - // sort spot list: wird nicht gemacht!!!!!!!! // 1. bullet marker spot // 2. cross marker spot @@ -350,21 +338,19 @@ void MarkerCasern::organize(const cv::Mat &img, bool autoWB) if (!colSet) { colSet = true; - mCol.setRgb(getValue(img,cx,cy).rgb());//getR(img, cx, cy), getG(img, cx, cy), getB(img, cx, cy)); + mCol.setRgb(getValue(img,cx,cy).rgb()); mColorIndex = i; } else { - colOther.setRgb(getValue(img,cx,cy).rgb());//getR(img, cx, cy), getG(img, cx, cy), getB(img, cx, cy)); + colOther.setRgb(getValue(img,cx,cy).rgb()); mOtherIndex = i; } // bildrand muss nicht ueberprueft werden, da sie gar nicht erst hereingekommen waeren for (j = -1; j < 2; ++j) // 3x3 feld wird ueberprueft for (k = -1; k < 2; ++k) { -//j=0, k=0; - col.setRgb(getValue(img,cx+j,cy+k).rgb());//getR(img, cx+j, cy+k), getG(img, cx+j, cy+k), getB(img, cx+j, cy+k)); -//debout << mCol << ", " << col << ", " << colOther <<endl; + col.setRgb(getValue(img,cx+j,cy+k).rgb()); // faktor, um die mitte hoeher zu gewichten, da bei fd der schwarze rand mit dem weiss gemischt oft hell ist if (col.value()/(1. + .5*(abs(j)+abs(k))) > mCol.value()) // wenn Helligkeit maximal { @@ -384,33 +370,23 @@ void MarkerCasern::organize(const cv::Mat &img, bool autoWB) // weissabgleich // 1. Dynamik der Helligkeit // 2. farbverschiebung entsprechend weisswertes -// int ocx = myRound(mSpots[mOtherIndex].x()); -// int ocy = myRound(mSpots[mOtherIndex].y()); // bildrand muss nicht ueberprueft werden, da sie gar nicht erst hereingekommen waeren -// // schwarzwert bestimmen -// QColor black(255,255,255); // dunkelster fleck -// for (j = -1; j < 2; ++j) // 3x3 feld um ocx,ocy wird ueberprueft -// for (k = -1; k < 2; ++k) -// { -// col.setRgb(getR(img, ocx+j, ocy+k), getG(img, ocx+j, ocy+k), getB(img, ocx+j, ocy+k)); -// if (col.value() < black.value()) // wenn Helligkeit geringer -// black = col; -// } + // weisswert und durchschnittlichen weisswert bestimmen // 2 bereiche neben farbmarker in weisser flaeche auf kopfpappe int wcx = myRound(mSpots[mColorIndex].x()+0.356*(mSpots[mColorIndex].y()-mSpots[mOtherIndex].y())); int wcy = myRound(mSpots[mColorIndex].y()+0.356*(mSpots[mColorIndex].x()-mSpots[mOtherIndex].x())); QColor white(0,0,0); // hellster fleck - //QColor avgWhite; // durchschnittlichen weisswert + int avgWhiteR=0, avgWhiteG=0, avgWhiteB=0; // durchschnittlichen weisswert for (j = -1; j < 2; ++j) // 3x3 feld um ocx,ocy wird ueberprueft for (k = -1; k < 2; ++k) { QColor color = getValue(img,wcx+j,wcy+k); - avgWhiteR+=color.red();//getR(img, wcx+j, wcy+k); - avgWhiteG+=color.green();//getG(img, wcx+j, wcy+k); - avgWhiteB+=color.blue();//getB(img, wcx+j, wcy+k); - col.setRgb(getValue(img,wcx+j,wcy+k).rgb());//getR(img, wcx+j, wcy+k), getG(img, wcx+j, wcy+k), getB(img, wcx+j, wcy+k)); + avgWhiteR+=color.red(); + avgWhiteG+=color.green(); + avgWhiteB+=color.blue(); + col.setRgb(getValue(img,wcx+j,wcy+k).rgb()); if (col.value() > white.value()) // wenn Helligkeit groesser white = col; } @@ -420,40 +396,16 @@ void MarkerCasern::organize(const cv::Mat &img, bool autoWB) for (k = -1; k < 2; ++k) { QColor color = getValue(img,wcx+j,wcy+k); - avgWhiteR+=color.red();//getR(img, wcx+j, wcy+k); - avgWhiteG+=color.green();//getG(img, wcx+j, wcy+k); - avgWhiteB+=color.blue();//getB(img, wcx+j, wcy+k); - col.setRgb(getValue(img,wcx+j,wcy+k).rgb());//getR(img, wcx+j, wcy+k), getG(img, wcx+j, wcy+k), getB(img, wcx+j, wcy+k)); + avgWhiteR+=color.red(); + avgWhiteG+=color.green(); + avgWhiteB+=color.blue(); + col.setRgb(getValue(img,wcx+j,wcy+k).rgb()); if (col.value() > white.value()) // wenn Helligkeit groesser white = col; } - //avgWhite.setRgb(); + avgWhiteR/=18; avgWhiteG/=18; avgWhiteB/=18; - - // debout << black <<endl; - // debout << white <<endl; - // debout << avgWhiteR << " " << avgWhiteG << " " << avgWhiteB <<endl; - // debout << mCol <<endl; - //debout << avgWhite <<endl; - - // Anpassung - // Value / Helligkeit anpassen - // schwarzton wird nicht beruecksichtigt, weil dadurch alles dunkler wurde, - // da verwischte aufnahmen den schwarzen pkt nicht sehr schwarz wiedergeben - // DOCH, BEI RGB und HSV kam es zu ueberschreitungen, was mit warnungen einherging: - // eine unwahrscheinliche uebersteuerung (zahlen > 255) wurde nicht abgefangen - // mCol.setHsv(mCol.hue(), mCol.saturation(), (int)((mCol.value()-black.value())*(255./(white.value()-black.value())))); //colOther.setHsv(colOther.hue(), colOther.saturation(), (int)((colOther.value()-black.value())*(255./(white.value()-black.value())))); - - //passiert nun im einen schritt -// // helligkeit hochsetzen, so dass weiss maximal hell -// mCol.setHsv(mCol.hue(), mCol.saturation(), MIN(MAX((int)(mCol.value()*(255./white.value())), 0),255)); -// colOther.setHsv(colOther.hue(), colOther.saturation(), MIN(MAX((int)(colOther.value()*(255./white.value())), 0),255)); - - //passiert nun im einen schritt und mit einem faktor statt einer summand -// // Farbton anpassen -// // uebersteuerung wird einfach gedeckelt und nicht angepasst!!! -// mCol.setRgb(MIN(MAX(mCol.red()+(avgWhiteB-avgWhiteR), 0),255), MIN(MAX(mCol.green()+(avgWhiteB-avgWhiteG), 0),255), mCol.blue()); -// colOther.setRgb(MIN(MAX(colOther.red()+(avgWhiteB-avgWhiteR), 0),255), MIN(MAX(colOther.green()+(avgWhiteB-avgWhiteG), 0),255), colOther.blue()); + if ((avgWhiteR !=0) && (avgWhiteG !=0) && (avgWhiteB !=0)) { mCol.setRgb((int) MIN(((255./avgWhiteR)*mCol.red()), 255.), (int) MIN(((255./avgWhiteG)*mCol.green()), 255.), (int) MIN(((255./avgWhiteB)*mCol.blue()), 255.)); @@ -464,53 +416,12 @@ void MarkerCasern::organize(const cv::Mat &img, bool autoWB) // eigentlich muesset saettigung ueber histogramm angepasst werden!! } - - // darauffolgende methode ist nach versuchen besser und sowieso schneller - // // wenn auf markern farbe nahezu identisch - // // weisst dies auf einen schwarzen marker hin, - // // dann wird der marker genommen, der die groesste Flaeche beansprucht - // if (abs(mCol.value()-colOther.value()) < 30) //&& abs(mCol.saturation()-colOther.saturation()) < 40 - // { - // int count[3] = {0, 0, 0}; - // int maxVal = (mCol.value()+colOther.value())/2 + 10; - // int maxCount = 0; - // int maxIdx = -1; - // for (i = 0; i < mSpots.size(); ++i) - // if (i != mCenterIndex) - // { - // cx = myRound(mSpots[i].x()); - // cy = myRound(mSpots[i].y()); - // // bildrand muss nicht ueberprueft werden, da sie gar nicht erst hereingekommen waeren - // for (j = -7; j < 8; ++j) // 15x15 feld wird ueberprueft - // for (k = -7; k < 8; ++k) - // { - // col.setRgb(getR(img, cx+j, cy+k), getG(img, cx+j, cy+k), getB(img, cx+j, cy+k)); - // if (col.value() < maxVal) - // count[i]++; - // } - // if (count[i] > maxCount) - // { - // maxCount = count[i]; - // maxIdx = i; - // } - // } - // mColorIndex = maxIdx; - // if (maxIdx != -1) - // debout << "Warning: Blackpoint at " << mSpots[maxIdx].x() << ", " << mSpots[maxIdx].y() << "!" << endl; - // } - + // wenn auf markern farbe nahezu identisch // weisst dies auf einen schwarzen marker hin, // dann wird der marker genommen, der den groessten radius hat if (abs(mCol.value()-colOther.value()) < 30) //&& abs(mCol.saturation()-colOther.saturation()) < 40 { -// if (mCenterIndex != -1) -// debout << myRound(mSpots[mCenterIndex].x())+1 << " " <<myRound(mSpots[mCenterIndex].y())+1<<endl; -// // debout << mColorIndex <<" " << mCenterIndex << " " << mSpots.size()<<endl; -// // debout << mCol.red() <<" "<< mCol.green() <<" "<< mCol.blue() <<endl; -// // debout << colOther.red() <<" "<< colOther.green() <<" "<< colOther.blue() <<endl; -// debout << mCol.hue() <<" "<< mCol.saturation() <<" "<< mCol.value() <<endl; -// debout << colOther.hue() <<" "<< colOther.saturation() <<" "<< colOther.value() <<endl; double maxRadius = 0, rad; int maxIdx = -1; for (i = 0; i < mSpots.size(); ++i) @@ -530,68 +441,7 @@ void MarkerCasern::organize(const cv::Mat &img, bool autoWB) // wird im verlaufe nicht mehr benoetigt: colOther = mCol; mCol = colOther; } -// if (mColorIndex != maxIdx) -// debout << "Warning: Method radius has other result than method blackpoint at point " << mSpots[maxIdx].x() << ", " << mSpots[maxIdx].y() << " and " << mSpots[mColorIndex].x() << ", " << mSpots[mColorIndex].y() << "!" << endl; } - -// // koennten so bei schlechter beleuchtung graue bereiche auf muetze eigentliche marker ueberlagern? -// // delete all without 4 with most counts and sort them -// int max[4] = {-1, -1, -1, -1}; // max[0] is biggest -// int maxIndex[4] = {-1, -1, -1, -1}; -// for (i = 0; i < mSpots.size(); ++i) -// { -// for (j = 0; j < 4; ++j) -// { -// if (mSpotCount[i] > max[j]) -// { -// for (k = j; k < 3; ++k) -// { -// max[k+1] = max[k]; -// maxIndex[k+1] = maxIndex[k]; -// } -// max[j] = mSpotCount[i]; -// maxIndex[j] = i; -// break; -// } -// } -// // == -// // if (mSpotCount[i] > max[0]) -// // { -// // max[3] = max[2]; max[2] = max[1]; max[1] = max[0]; -// // maxIndex[3] = maxIndex[2]; maxIndex[2] = maxIndex[1]; maxIndex[1] = maxIndex[0]; -// // max[0] = mSpotCount[i]; -// // maxIndex[0] = i; -// // } else if (mSpotCount[i] > max[1]) -// // { -// // max[3] = max[2]; max[2] = max[1]; -// // maxIndex[3] = maxIndex[2]; maxIndex[2] = maxIndex[1]; -// // max[1] = mSpotCount[i]; -// // maxIndex[1] = i; -// // } else if (mSpotCount[i] > max[2]) -// // { -// // max[3] = max[2]; -// // maxIndex[3] = maxIndex[2]; -// // max[2] = mSpotCount[i]; -// // maxIndex[2] = i; -// // } else if (mSpotCount[i] > max[3]) -// // { -// // max[3] = mSpotCount[i]; -// // maxIndex[3] = i; -// // } -// } -// for (j = 0, i = 0; i < 4 && maxIndex[i] > -1; ++i) -// { -// mSpots.append(mSpots[maxIndex[i]]); -// mSpotCount.append(max[i]); -// j++; // number of max -// } -// k = mSpots.size(); -// for (i = 0; i < k-j; ++i) -// { -// mSpots.removeFirst(); -// mSpotCount.removeFirst(); -// } -// // debout << max[0] << " " << max[1] << " " << max[2] << " " << max[3] << " " <<endl; } MyEllipse MarkerCasern::getCenterSpot() const @@ -634,15 +484,11 @@ void MarkerCasern::draw(cv::Mat &img) const // quadrangle if (hasQuadrangle()) { -// CvPoint pt[4], *rect = pt; std::vector<cv::Point> pt; -// int count = 4; for (i = 0; i < 4; ++i) pt.push_back(cv::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::LINE_AA,0); -// cvPolyLine(img, &rect, &count, 1, 1, CV_RGB(0,255,0), 1, CV_AA, 0); //3, CV_AA, 0 } } @@ -656,19 +502,11 @@ bool MarkerCasernList::mayAddEllipse(const cv::Mat &img, const MyEllipse& e, boo int cx = myRound(e.center().x()); int cy = myRound(e.center().y()); -// char *data = img->imageData; -// int iw = img->width; // maybe spot if (blackInside && // marker have to be black inside (e.r1()>SPOT_SIZE_MIN && e.r1()<SPOT_SIZE_MAX && e.r2()>SPOT_SIZE_MIN && e.r2()<SPOT_SIZE_MAX && e.ratio()<2.) && // ellipse size ((cx < img.cols-3) && (cx > 1) && (cy < img.rows-3) && (cy > 1))) // && // not near the image border -// folgende abfragen werden jetzt ueber blackInside abgefragt, was ueber die flaechenberechung erstellt wird -// ((*(data+cx+cy*iw) != -1) || // ellipse color must be somehow black inside (-1 == weiss, 0 == schwarz) -// (*(data+cx+1+cy*iw) != -1) || (*(data+cx-1+cy*iw) != -1) || -// (*(data+cx+(cy+1)*iw) != -1) || (*(data+cx+(cy-1)*iw) != -1))) -// // die suche nach schwarz fkt nicht immer: quadrat mit farbmarker koennte herausfallen -// // oder geschwungene kontur wie bumerang koennte in der mitte der ellipse schwarz sein, obwohl bumerang weiss { int s = -1; for (i = 0; i < size(); ++i) @@ -691,14 +529,6 @@ bool MarkerCasernList::mayAddEllipse(const cv::Mat &img, const MyEllipse& e, boo MarkerCasern m; m.addSpot(e); append(m); -// if (cx > 141 && cx < 147 && cy > 185 && cy < 191) -// { -// debout << "falsche ellipse!!"<<endl; -// cvNamedWindow("img", CV_WINDOW_AUTOSIZE ); // 0 wenn skalierbar sein soll -// cvShowImage("img", img); -// // // //cvWaitKey( 0 ); // zahl statt null, wenn nach bestimmter zeit weitergegangen werden soll -// } - } return true; // maybe head @@ -752,7 +582,6 @@ bool MarkerCasernList::mayAddQuadrangle(const Vec2F v[4]) //Vec2F p1, Vec2F p2, void MarkerCasernList::organize(const cv::Mat &img, bool autoWB) { int i, j, k, s; -// for (i = 0; i < size(); ++i) // delete marker without head and organize every marker for (i = 0; i < size(); ) diff --git a/src/markerHermes.cpp b/src/markerHermes.cpp index 580120ffd..1c15e1aee 100644 --- a/src/markerHermes.cpp +++ b/src/markerHermes.cpp @@ -21,11 +21,6 @@ //folgende zeile spaeter raus #include <opencv2/highgui.hpp> -// spaeter entfernen naechsten beiden zeilen -//#include "control.h" -//extern Control *cw; - -//mMainWindow->getHeadSize() waere besser zu nmutzen, aber window in dioeser Klasse nicht bekannt! // an Treppen koennen grosse unterschiede da sein!!!! #define HEAD_SIZE_MIN 7 #define HEAD_SIZE_MAX 30 @@ -144,9 +139,6 @@ void MarkerHermes::organize(const cv::Mat &img, bool /*autoWB*/) if (mSpots.size() == 0) return; -// for (i = 0; i < mSpots.size(); ++i) -// mSpots[i].draw(img, 0, 255, 0); - // durch mgl wachsen der spots muss ueberprueft werden, ob sich im nachhinnein Ueberlagerungen ergeben for (i = 0; i < mSpots.size(); ++i) for (j = i+1; j < mSpots.size(); ++j) @@ -163,15 +155,7 @@ void MarkerHermes::organize(const cv::Mat &img, bool /*autoWB*/) // spots loeschen, die selten erkannt wurden // mind 5 stehen lassen -// int count = 100, anz = 0; -// while (count > 4) -// { -// ++anz; -// count = 0; -// for (i = 0; i < mSpotCount.size(); ++i) -// if (mSpotCount[i] > anz) -// count++; -// } + // nur die spots mit am meisten treffern stehen lassen int maxCount = 0; for (i = 0; i < mSpotCount.size(); ++i) @@ -220,9 +204,6 @@ void MarkerHermes::organize(const cv::Mat &img, bool /*autoWB*/) } } -// for (i = 0; i < mSpots.size(); ++i) -// mSpots[i].draw(img, 255, 0, 0); - // ab hier nur noch 0 oder 1 spots!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // bei 0 muss keine farbe mehr bestimmt werden if (mSpots.size() == 1) @@ -248,13 +229,10 @@ void MarkerHermes::organize(const cv::Mat &img, bool /*autoWB*/) if (maxVal-minVal < MIN_CONTRAST) // war 150bei zu geringem Kontrast wird spot geloescht { deleteSpot(0); - //debout << cx << " " << cy<< " " <<maxVal-minVal<<endl; return; } mCenterIndex = 0; - //debout << "dunkelster Wert: " <<minVal<<endl; - //debout << "hellster Wert: " <<maxVal<<endl; } } @@ -298,8 +276,6 @@ bool MarkerHermesList::mayAddEllipse(const cv::Mat &img, const MyEllipse& e, boo int cx = myRound(e.center().x()); int cy = myRound(e.center().y()); -// char *data = img->imageData; -// int iw = img->width; // maybe spot if (blackInside && // marker have to be black inside @@ -327,14 +303,6 @@ bool MarkerHermesList::mayAddEllipse(const cv::Mat &img, const MyEllipse& e, boo MarkerHermes m; m.addSpot(e); append(m); -// if (cx > 141 && cx < 147 && cy > 185 && cy < 191) -// { -// debout << "falsche ellipse!!"<<endl; -// cvNamedWindow("img", CV_WINDOW_AUTOSIZE ); // 0 wenn skalierbar sein soll -// cvShowImage("img", img); -// // // //cvWaitKey( 0 ); // zahl statt null, wenn nach bestimmter zeit weitergegangen werden soll -// } - } return true; // maybe head @@ -373,7 +341,6 @@ bool MarkerHermesList::mayAddEllipse(const cv::Mat &img, const MyEllipse& e, boo void MarkerHermesList::organize(const cv::Mat &img, bool autoWB) { int i, j, k, s; -// for (i = 0; i < size(); ++i) // delete marker without head and organize every marker for (i = 0; i < size(); ) diff --git a/src/markerJapan.cpp b/src/markerJapan.cpp index 98a7595b5..db483863e 100644 --- a/src/markerJapan.cpp +++ b/src/markerJapan.cpp @@ -21,11 +21,6 @@ //folgende zeile spaeter raus #include <opencv2/highgui.hpp> -//// radius fuer japan ellipsen -//#define HEAD_SIZE_MIN 8 -//#define HEAD_SIZE_MAX 20 -//#define SPOT_SIZE_MIN 1 -//#define SPOT_SIZE_MAX 5 #define SPOT_COLOR 0 // HUE==0, hier ROT // fuehrt zu folgendem range: 0-20 + 340-359 // Marker Size is a A4 copy of file (from takahiro from japan, nishinari group) @@ -113,14 +108,6 @@ void MarkerJapan::modifyHead(const MyEllipse &head, float headSize) mHasHead = true; mHead = head; } - -// debout << headSize << endl; -// debout << outlineMin << endl; -// debout << outlineMax << endl; -// debout "x: "<<mHead.center().x()<<endl; -// debout "y: "<<mHead.center().y()<<endl; -// debout "o: "<<mHead.outline()<<endl; - } void MarkerJapan::modifySpot(int i, const MyEllipse &spot) @@ -179,9 +166,6 @@ void MarkerJapan::organize(const cv::Mat &img, bool autoWB) if (mSpots.size() == 0) return; -// for (i = 0; i < mSpots.size(); ++i) -// mSpots[i].draw(img, 0, 255, 0); - // durch mgl wachsen der spots muss ueberprueft werden, ob sich im nachhinnein Ueberlagerungen ergeben for (i = 0; i < mSpots.size(); ++i) for (j = i+1; j < mSpots.size(); ++j) @@ -227,28 +211,24 @@ void MarkerJapan::organize(const cv::Mat &img, bool autoWB) cx = myRound(mSpots[i].x()); cy = myRound(mSpots[i].y()); r = 1; // fuehrte dazu, das zuweit gesucht wird und inangrenzenden marker hineingesuct wurde: myRound((mSpots[i].r1()+mSpots[i].r2())/2.); // mittlerer radius -// debout << cx+1 << " " << cy+1 << ": "; int minVal = 256; // groesser als komplett weiss (255) // bildrand muss nicht ueberprueft werden, da sie gar nicht erst hereingekommen waeren for (j = -r; j < r+1; ++j) for (k = -r; k < r+1; ++k) { - col.setRgb(getValue(img,cx+j,cy+k).rgb());//getRGB(img,cx+j,cy+k));//getR(img, cx+j, cy+k), getG(img, cx+j, cy+k), getB(img, cx+j, cy+k)); + col.setRgb(getValue(img,cx+j,cy+k).rgb()); if (col.value() < minVal) minVal = col.value(); // Helligkeit } minValList.append(minVal); -// cout << minVal << endl; } // loeschen aller zu hellen spots QList<int> minValListSort = minValList; std::sort(minValListSort.begin(), minValListSort.end()); // sortiert aufsteigend for (i = 0; i < mSpots.size(); ++i) { -//debout << mSpots[i].center().x()<< " "<< minValList[i] <<endl; if (minValList[i] > minValListSort[numberRemaining-1]) { -//debout << i << " groesser als " << minValListSort[numberRemaining-1]<< endl; deleteSpot(i); minValList.removeAt(i); --i; @@ -256,9 +236,6 @@ void MarkerJapan::organize(const cv::Mat &img, bool autoWB) } } -// for (i = 0; i < mSpots.size(); ++i) -// mSpots[i].draw(img, 255, 0, 0); - // bei 0 muss keine farbe mehr bestimmt werden if (mSpots.size() < 2) return; @@ -274,21 +251,19 @@ void MarkerJapan::organize(const cv::Mat &img, bool autoWB) if (!colSet) { colSet = true; - mCol.setRgb(getValue(img,cx,cy).rgb());//getRGB(img,cx,cy));//getR(img, cx, cy), getG(img, cx, cy), getB(img, cx, cy)); + mCol.setRgb(getValue(img,cx,cy).rgb()); mColorIndex = i; } else { - colOther.setRgb(getValue(img,cx,cy).rgb());//getRGB(img,cx,cy));//getR(img, cx, cy), getG(img, cx, cy), getB(img, cx, cy)); + colOther.setRgb(getValue(img,cx,cy).rgb()); mOtherIndex = i; } // bildrand muss nicht ueberprueft werden, da sie gar nicht erst hereingekommen waeren for (j = -1; j < 2; ++j) // 3x3 feld wird ueberprueft for (k = -1; k < 2; ++k) { -//j=0, k=0; - col.setRgb(getValue(img,cx+j,cy+k).rgb());//getRGB(img,cx+j,cy+k));//getR(img, cx+j, cy+k), getG(img, cx+j, cy+k), getB(img, cx+j, cy+k)); -//debout << mCol << ", " << col << ", " << colOther <<endl; + col.setRgb(getValue(img,cx+j,cy+k).rgb()); // faktor, um die mitte hoeher zu gewichten, da bei fd der schwarze rand mit dem weiss gemischt oft hell ist if (col.value()/(1. + .5*(abs(j)+abs(k))) > mCol.value()) // wenn Helligkeit maximal { @@ -323,9 +298,6 @@ void MarkerJapan::organize(const cv::Mat &img, bool autoWB) deleteSpot(1); } - // mColorIndex, mOtherIndex are correct // mCenterIndex == -1 !!! - //debout << mColorIndex << " " << mOtherIndex << " " << mCenterIndex <<endl; - if (autoWB) { // weissabgleich @@ -337,16 +309,15 @@ void MarkerJapan::organize(const cv::Mat &img, bool autoWB) int wcx = myRound(mSpots[mColorIndex].x()+0.356*(mSpots[mColorIndex].y()-mSpots[mOtherIndex].y())); int wcy = myRound(mSpots[mColorIndex].y()+0.356*(mSpots[mColorIndex].x()-mSpots[mOtherIndex].x())); QColor white(0,0,0); // hellster fleck - //QColor avgWhite; // durchschnittlichen weisswert int avgWhiteR=0, avgWhiteG=0, avgWhiteB=0; // durchschnittlichen weisswert for (j = -1; j < 2; ++j) // 3x3 feld um ocx,ocy wird ueberprueft for (k = -1; k < 2; ++k) { QColor color = getValue(img,wcx+j,wcy+k); - avgWhiteR+=color.red();//getR(img, wcx+j, wcy+k); - avgWhiteG+=color.green();//getG(img, wcx+j, wcy+k); - avgWhiteB+=color.blue();//getB(img, wcx+j, wcy+k); - col.setRgb(getValue(img,wcx+j,wcy+k).rgb());//getR(img, wcx+j, wcy+k), getG(img, wcx+j, wcy+k), getB(img, wcx+j, wcy+k)); + avgWhiteR+=color.red(); + avgWhiteG+=color.green(); + avgWhiteB+=color.blue(); + col.setRgb(getValue(img,wcx+j,wcy+k).rgb()); if (col.value() > white.value()) // wenn Helligkeit groesser white = col; } @@ -356,14 +327,14 @@ void MarkerJapan::organize(const cv::Mat &img, bool autoWB) for (k = -1; k < 2; ++k) { QColor color = getValue(img,wcx+j,wcy+k); - avgWhiteR+=color.red();//getR(img, wcx+j, wcy+k); - avgWhiteG+=color.green();//getG(img, wcx+j, wcy+k); - avgWhiteB+=color.blue();//getB(img, wcx+j, wcy+k); - col.setRgb(getValue(img,wcx+j,wcy+k).rgb());//getR(img, wcx+j, wcy+k), getG(img, wcx+j, wcy+k), getB(img, wcx+j, wcy+k)); + avgWhiteR+=color.red(); + avgWhiteG+=color.green(); + avgWhiteB+=color.blue(); + col.setRgb(getValue(img,wcx+j,wcy+k).rgb()); if (col.value() > white.value()) // wenn Helligkeit groesser white = col; } - //avgWhite.setRgb(); + avgWhiteR/=18; avgWhiteG/=18; avgWhiteB/=18; if ((avgWhiteR !=0) && (avgWhiteG !=0) && (avgWhiteB !=0)) @@ -435,15 +406,11 @@ void MarkerJapan::draw(cv::Mat &img) const // quadrangle if (hasQuadrangle()) { -// CvPoint pt[4], *rect = pt; std::vector<cv::Point> pt; -// int count = 4; for (i = 0; i < 4; ++i) pt.push_back(cv::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::LINE_AA,0); -// cvPolyLine(img, &rect, &count, 1, 1, CV_RGB(0,255,0), 1, CV_AA, 0); //3, CV_AA, 0 } } @@ -465,7 +432,6 @@ bool MarkerJapanList::mayAddEllipse(const cv::Mat &img, const MyEllipse& e, bool float SPOT_SIZE_MAX = mHeadSize/4.; int iHead = -1; - //debout << mHeadSize << endl; // == 19.1259 // maybe spot if (blackInside && // marker have to be black inside (e.r1()>SPOT_SIZE_MIN && e.r1()<SPOT_SIZE_MAX && e.r2()>SPOT_SIZE_MIN && e.r2()<SPOT_SIZE_MAX && e.ratio()<2.) && // ellipse size @@ -556,7 +522,6 @@ bool MarkerJapanList::mayAddQuadrangle(const Vec2F v[4]) //Vec2F p1, Vec2F p2, V void MarkerJapanList::organize(const cv::Mat &img, bool autoWB) { int i, j, k, s; -// for (i = 0; i < size(); ++i) // delete marker without head and organize every marker for (i = 0; i < size(); ) @@ -620,12 +585,10 @@ void MarkerJapanList::toCrossList(QList<TrackPoint> *crossList, bool ignoreWitho { if (at(i).hasHead()) { - //debout << at(i).head().outline()<<endl; if (at(i).spots().size() == 0) { if (!ignoreWithoutMarker) { - //v1 = at(i).head().center(); v1 = at(i).getCenter(); crossList->append(TrackPoint(v1, 0)); // 0 schlechteste qualitaet } diff --git a/src/multiColorMarkerItem.cpp b/src/multiColorMarkerItem.cpp index 0d03ceae9..d2dda2bf3 100644 --- a/src/multiColorMarkerItem.cpp +++ b/src/multiColorMarkerItem.cpp @@ -36,12 +36,6 @@ MultiColorMarkerItem::MultiColorMarkerItem(QWidget *wParent, QGraphicsItem * par { mMainWindow = (class Petrack*) wParent; mImage = nullptr; -// mMask = NULL; - //setAcceptsHoverEvents(true); - - // setEnabled(false); // all mouse events connot access this item, but it will be seen - // einzig move koennte interessant sein, um grid zu verschieben?! -// setAcceptsHoverEvents(true); } /** @@ -56,20 +50,8 @@ QRectF MultiColorMarkerItem::boundingRect() const { if (mMainWindow->getImage()) return QRectF(-mMainWindow->getImageBorderSize(), -mMainWindow->getImageBorderSize(), mMainWindow->getImage()->width(), mMainWindow->getImage()->height()); -// return QRectF(-mMainWindow->getImageBorderSize(), -mMainWindow->getImageBorderSize(), mImage->width(), mImage->height()); else return QRectF(0, 0, 0, 0); -// // bounding box wird in lokalen koordinaten angegeben!!! (+-10 wegen zahl "1") -// if (mControlWidget->getCalibCoordShow()) -// return QRectF(-110., -110., 220., 220.); -// else ; - -// return QRectF(0., 0., 0., 0.); - -// // sicher ware diese boundingbox, da alles -// // return QRectF(xMin, yMin, xMax-xMin, yMax-yMin); -// // eigentlich muesste folgende Zeile reichen, aber beim ranzoomen verschwindet dann koord.sys. -// // return QRectF(mControlWidget->getCalibCoordTransX()/10.-scale, mControlWidget->getCalibCoordTransY()/10.-scale, 2*scale, 2*scale); } void MultiColorMarkerItem::setRect(Vec2F& v) @@ -101,16 +83,15 @@ void MultiColorMarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsIt auto* p = mImage->scanLine(y)-1; for (x = 0; x < mMask.cols; x++) { - *(++p) = *data; // color.blue(); - *(++p) = *data; // color.green(); - *(++p) = *data; // color.red(); - *(++p) = *data ? notMaskMask : 255; // color.alpha(); // 255; + *(++p) = *data; + *(++p) = *data; + *(++p) = *data; + *(++p) = *data ? notMaskMask : 255; ++data; } data = (yData += mMask.cols/sizeof(char)); // because sometimes widthStep != width } painter->setOpacity(mMainWindow->getMultiColorMarkerWidget()->opacity->value()/100.); - //painter->drawImage(mMainWindow->getRecoRoiItem()->rect().x(),mMainWindow->getRecoRoiItem()->rect().y(), *mImage); // during hoverMoveEvent of recognitionRect the painting moves with rect painter->drawImage(mUlc.x(),mUlc.y(), *mImage); } @@ -128,8 +109,6 @@ cv::Mat MultiColorMarkerItem::createMask(int w, int h) if (w>0 && h>0 && (mMask.empty() || (!mMask.empty() && (w != mMask.cols || h != mMask.rows)))) { mMask.create(h,w,CV_8UC1); -// cvReleaseImage(&mMask); -// mMask = cvCreateImage(cvSize(w, h), 8, 1); } return mMask; } diff --git a/src/person.cpp b/src/person.cpp index 0934a5cde..49d0a5337 100644 --- a/src/person.cpp +++ b/src/person.cpp @@ -27,8 +27,6 @@ //#define SAVE_IMG_DETECTION_STEPS // setzen, wenn die gezeigten Bilder (SHOWELLIPSES) auch als Bildsequenz weggeschrieben werden soll //#define SAVE_IMG_FILEBASE "D:/diss/personModel/ownPerson/petrack/density/d4.5_" -//#define TIME_MEASUREMENT - using namespace::cv; PersonList::PersonList() diff --git a/src/petrack.cpp b/src/petrack.cpp index 7d859c0aa..360ce6084 100644 --- a/src/petrack.cpp +++ b/src/petrack.cpp @@ -66,8 +66,6 @@ #include <opencv2/opencv.hpp> -// Zeitausgabe aktivieren -//#define TIME_MEASUREMENT //temp muss spaeter herausgenommen werden, // dient dazu, in anderen dateien um schnell ueber cw->temp1->value() an einstellbare daten zu kommen @@ -80,10 +78,8 @@ Petrack::Petrack() { QIcon icon; icon.addFile(":/icon"); // about - // icon.addFile(":/icon_small"); - // icon.addFile(":/icon_smaller"); icon.addFile(":/icon_smallest"); // window title bar - setWindowIcon(icon); // QIcon(":/icon")fuer about und icon in windows titel bar top left + setWindowIcon(icon); mHeadSize = -1; mCmPerPixel = -1; mScene = nullptr; @@ -97,32 +93,19 @@ Petrack::Petrack() mTrackChanged = true; mCoordItem = nullptr; mImage = nullptr; -// mIplImg = NULL; -// mIplImgFiltered = NULL; setLoading(true); - // mPrevIplImgFiltered = NULL; - // mPrevFrame = -1; setAcceptDrops(true); -// grabKeyboard(); // nimmt alle Keyboard Eingaben entgegen, eintragen in Text-Felder dann nicht mehr moeglich -// grabMouse(); // nimmt alle MouseEvents eintgegen, Doppelklick etc. dann nicht mehr moeglich - int space = 2; - // setAccessibleName("PeTrack"); mBrightContrastFilter.disable(); - // mContrastFilter.disable(); - // mBrightFilter.disable(); mBorderFilter.disable(); mSwapFilter.disable(); mBackgroundFilter.disable(); mStereoContext = nullptr; mCalibFilter = new CalibFilter; // schoener waere erst zu erzeugen, wenn video geladen wird, da sonst bei stereo erst normealer und dann stereo objekt erzeugt wird mCalibFilter->disable(); // aber control widget greift schon bei erzeugung auf alle objekte zur einstellung zurueck - //mCalibFilter.disable(); //enable(); - - //mImageBorderSize=0; mControlWidget = new Control(this); cw = mControlWidget; // muss spaeter geloescht werden @@ -130,7 +113,6 @@ Petrack::Petrack() mStereoWidget = new StereoWidget(this); mStereoWidget->setWindowFlags(Qt::Window); mStereoWidget->setWindowTitle("Stereo parameter"); - //mStereoWidget->show(); mColorRangeWidget = new ColorRangeWidget(this); mColorRangeWidget->setWindowFlags(Qt::Window); @@ -139,53 +121,27 @@ Petrack::Petrack() mColorMarkerWidget = new ColorMarkerWidget(this); mColorMarkerWidget->setWindowFlags(Qt::Window); mColorMarkerWidget->setWindowTitle("Color marker parameter"); - //mColorMarkerWidget->show(); mCodeMarkerWidget = new CodeMarkerWidget(this); mCodeMarkerWidget->setWindowFlags(Qt::Window); mCodeMarkerWidget->setWindowTitle("Code marker parameter"); - //mCodeMarkerWidget->show(); mMultiColorMarkerWidget = new MultiColorMarkerWidget(this); mMultiColorMarkerWidget->setWindowFlags(Qt::Window); mMultiColorMarkerWidget->setWindowTitle("MultiColor marker parameter"); - //mColorMarkerWidget->show(); mScene = new QGraphicsScene(this); mImageItem = new ImageItem(this); // durch uebergabe von scene wird indirekt ein scene->addItem() aufgerufen mControlWidget->setScene(mScene); - // wird in controll.cpp behandelt!!! - // if (mControlWidget->filterBright->checkState() == Qt::Checked) - // mBrightFilter.enable(); - // else //Qt::Unchecked - // mBrightFilter.disable(); - // if (mControlWidget->filterContrast->checkState() == Qt::Checked) - // mContrastFilter.enable(); - // else //Qt::Unchecked - // mContrastFilter.disable(); - // if (mControlWidget->filterContrast->checkState() == Qt::Checked) - // mContrastFilter.enable(); - // else //Qt::Unchecked - // mContrastFilter.disable(); - mAnimation = new Animation(this); - // mImage = new QImage; // wird erst bei neuer sequenz erstellt, da dort groesse bekannt, - // zudem kann so ueber mImage==NULL beginn abgefragt werden - // // hier koennte ein Einfuehrungsbild mit logo etc eingeblendet werden - // mImage->load(":/logo"); - // //C:/Dokumente und Einstellungen/Maik Boltes/Eigene Dateien/diss/logo/logo.png - // mImageItem->setLogo(mImage); - // // so wurde gruene recogniton area zurueckgesetzt: - // //mImageItem->setImage(mImage); mLogoItem = new LogoItem(this); // durch uebergabe von scene wird indirekt ein scene->addItem() aufgerufen mLogoItem->setZValue(6); // groesser heisst weiter oben mExtrCalibration.setMainWindow(this); - //mExtCalibration = new ExtrCalibration(this); // muss vor CoordItem (und GridItem) stehen damit man auf useExtCalib abfragen kann mGridItem = new GridItem(this); mGridItem->setZValue(2.5); // durch uebergabe von scene wird indirekt ein scene->addItem() aufgerufen @@ -203,7 +159,6 @@ Petrack::Petrack() mViewWidget = new ViewWidget(this); mView = mViewWidget->view(); - //mScene->setSceneRect(0, 0, 0, 0); mView->setScene(mScene); connect(mView, SIGNAL(mouseDoubleClick()), this, SLOT(openSequence())); connect(mView, SIGNAL(mouseShiftDoubleClick(QPointF)), this, SLOT(addManualTrackPointOnlyVisible(QPointF))); //const QPoint &pos funktionierte nicht @@ -212,7 +167,6 @@ Petrack::Petrack() connect(mView, SIGNAL(mouseRightDoubleClick(QPointF, int)), this, SLOT(deleteTrackPoint(QPointF, int))); //const QPoint &pos funktionierte nicht connect(mView, SIGNAL(mouseMiddleDoubleClick(int)), this, SLOT(deleteTrackPointAll(int))); //const QPoint &pos funktionierte nicht connect(mView, SIGNAL(mouseShiftWheel(int)), this, SLOT(skipToFrameWheel(int))); - //connect(mView, SIGNAL(mouseRightClick(QPointF)), this, SLOT(showContextMenu(QPointF))); mPlayerWidget = new Player(mAnimation, this); @@ -305,20 +259,14 @@ Petrack::Petrack() createActions(); createMenus(); - //createToolBars(); createStatusBar(); mSeqFileName = QDir::currentPath(); //fuer allerersten Aufruf des Programms readSettings(); saveXml(mDefaultSettings); //noch nicht noetig, da eh noch nicht fkt -// mDefaultSettings = QString(QDir::tempPath() + "/default.pet"); -// saveProject(mDefaultSettings); // save default settings for later restore - - //#include <time.h> mShowFPS = 0; - // mLastTime = -1; mTrcFileName = ""; @@ -331,8 +279,6 @@ Petrack::Petrack() mAutoBackTrack = true; // ist der default, dann wenn in XML-Datei nicht drin steht mAutoTrackOptimizeColor = false; // ist der default, dann wenn in XML-Datei nicht drin steht -// resetUI(); - setLoading(false); } Petrack::~Petrack() @@ -371,24 +317,10 @@ void Petrack::dropEvent(QDropEvent *event) } } -//void Petrack::contextMenuEvent(QContextMenuEvent *event){ -// QMenu menu(this); -// menu.addAction(mDelPastAct); -// menu.addAction(mDelFutureAct); -// menu.addAction(mDelAllRoiAct); -// menu.exec(event->globalPos()); -//} - void Petrack::updateSceneRect() { double iW=0, iH=0, bS=0; - // // must be set explicitly, because the bounding box of the whole scene raises automatically but not gets smaller - // cout << "Image: "<< boundingRect().x() << " " << boundingRect().width() <<endl; - // cout << "Image: "<< sceneBoundingRect().x() << " " << sceneBoundingRect().width() <<endl; - // cout << "Image: "<< mScene->itemsBoundingRect().x() << " " << mScene->itemsBoundingRect().width() <<endl; - // mScene->setSceneRect(mScene->itemsBoundingRect()); // klappte nicht so gut, warum? - if (mImage) { iW = mImage->width(); @@ -442,9 +374,6 @@ void Petrack::openXml(QDomDocument &doc, bool openSeq) QString tmpSeq = getExistingFile(seq, mProFileName); if (tmpSeq != "") seq = tmpSeq; -// if (openSeq && (seq != "")) -// openSequence(seq); // wenn leer, dann kommt abfrage hoch, welche datei; abbrechen, wenn aktuelle gewuenscht - } if (elem.hasAttribute("STATUS_HEIGHT")) { @@ -489,7 +418,6 @@ void Petrack::openXml(QDomDocument &doc, bool openSeq) } if (elem.hasAttribute("FPS")) { - //mAnimation->setFPS(elem.attribute("FPS").toDouble()); fps = elem.attribute("FPS").toDouble(); } if (elem.hasAttribute("SOURCE_FRAME_IN")) @@ -524,9 +452,6 @@ void Petrack::openXml(QDomDocument &doc, bool openSeq) QString matStr = elem.attribute("TRANSFORMATION"); QTextStream in(&matStr); in >> zoom >> rotate >> hScroll >> vScroll; - //elem.attribute("TRANSFORMATION").sscanf("%f %f %f %f %f %f", &m11, &m12, &m21, &m22, &dx, &dy); - //mView->setMatrix(QMatrix(m11, m12, m21, m22, dx, dy)); - //mView->centerOn(m21, m22); } if (elem.hasAttribute("CAMERA")) { @@ -592,7 +517,6 @@ void Petrack::openXml(QDomDocument &doc, bool openSeq) { mTracker->clear(); mTracker->reset(); - //mTracker->init(); } importTracker(mTrcFileName); } @@ -619,9 +543,6 @@ void Petrack::openProject(QString fileName, bool openSeq) // default fileName="" if (fileName.isEmpty()) fileName = QFileDialog::getOpenFileName(this, tr("Select project file"), QFileInfo(mProFileName).path(), tr("PeTrack project file (*.pet);;All files (*.*)")); - // folgende zeilen nicht noetig, da dies nicht in pet-datei steht! - // else - // fileName = getExistingFile(fileName); // ueberprueft die ;-getrennten Dateinamen auf existenz und gibt ersten zurueck - interessant fuer relativen und absoluten pfad if (!fileName.isEmpty()) { @@ -640,7 +561,6 @@ void Petrack::openProject(QString fileName, bool openSeq) // default fileName="" return; } -// resetUI(); debout << "open " << fileName << std::endl; file.close(); mProFileName = fileName; @@ -651,8 +571,6 @@ void Petrack::openProject(QString fileName, bool openSeq) // default fileName="" if (root.attribute("VERSION") != mPetrackVersion) { PWarning(this, tr("PeTrack"), tr("Reading %1:\nDifferent version numbers %2 (application) and %3 (file) may cause problems.").arg(fileName, mPetrackVersion, root.attribute("VERSION"))); - //tr("Cannot read content from %1\nbecause of different version numbers\n%2 (application) and %3 (file).").arg(fileName).arg(VERSION).arg(root.attribute("VERSION"))); - //return; } } openXml(doc, openSeq); @@ -723,10 +641,6 @@ void Petrack::saveXml(QDomDocument &doc) elem.setAttribute("ANTIALIAS", mAntialiasAct->isChecked()); elem.setAttribute("OPENGL", mOpenGLAct->isChecked()); elem.setAttribute("SAVE_TRANSFORMED", mCropZoomViewAct->isChecked()); - // QMatrix mat = mView->matrix(); - // QPointF center = (mView->sceneRect()).center(); - // 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()); @@ -755,7 +669,6 @@ bool Petrack::saveProject(QString fileName) // default fileName="" // if no destination file or folder is given if (fileName.isEmpty() || QFileInfo(mProFileName).isDir()) { - //QFileInfo(mProFileName).path() fileName = QFileDialog::getSaveFileName(this, tr("Select project file"), mProFileName, tr("PeTrack project file (*.pet);;All files (*.*)")); } @@ -868,9 +781,6 @@ void Petrack::openSequence(QString fileName) // default fileName = "" if (fileName.isEmpty()) fileName = QFileDialog::getOpenFileName(this, tr("Open video or image sequence"), QFileInfo(mSeqFileName).path(), tr("All supported types (*.avi *.mpg *.mts *.m2t *.m2ts *.wmv *.mp4 *.mov *.mxf *.bmp *.dib *.jpeg *.jpg *.jpe *.png *.pbm *.pgm *.ppm *.sr *.ras *.tiff *.tif *.exr *.jp2);;Video (*.avi *.mpg *.mts *.m2ts *.m2t *.wmv *.mov *.mp4 *.mxf);;Images (*.bmp *.dib *.jpeg *.jpg *.jpe *.png *.pbm *.pgm *.ppm *.sr *.ras *.tiff *.tif *.exr *.jp2);;Windows bitmaps (*.bmp *.dib);;JPEG (*.jpeg *.jpg *.jpe);;Portable network graphics (*.png);;Portable image format (*.pbm *.pgm *.ppm);;Sun rasters (*.sr *.ras);;TIFF (*.tiff *.tif);;OpenEXR HDR (*.exr);;JPEG 2000 (*.jp2);;All files (*.*)")); - // in control - // else - // fileName = getExistingFile(fileName); // ueberprueft die ;-getrennten Dateinamen auf existenz und gibt ersten zurueck - interessant fuer relativen und absoluten pfad if (!fileName.isEmpty()) { if (!mAnimation->openAnimation(fileName)) @@ -879,7 +789,6 @@ void Petrack::openSequence(QString fileName) // default fileName = "" return; } - //updateSourceInOutFrames(); mCameraGroupView->setEnabled(mAnimation->isStereoVideo()); mCameraMenu->setEnabled(mAnimation->isStereoVideo()); @@ -937,11 +846,9 @@ void Petrack::updateWindowTitle() title += "; "; } if (mAnimation->isVideo()) - title += "sequence: " + mAnimation->getCurrentFileName() + tr(" (%1").arg(mAnimation->getNumFrames()) + tr(" frames; %1x%2").arg(size.width()).arg(size.height()) + " pixel)"; //size getFileBase()+".avi" - //title += "sequence: " + mAnimation->getCurrentFileName() + tr(" (%1").arg(mAnimation->getNumFrames()) + tr(" frames; %1").arg(mAnimation->getFPS()) + tr(" fps; %1x%2").arg(size.width()).arg(size.height()) + " pixel)"; //size getFileBase()+".avi" + title += "sequence: " + mAnimation->getCurrentFileName() + tr(" (%1").arg(mAnimation->getNumFrames()) + tr(" frames; %1x%2").arg(size.width()).arg(size.height()) + " pixel)"; else if (mAnimation->isImageSequence()) - title += "sequence: " + mAnimation->getCurrentFileName() + tr(" ... (%1").arg(mAnimation->getNumFrames()) + tr(" frames; %1x%2").arg(size.width()).arg(size.height()) + " pixel)"; //size getFileBase() - //title += "sequence: " + mAnimation->getCurrentFileName() + tr(" ... (%1").arg(mAnimation->getNumFrames()) + tr(" frames; %1").arg(mAnimation->getFPS()) + tr(" fps; %1x%2").arg(size.width()).arg(size.height()) + " pixel)"; //size getFileBase() + title += "sequence: " + mAnimation->getCurrentFileName() + tr(" ... (%1").arg(mAnimation->getNumFrames()) + tr(" frames; %1x%2").arg(size.width()).arg(size.height()) + " pixel)"; setWindowTitle(title); } @@ -1019,12 +926,11 @@ void Petrack::saveSequence(bool saveVideo, bool saveView, QString dest) // defau #else AviFileWriter aviFile; #endif - //CvVideoWriter* videoWriter; bool formatIsSaveAble = false; bool saveRet; - QImage *viewImage = nullptr; // =NULL, amit keine Warnung - QPainter *painter = nullptr; // =NULL, amit keine Warnung - int progEnd = /*mAnimation->getNumFrames()-1*/mAnimation->getSourceOutFrameNum()-mPlayerWidget->getPos(); // nur wenn nicht an anfang gesprungen wird:-mPlayerWidget->getPos() + QImage *viewImage = nullptr; + QPainter *painter = nullptr; + int progEnd = mAnimation->getSourceOutFrameNum()-mPlayerWidget->getPos(); // nur wenn nicht an anfang gesprungen wird:-mPlayerWidget->getPos() cv::Mat iplImgFilteredBGR; bool writeFrameRet = false; bool convert8To24bit = false; @@ -1033,43 +939,6 @@ void Petrack::saveSequence(bool saveVideo, bool saveView, QString dest) // defau if (saveVideo) { - // // - // // Retreive the number of compressors. - // // - // int iNumCompressors = aviFile.enumerateCompressors(mIplImgFiltered->height, mIplImgFiltered->width, 8*mIplImgFiltered->nChannels, NULL, 0); - // - // if(iNumCompressors) - // { - // ICINFO* picinfo = new ICINFO[iNumCompressors]; - // COMPVARS* comp = new COMPVARS[iNumCompressors]; - // char *c; - // - // // - // // Retreive information about these compressors. - // // - // aviFile.enumerateCompressors(mIplImgFiltered->height, mIplImgFiltered->width, 8*mIplImgFiltered->nChannels, picinfo, iNumCompressors); - // - // for (int i=0; i<iNumCompressors; i++) - // { - // c = (char*) &(picinfo[i].fccHandler); - // debout << c[0] << c[1] << c[2] << c[3] << " " << (char *) picinfo[i].szName << endl; - // comp[i].cbSize = picinfo[i].dwSize; - // //comp[i].lQ = 100.; //picinfo[i].; - // comp[i].dwFlags = picinfo[i].dwFlags; - // comp[i].fccHandler = picinfo[i].fccHandler; - // comp[i].fccType = picinfo[i].fccType; - // //comp[i].cbState = ; - // //comp[i].lpState = ; - // } - // - // // - // // Set the compressor to the first one found. - // // - // //aviFile.setCompressor(comp); - // - // delete [] picinfo; - // } - if (saveView) { if (mCropZoomViewAct->isChecked()) @@ -1078,37 +947,18 @@ void Petrack::saveSequence(bool saveVideo, bool saveView, QString dest) // defau viewImage = new QImage((int) mScene->width(), (int) mScene->height(), QImage::Format_RGB32); painter = new QPainter(); } - //CvSize size; - //size.width = mIplImgFiltered->width; - //size.height = mIplImgFiltered->height; if (convert8To24bit) mult = 3; else mult = 1; - //debout << "width: " << mIplImgFiltered->width << " height: " << mIplImgFiltered->height << endl; - //debout << "width: " << mView->viewport()->width() << " height: " << mView->viewport()->height() << endl; - //debout << "width: " << mScene->width() << " height: " << mScene->height() << endl; - //debout << "channels: " << mIplImgFiltered->nChannels << endl; -// debout << "viewImage: " << viewImage->depth() << endl; - bool ok = false; if( saveView ) ok = aviFile.open(dest.toStdString().c_str(), viewImage->width(), viewImage->height(), viewImage->depth(), mAnimation->getFPS()); else ok = aviFile.open(dest.toStdString().c_str(), mImg.cols, mImg.rows, mult*8*mImg.channels(), mAnimation->getFPS()); - ////vw = new cv::VideoWriter; - ////vw->open(dest.toStdString().c_str(), CV_FOURCC_DEFAULT, mAnimation->getFPS(), size); - //// -1 muss unter linux durch CV_FOURCC('P','I','M','1') ist mpeg1 oder CV_FOURCC('M','J','P','G') ersetzt werden oder CV_FOURCC_DEFAULT - //// CV_FOURCC('D','I','B',' ') == 0 bedeutet rgb unkomprimiert - siehe http://opencvlibrary.sourceforge.net/VideoCodecs - //if (autoSave) - // videoWriter = cvCreateVideoWriter(dest.toStdString().c_str(), CV_FOURCC_DEFAULT, mAnimation->getFPS(), size); //, int is_color=1 - //else - // videoWriter = cvCreateVideoWriter(dest.toStdString().c_str(), 0, mAnimation->getFPS(), size); //, int is_color=1 - //// if codec is not supported or no codec is selected - //if (!videoWriter) - // return; + if (!ok) { debout << "Error: opening AVI file: " << dest.toStdString().c_str() << std::endl; @@ -1116,8 +966,6 @@ void Petrack::saveSequence(bool saveVideo, bool saveView, QString dest) // defau } } - // mPlayerWidget->skipToFrame(0); // koennte man auch weglassen, dann wurde von aktueller pos film geschrieben!!! - if (!saveVideo) { if (saveView) @@ -1206,10 +1054,8 @@ void Petrack::saveSequence(bool saveVideo, bool saveView, QString dest) // defau mScene->render(painter); painter->end(); } -// debout << "nChannels: " << mIplImgFiltered->nChannels << endl; if ((mImgFiltered.channels() == 1) /* && convert8To24bit*/) { - //cvCvtColor(mIplImgFiltered, iplImgFilteredBGR, CV_GRAY2BGR); cv::cvtColor(mImg, iplImgFilteredBGR, cv::COLOR_GRAY2BGR); if( saveView ) writeFrameRet = aviFile.appendFrame((const unsigned char*) viewImage->bits(), true); // 2. param besagt, ob vertikal gespiegel werden soll @@ -1219,7 +1065,6 @@ void Petrack::saveSequence(bool saveVideo, bool saveView, QString dest) // defau else { if( saveView ){ -// debout << "." << endl; writeFrameRet = aviFile.appendFrame((const unsigned char*) viewImage->bits(), true); // 2. param besagt, ob vertikal gespiegel werden soll }else{ writeFrameRet = aviFile.appendFrame((const unsigned char*) mImg.data, true); // 2. param besagt, ob vertikal gespiegel werden soll @@ -1293,9 +1138,6 @@ void Petrack::saveSequence(bool saveVideo, bool saveView, QString dest) // defau if (saveVideo) { aviFile.close(); - //cvReleaseVideoWriter(&videoWriter); -// if (iplImgFilteredBGR) -// cvReleaseImage(&iplImgFilteredBGR); } mPlayerWidget->skipToFrame(memPos); @@ -1333,8 +1175,6 @@ void Petrack::saveView(QString dest) //default = "" { QPrinter printer(QPrinter::ScreenResolution); // HighResolution? printer.setColorMode(QPrinter::Color); - //printer.setPageSize(QPrinter::A4); - //printer.setOutputFormat(QPrinter::PdfFormat); //QPrinter::PostScriptFormat automatisch durch dateiendung printer.setOutputFileName(dest); QPainter painter(&printer); if (mCropZoomViewAct->isChecked()) @@ -1392,8 +1232,6 @@ void Petrack::saveImage(QString dest) //default = "" QPrinter printer(QPrinter::ScreenResolution); // HighResolution? printer.setColorMode(QPrinter::Color); - //printer.setPageSize(QPrinter::A4); - //printer.setOutputFormat(QPrinter::PdfFormat); //QPrinter::PostScriptFormat automatisch durch dateiendung printer.setOutputFileName(dest); QPainter painter(&printer); QRect rect = painter.viewport(); @@ -1422,24 +1260,9 @@ void Petrack::print() QPrinter printer(QPrinter::ScreenResolution); //ScreenResolution, HighResolution// liefert zu hause: QWin32PrintEngine::initialize: GetPrinter failed () printer.setPageSize(QPageSize{QPageSize::PageSizeId::A4}); QPrintDialog dialog(&printer, this); - //printer.setOutputFormat(QPrinter::PostScriptFormat); if (dialog.exec()) { QPainter painter(&printer); mView->render(&painter); - - // QRect rect = painter.viewport(); - // QSize size = imageWidget->pixmap()->size(); - // size.scale(rect.size(), Qt::KeepAspectRatio); - // painter.setViewport(rect.x(), rect.y(), size.width(), size.height()); - // painter.setWindow(imageWidget->pixmap()->rect()); - // painter.drawPixmap(0, 0, *imageWidget->pixmap()); - // // print the upper half of the viewport into the lower. - // // half of the page. - // QRect viewport = view.viewport()->rect(); - // view.render(&painter, - // QRectF(0, printer.height() / 2, - // printer.width(), printer.height() / 2), - // viewport.adjusted(0, 0, 0, -viewport.height() / 2)); } } else @@ -1450,7 +1273,6 @@ void Petrack::resetSettings() { mAnimation->reset(); openXml(mDefaultSettings); -// resetUI(); } void Petrack::about() @@ -1468,10 +1290,6 @@ void Petrack::about() //People/Pedestrian/Person tracking QMessageBox::about(this, tr("About PeTrack"), message); - //© © © (c) - // folgender befehl wird erst nach About-Fenster ausgefuehrt und ersetzt Icon im Hauptfenster - //QApplication::activeWindow()->setWindowIcon(QIcon(":/icon")); - // siehe auch Petrack::Petrack() } @@ -1480,39 +1298,7 @@ void Petrack::commandLineOptions() PMessageBox *mb = new PMessageBox{this, tr("Command line options"), commandLineOptionsString, QIcon()}; mb->setModal(false); mb->setAttribute(Qt::WA_DeleteOnClose); - - //"<style>spantab {padding-left: 4em; margin-left:5em}</style><span class=\"tab\"></span>" - //"<p>Only to convert a video <kbd>video.avi</kbd> with settings stored in a petrack project file <kbd>project.pet</kbd> to an image sequence to be stored in the directory <kbd>folder</kbd> call:<br>" - //"<code>petrack.exe -project project.pet </code><br>" - //" <code>-sequence video.avi </code><br>" - //" <code>-autoSave folder</code></p>" - //To generate trajectories from a single image sequence frame000.jpg to frame345.jpg - //with settings stored in project.pet, export tracker file tracker_file and exit - //with saving the project to project.pet again: - //petrack.exe -project project.pet -sequence frame000.jpg -autoTrack tracker_file -autoSave project.pet - //For more information (especially key bindings) see http://www.fz-juelich.de/jsc/petrack/. - //Normal usage is interactive usage. - - - mb->show(); - -//Usage: petrack [-help|-?] [[-project] project.pet] [-sequence image_sequence_or_video] [-autoSave|-autosave image_folder_or_video|project.pet|tracker_file] [-autoTrack|-autotrack tracker_file] [-autoPlay|-autoplay tracker_file] - -//Usage: -// ------ -// petrack [-help|-?] [[-project] project.pet] [-sequence image_sequence_or_video] [-autoSave|-autosave image_folder_or_video|project.pet|tracker_file] [-autoTrack|-autotrack tracker_file] [-autoPlay|-autoplay tracker_file] - -// -help|-? shows help information for command line options -// -project optional option to set project file to project.pet; otherwise the argument without option flag is used as project file -// -sequence loads image sequence or video image_sequence_or_video; option overwrites SRC attribute in project file -// -autoSave|-autosave if the argument ends with pet, a project file will be written to proj.pet at the end; -// if the argument ends with txt, dat or trav, the trajectories will be written in a format according to the suffix of tracker_file; -// otherwise image_folder_or_video is the folder to store the image sequence or a name of a video file for the direct export; -// in all cases PeTrack ends after finishing the work -// -autoTrack|-autotrack calculates automatically the trajectories of marked pedestrians and stores the result to tracker_file -// -autoPlay|-autoplay plays the video or image sequence and stores the trajectories to tracker_file - } void Petrack::keyBindings() @@ -1543,39 +1329,6 @@ void Petrack::keyBindings() mb->setAttribute(Qt::WA_DeleteOnClose); mb->setModal(false); -//"Beside the space bar all bindings only affect inside the image.<p>" -//"Space bar<br>" -//" toggles between pause and last play direction<br>" -//"Mouse scroll wheel<br>" -//" zooms in and out to or from the pixel of the image at the position of the mouse pointer<br>" -//"Shift + mouse scroll wheel<br>" -//" plays forwards or backwards<br>" -//"Holding left mouse button<br>" -//" moves image<br>" -//"Arrows<br>" -//" moves image<br>" -//"Double-click left mouse button<br>" -//" opens video or image sequence<br>" -//"Ctrl + double-click left mouse button<br>" -//" inserts new or moves near trackpoint<br>" -//"Ctrl + double-click right mouse button<br>" -//" deletes a trajectory of a near trackpoint<br>" -//"Shift + double-click right mouse button<br>" -//" deletes the past part of a trajectory of a near trackpoint<br>" -//"Alt + double-click right mouse button<br>" -//" deletes the future part of a trajectory of a near trackpoint<br>" -//"Ctrl + double-click middle mouse button<br>" -//" deletes all trajectories<br>" -//"Shift + double-click middle mouse button<br>" -//" deletes the past part of all trajectories<br>" -//"Alt + double-click middle mouse button<br>" -//" deletes the future part of all trajectories<br>" -//"Shift + t<br>" -//" toggles tracking online calculation<br>" -//"Shift + double-click left mouse button<br>" -//" inserts new or moves near trackpoint and enables showing only the modified trajectory<p>" -//"Further key bindings you will find next to the entries of the menus." - mb->show(); } @@ -1619,8 +1372,6 @@ void Petrack::setGlobalFont() // the user canceled the dialog; font is set to the initial // value, in this case Times, 12. } - //static QFont font("Courier", 10, QFont::Normal); //Times Helvetica, Normal Bold // QFont("Times", 12) - //this->setFont(font); } void Petrack::showHideControlWidget() @@ -1927,7 +1678,6 @@ void Petrack::createStatusBar() statusBar()->addPermanentWidget(mStatusPosRealHeight = new QDoubleSpinBox()); connect(mStatusPosRealHeight, SIGNAL(valueChanged(double)), this, SLOT(setStatusPosReal())); - //mStatusPosRealHeight->setEnabled(false); // temporaer, damit nichts eingetragen werden kann!!!!!! statusBar()->addPermanentWidget(mStatusLabelPosReal = new QLabel(" ")); statusBar()->addPermanentWidget(mStatusLabelPos = new QLabel(" ")); statusBar()->addPermanentWidget(mStatusLabelColor = new QLabel(" ")); @@ -1935,22 +1685,17 @@ void Petrack::createStatusBar() mStatusLabelStereo->setMinimumWidth(200); mStatusLabelTime->setFont(f); mStatusLabelTime->setMinimumWidth(200); - //mStatusLabelTime->setAlignment(Qt::AlignRight); ??? verschiebt text nach oben???!!! mStatusLabelFPS->setFont(f); mStatusLabelFPS->setMinimumWidth(80); mStatusLabelFPS->setAutoFillBackground(true); mStatusLabelFPS->setToolTip("Click to adapt play rate to fps rate"); - //mStatusLabelFPS->setFrameStyle(QFrame::VLine); mStatusPosRealHeight->setRange(-999.9, 9999.9); // in cm mStatusPosRealHeight->setDecimals(1); mStatusPosRealHeight->setFont(f); mStatusLabelPosReal->setFont(f); mStatusLabelPosReal->setMinimumWidth(340); - // mStatusLabelPosReal->setFrameStyle(QFrame::Sunken|QFrame::Panel); mStatusLabelPos->setFont(f); mStatusLabelPos->setMinimumWidth(100); - //mStatusLabelPos->setFrameStyle(QFrame::VLine|QFrame::Sunken); - // debout << mStatusLabelPos->frameWidth() <<endl; ???? warum 0, daher wird auch sunken, vline nicht richtig gesetzt!!!! mStatusLabelColor->setFont(f); mStatusLabelColor->setMinimumWidth(90); mStatusLabelColor->setAutoFillBackground(true); @@ -1965,7 +1710,7 @@ void Petrack::resetUI() /// Anderenfalls kommt es evtl. beim nacheinander laden verschiedener Projekte zu einem Programmabsturz /// return; - /// sequence , height + mSeqFileName = ""; mAnimation->free(); if( mImage ) @@ -2015,9 +1760,6 @@ void Petrack::resetUI() mControlWidget->r6->setValue(0); mControlWidget->tx->setValue(0); mControlWidget->ty->setValue(0); - //mControlWidget->k4->setValue(0); - //mControlWidget->k5->setValue(0); - //mControlWidget->k6->setValue(0); mControlWidget->quadAspectRatio->setCheckState(Qt::Unchecked); mControlWidget->fixCenter->setCheckState(Qt::Unchecked); mControlWidget->tangDist->setCheckState(Qt::Checked); @@ -2111,7 +1853,6 @@ void Petrack::resetUI() mControlWidget->mapH->setValue(0); mControlWidget->mapColor->setCheckState(Qt::Checked); mControlWidget->mapHeight->setValue(180); -// mControlWidget->colorPlot->replot(); mControlWidget->mapDefaultHeight->setValue(180); /// @@ -2197,9 +1938,6 @@ void Petrack::resetUI() mControlWidget->anaConsiderAbs->setCheckState(Qt::Unchecked); mControlWidget->anaConsiderRev->setCheckState(Qt::Unchecked); mControlWidget->showVoronoiCells->setCheckState(Qt::Unchecked); - -// updateImage(); - } void Petrack::setStatusStereo(float x, float y, float z) @@ -2226,21 +1964,19 @@ void Petrack::setStatusFPS() mStatusLabelFPS->setText(QString("%1fps ").arg(mShowFPS, 5, 'f', 1)); QPalette pal = mStatusLabelFPS->palette(); // static moeglich? - QColor color;//(qRed(col), qGreen(col), qBlue(col)); + QColor color; double diff = mShowFPS-mAnimation->getFPS(); int opacity = mPlayerWidget->getPlayerSpeedLimited() ? 128 : 20; if( diff < -6 ) // very slow ==> red - color.setRgb(200,0,0,opacity);//mStatusLabelFPS->setStyleSheet("background-color: rgba(200,0,0,20);");// border-style: outset; border-width: 1px; border-color: yellow;");//, qRgba(250,0,0,50));//Qt::yellow); + color.setRgb(200,0,0,opacity); else if( diff < -2 ) // better ==> yellow - color.setRgb(200,200,0,opacity);//mStatusLabelFPS->setStyleSheet("background-color: rgba(200,200,0,20);");// border-style: outset; border-width: 1px; border-color: yellow;");//, qRgba(250,0,0,50));//Qt::yellow); + color.setRgb(200,200,0,opacity); else if (diff > -2) // nearly ok ==> green - color.setRgb(0,200,0,opacity);//mStatusLabelFPS->setStyleSheet("background-color: rgba(0,200,0,20);");// border-style: outset; border-width: 1px; border-color: red;");//, qRgba(250,0,0,50));//Qt::yellow); + color.setRgb(0,200,0,opacity); pal.setColor(QPalette::Window, color); -// pal.setColor(QPalette::WindowText,mPlayerWidget->getPlayerSpeedFixed() ? QColor(100,100,100) : QColor(0,0,0)); - // pal.setBrush(QPalette::WindowText, mPlayerWidget->getPlayerSpeedFixed() ? QBrush(QColor(50,50,50),Qt::Dense2Pattern) : QBrush(QColor(0,0,0),Qt::SolidPattern)); mStatusLabelFPS->setPalette(pal); } @@ -2328,7 +2064,6 @@ void Petrack::setStatusColor(const QRgb &col) else mStatusLabelColor->setText(QString("<font color=\"#000000\"> %1</font>").arg(s)); - // mStatusLabelColor->setBackgroundRole(QPalette::Text); QPalette pal = mStatusLabelColor->palette(); // static moeglich? QColor color(qRed(col), qGreen(col), qBlue(col)); @@ -2338,7 +2073,6 @@ void Petrack::setStatusColor(const QRgb &col) mControlWidget->getColorPlot()->setCursor(color); mControlWidget->getColorPlot()->replot(); - //debout << "QColor: " << color << " height: " << mControlWidget->getColorPlot()->map(color) << endl; } void Petrack::setStatusColor() @@ -2453,7 +2187,6 @@ void Petrack::setMousePosOnImage(QPointF pos) if (mImage) { mMousePosOnImage = pos; - // real coordinate setStatusPosReal(mImageItem->getPosReal(pos, getStatusPosRealHeight())); // pixel coordinate @@ -2485,12 +2218,10 @@ void Petrack::keyPressEvent(QKeyEvent * event) mPlayerWidget->togglePlayPause(); break; case Qt::Key_D: -// debout << "test Key_D" << endl; break; default: ; } -// QMainWindow::keyPressEvent(event); } void Petrack::mousePressEvent(QMouseEvent *event) @@ -2555,9 +2286,6 @@ void Petrack::importTracker(QString dest) //default = "" dest = QFileDialog::getOpenFileName(this, tr("Select file for importing tracking pathes"), lastFile, tr("PeTrack tracker (*.trc *.txt);;All files (*.*)")); } - // in control - // else - // dest = getExistingFile(dest); // ueberprueft die ;-getrennten Dateinamen auf existenz und gibt ersten zurueck - interessant fuer relativen und absoluten pfad if (!dest.isEmpty()) { @@ -2617,18 +2345,7 @@ void Petrack::importTracker(QString dest) //default = "" in >> tp; }else if( trcVersion >= 3) { - -// in.skipWhiteSpace(); // skip white spaces for reading the comment line without this the reading makes some problems -// // Kommentarzeile lesen -// comment = in.readLine(); -// // Kommentarzeichen entfernen - wird beim exportieren wieder hinzugefuegt -// if( comment.startsWith("#")) -// { -// comment = comment.remove(0,2); -// } in >> tp; -// tp.setComment(comment); - } mTracker->append(tp); tp.clear(); // loeschen, sonst immer weitere pfade angehangen werden @@ -2660,8 +2377,6 @@ void Petrack::importTracker(QString dest) //default = "" setTrackChanged(true);// flag changes of track parameters mTracker->reset(); - //mTrackerReal->reset(); ??? - QTextStream in(&file); TrackPerson tp; TrackPoint tPoint; @@ -2696,9 +2411,6 @@ void Petrack::importTracker(QString dest) //default = "" continue; } - // Test-Ausgabe - //debout << line << endl; - if ((!exec_once_flag) && (!headerline.contains("cm"))) { conversionFactorTo_cm = 100.0; @@ -2735,7 +2447,6 @@ void Petrack::importTracker(QString dest) //default = "" tPoint = TrackPoint(Vec2F(p2d.x,p2d.y),100); tPoint.setSp(x,y,-mControlWidget->getCalibExtrTrans3()-z); // fuer den Abstand zur Kamera in z-Richtung wie bei einer Stereokamera - //tPoint.setSp(x,y,z); // Eigentlich bisher nur fuer Stereodaten verwendet // Neue ID ? ==> letzte Person beendet ==> abspeichern if( personNr > current_personNr ) @@ -2759,10 +2470,6 @@ void Petrack::importTracker(QString dest) //default = "" tp.setLastFrame(frameNr); tp.append(tPoint); } - - // Test-Ausgabe - //debout << "Person: " << personNr << " at Frame: " << frameNr << " at 2D-Position: (" << p2d.x << ", " << p2d.y << ") and 3D-Position: (" << x << ", " << y << ", " << z << ")" << endl; - } mControlWidget->trackNumberAll->setText(QString("%1").arg(mTracker->size())); @@ -2797,10 +2504,7 @@ void Petrack::testTracker() { mControlWidget->trackShowOnly->setCheckState(Qt::Checked); mControlWidget->trackShowOnlyNr->setValue(pers[idx]); -// mControlWidget->trackShowOnlyNr->setValue(pers[idx]); - mPlayerWidget->skipToFrame(frame[idx]); // QString().number(mAnimation->getCurrentFrameNum()) - //mControlWidget->trackGotoNr->click(); - + mPlayerWidget->skipToFrame(frame[idx]); ++idx; } @@ -2811,9 +2515,8 @@ int Petrack::calculateRealTracker() bool autoCorrectOnlyExport = (mControlWidget->getRecoMethod() == reco::RecognitionMethod::MultiColor) && // multicolor mMultiColorMarkerWidget->autoCorrect->isChecked() && mMultiColorMarkerWidget->autoCorrectOnlyExport->isChecked(); - //int anz = mTrackerReal->calculate(mTracker, mImageItem, mControlWidget->getColorPlot(), getImageBorderSize(), mControlWidget->anaMissingFrames->checkState()); int anz = mTrackerReal->calculate(mTracker, mImageItem, mControlWidget->getColorPlot(), getImageBorderSize(), - mControlWidget->anaMissingFrames->checkState(), //mControlWidget->trackMissingFrames->checkState(), + mControlWidget->anaMissingFrames->checkState(), mStereoWidget->stereoUseForExport->isChecked(), mControlWidget->trackAlternateHeight->checkState(), mControlWidget->coordAltitude->value(), mStereoWidget->stereoUseCalibrationCenter->isChecked(), mControlWidget->exportElimTp->isChecked(), mControlWidget->exportElimTrj->isChecked(), mControlWidget->exportSmooth->isChecked(), @@ -2824,191 +2527,6 @@ int Petrack::calculateRealTracker() return anz; } - -// Veraltet wird in extCalibration gemacht! -//void Petrack::load3DCalibPoints(QString src) // default = "" -//{ - -// bool all_ok = true; - -// vector<Point3f> list3D; -// vector<Point2f> list2D; - -// if( !src.isEmpty() ) -// { -// if( src.right(4) == ".3dc" ) -// { -// //mExtrCalibration->setExtrCalibFile(src); -// QFile file(src); -// if( !file.open(QIODevice::ReadOnly | QIODevice::Text) ) -// { -// QMessageBox::critical(this, tr("PeTrack"), tr("Error: Cannot open %1:\n%2.").arg(src).arg(file.errorString())); -// return; -// } - -// debout << "reading 3D calibration data from " << src << "..." << endl; - -// QTextStream in(&file); -// QString line; -// int lineCount = 0; -// QStringList values; - -// line = in.readLine(); -// lineCount++; -// int sz_3d = line.toInt(&all_ok); -// if( !all_ok ){ -// QMessageBox::critical(this, tr("PeTrack"), tr("Error: First line of 3D point file should only contain the number of listed 3D-Points.")); -// return; -// } - -// bool withImageData = false; -// double coords[5]; -// while( !in.atEnd() ) -// { -// line = in.readLine(); - -// lineCount++; -// // comment lines -// if( line.startsWith("#") || line.startsWith(";;") || line.startsWith("//") || line.startsWith("!") ) -// continue; - -// //QStream stream(line); - -// //stream >> x_3d >> y_3d << z_3d -// // >> x_2d << y_2d; - -// values = line.split(" "); -// //cout << line << " (" << values.size() << ")" << endl; -// if( lineCount == 2 && values.size() == 5 ) -// { -// withImageData = true; -// } -// if( values.size() == 3 || values.size() == 5 ) -// { -// //debout << values.at(0) << ", " << values.at(1) << ", " << values.at(2) << endl; -// for(int i=0; i<3; i++) -// { -// coords[i] = values.at(i).toDouble(&all_ok); -// if(!all_ok) -// { -// QMessageBox::critical(this, tr("PeTrack"), tr("Error: Reading Float-Value in line %1 column %2 crashed: %3 (File: %4)").arg(lineCount).arg(i).arg(values.at(i)).arg(src)); -// return; -// } -// } -// list3D.push_back( Point3f( coords[0], coords[1], coords[2] ) ); -// if (values.size() == 5) -// { -// if( !withImageData ){ -// QMessageBox::critical(this, tr("PeTrack"), tr("Error: Unsupported File Format in: %1 (Only 3D-Points or 3D-Points and 2D-Points, but no mix)").arg(src)); -// return; -// } -// for(int i=3; i<5; i++) -// { -// coords[i] = values.at(i).toDouble(&all_ok); -// if(!all_ok) -// { -// QMessageBox::critical(this, tr("PeTrack"), tr("Error: Reading Float-Value in line %1 column %2 crashed: %3 (File: %4)").arg(lineCount).arg(i).arg(values.at(i)).arg(src)); -// return; -// } -// } -// list2D.push_back( Point2f( coords[3], coords[4] ) ); - -// }else if( withImageData ) -// { -// QMessageBox::critical(this, tr("PeTrack"), tr("Error: Unsupported File Format in: %1 (Only 3D-Points or 3D-Points and 2D-Points, but no mix)").arg(src)); -// return; -// } -// }else -// { -// QMessageBox::critical(this, tr("PeTrack"), tr("Error: Unsupported File Format in: %1").arg(src)); -// return; -// } - - -// } -// file.close(); -// all_ok = true; -// int sz_2d = 0; -// if( !mTracker || mTracker->size() < 4 ) -// { -// if( !withImageData ) -// { -// QMessageBox::critical(this, tr("PeTrack"), tr("Error: At minimum four 3D calibration points needed for 3D calibration.")); -// } -// }else -// { -// sz_2d = mTracker->size(); -// list2D.clear(); - -// if( sz_2d != sz_3d ){ -// if( !withImageData ) -// { -// QMessageBox::critical(this, tr("PeTrack"), tr("Count of 2D-Points (%1) and 3D-Points (%2) disagree").arg(sz_2d).arg(sz_3d)); -// all_ok = false; -// } -// } -// //debout << "Marked 2D-Image-Points: " << endl; -// if( all_ok ) -// { -// for(int i = 0; i < sz_2d; i++) -// { -// //debout << "[" << i << "]: (" << mTracker->at(i).at(0).x() << ", " << mTracker->at(i).at(0).y() << ")" << endl; -// // Info: Tracker->TrackPerson->TrackPoint->Vec2F -// list2D.push_back(Point2f(mTracker->at(i).at(0).x(),mTracker->at(i).at(0).y())); -// } -// } -// } - - -// // mExtrCalibration->set3DList(list3D); -// // mExtrCalibration->set2DList(list2D); -// //debout << "3D.x " << "3D.y " << "3D.z " << "2D.x " << "2D.y " << endl; -// for( int i=0; i<sz_3d; i++ ) -// { -// // debout << ((Point3f) mExtrCalibration->get3DList().at(i)).x << " " -// // << ((Point3f) mExtrCalibration->get3DList().at(i)).y << " " -// // << ((Point3f) mExtrCalibration->get3DList().at(i)).z << " " -// // << ((Point2f) mExtrCalibration->get2DList().at(i)).x << " " -// // << ((Point2f) mExtrCalibration->get2DList().at(i)).y << endl; -// } - -// if( !withImageData ) -// { -// // Save corresponding image-points, -// QFile file(src); -// int i; - -// if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) -// { -// QMessageBox::critical(this, tr("PeTrack"), tr("Cannot open %1:\n%2.").arg(src).arg(file.errorString())); -// return; -// } - -// QTextStream out(&file); - -// out << sz_3d << endl; -// for (i = 0; i < sz_3d; ++i) -// { -// out << list3D.at(i).x << " " << list3D.at(i).y << " " << list3D.at(i).z << " " << list2D.at(i).x << " " << list2D.at(i).y << endl; -// } - -// file.close(); - -// } - -// // mExtrCalibration->calibExtrinsicParams(); -// }else // is 3dc-File ? -// { -// QMessageBox::critical(this, tr("PeTrack"), tr("File format is not supported for 3D calibration input files: %1 (supported: .3dc ").arg(src.right(4))); -// return; -// } -// }else // src empty ? -// { -// QMessageBox::critical(this, tr("PeTrack"), tr("Cannot open 3D calibration file: file is missing.")); -// return; -// } -//} - void Petrack::exportTracker(QString dest) //default = "" { static QString lastFile; @@ -3021,15 +2539,6 @@ void Petrack::exportTracker(QString dest) //default = "" // if no destination file or folder is given if (dest.isEmpty()) { - // if (lastFile.isEmpty() && !mSeqFileName.isEmpty()) - // lastFile = QFileInfo(mSeqFileName).path(); - //getSaveFileName( ==> Wird keine Dateiendung angegeben wird automatisch die erste aus dem Filter angehangen - //QUrl url = QFileDialog::getSaveFileUrl(this, - // tr("Select file for exporting tracking pathes"), - // lastFile, - // tr("Tracker (*.*);;Petrack tracker (*.trc);;Text (*.txt);;Text for gnuplot(*.dat);;XML Travisto (*.trav);;All supported types (*.txt *.trc *.dat *.trav *.);;All files (*.*)")); - //dest = url.toLocalFile();//path();//toString(); - QFileDialog fileDialog(this, tr("Select file for exporting tracking pathes"), lastFile, @@ -3037,26 +2546,10 @@ void Petrack::exportTracker(QString dest) //default = "" fileDialog.setAcceptMode(QFileDialog::AcceptSave); fileDialog.setFileMode(QFileDialog::AnyFile); fileDialog.setDefaultSuffix(""); - //fileDialog.setOption(); - -// foreach (QString filter, fileDialog.mimeTypeFilters()) { -// debout << "MIME-Typ Filter: " << filter << endl; - -// } -// foreach (QString filter, fileDialog.nameFilters()) { -// debout << "Name Filter: " << filter << endl; - -// } if( fileDialog.exec() ){ dest = fileDialog.selectedFiles().at(0); -// debout << "selectedFiles" << endl; } - //dest = QFileDialog::getSaveFileName(this, - // tr("Select file for exporting tracking pathes"), - // lastFile, - // tr("Tracker (*.*);;Petrack tracker (*.trc);;Text (*.txt);;Text for gnuplot(*.dat);;XML Travisto (*.trav);;All supported types (*.txt *.trc *.dat *.trav *.);;All files (*.*)")); - } if (!dest.isEmpty()) @@ -3066,15 +2559,12 @@ void Petrack::exportTracker(QString dest) //default = "" mMultiColorMarkerWidget->autoCorrect->isChecked() && mMultiColorMarkerWidget->autoCorrectOnlyExport->isChecked(); -// debout << "dest: " << dest << " suffix: " << dest.right(4) << endl; - if (dest.right(4) == ".trc") { #ifdef TIME_MEASUREMENT double time1 = 0.0, tstart; tstart = clock(); #endif - //QFile file(dest); QTemporaryFile file; int i; @@ -3092,10 +2582,7 @@ void Petrack::exportTracker(QString dest) //default = "" qApp->processEvents(); - //if (mControlWidget->exportComment->isChecked()) trcVersion = 4; - //else - // trcVersion = 2; debout << "export tracking data to " << dest << " (" << mTracker->size() << " person(s), file version " << trcVersion << ")..." << std::endl; QTextStream out(&file); @@ -3107,8 +2594,6 @@ void Petrack::exportTracker(QString dest) //default = "" qApp->processEvents(); progress.setLabelText(QString("Export person %1 of %2 ...").arg(i+1).arg(mTracker->size())); progress.setValue(i+1); - //if(mControlWidget->exportComment->isChecked()) - // out << "# " << (*mTracker)[i].comment() << endl; out << (*mTracker)[i] << Qt::endl; } file.flush(); @@ -3134,9 +2619,6 @@ void Petrack::exportTracker(QString dest) //default = "" else statusBar()->showMessage(tr("Saved tracking data to %1.").arg(dest), 5000); - // kurz Alternative zu oben aber schlechter lesbar - //while(!file.copy(dest)) QFile::remove(dest); - progress.setValue(mTracker->size()+1); std::cout << " finished " << std::endl; @@ -3149,11 +2631,7 @@ void Petrack::exportTracker(QString dest) //default = "" // time1 = 0.0; // tstart = clock(); #endif -// mTracker->checkPlausibility(pers, frame, -// mControlWidget->testEqual->isChecked(), -// mControlWidget->testVelocity->isChecked(), -// mControlWidget->testInside->isChecked(), -// mControlWidget->testLength->isChecked()); + #ifdef TIME_MEASUREMENT // time1 += clock() - tstart; // time1 = time1/CLOCKS_PER_SEC; @@ -3165,7 +2643,7 @@ void Petrack::exportTracker(QString dest) //default = "" { QTemporaryFile file; - if (!file.open()) //!file.open(QIODevice::WriteOnly | QIODevice::Text)) + if (!file.open()) { PCritical(this, tr("PeTrack"), tr("Cannot open %1:\n%2.").arg(dest).arg(file.errorString())); return; @@ -3270,11 +2748,7 @@ void Petrack::exportTracker(QString dest) //default = "" // time1 = 0.0; // tstart = clock(); #endif -// mTracker->checkPlausibility(pers, frame, -// mControlWidget->testEqual->isChecked(), -// mControlWidget->testVelocity->isChecked(), -// mControlWidget->testInside->isChecked(), -// mControlWidget->testLength->isChecked()); + #ifdef TIME_MEASUREMENT // time1 += clock() - tstart; // time1 = time1/CLOCKS_PER_SEC; @@ -3283,15 +2757,6 @@ void Petrack::exportTracker(QString dest) //default = "" } else if (dest.right(4) == ".dat") { - // // war: immer wenn txt exportiert wird, wird auch fuer dat fuer excel exportiert - // QString destDat(dest.left(dest.length()-4)+".dat"); - // QFile fileDat(destDat); - // if (!fileDat.open(QIODevice::WriteOnly | QIODevice::Text)) - // { - // QMessageBox::critical(this, tr("PeTrack"), tr("Cannot open %1:\n%2.").arg(destDat).arg(fileDat.errorString())); - // return; - // } - QTemporaryFile fileDat; if (!fileDat.open()) //!fileDat.open(QIODevice::WriteOnly | QIODevice::Text)) @@ -3329,43 +2794,6 @@ void Petrack::exportTracker(QString dest) //default = "" statusBar()->showMessage(tr("Saved tracking data to %1.").arg(dest), 5000); std::cout << " finished" << std::endl; - - -// mTracker->checkPlausibility(pers, frame, -// mControlWidget->testEqual->isChecked(), -// mControlWidget->testVelocity->isChecked(), -// mControlWidget->testInside->isChecked(), -// mControlWidget->testLength->isChecked()); - - // - // // immer wenn txt exportiert wird, wird auch fuer visu-software xml nach ulrich kemlow exportiert - // QString destXml(dest.left(dest.length()-4)+".trav"); - // QFile fileXml(destXml); - // if (!fileXml.open(QIODevice::WriteOnly | QIODevice::Text)) - // { - // QMessageBox::critical(this, tr("PeTrack"), tr("Cannot open %1:\n%2.").arg(destXml).arg(fileXml.errorString())); - // return; - // } - // debout << "export tracking data to " << destXml << " (" << mTracker->size() << " person(s))..." << endl; - // // already done: mTrackerReal->calculate(mTracker, mImageItem, mControlWidget->getColorPlot(), getImageBorderSize(), mControlWidget->trackMissingFrames->checkState()); - // QTextStream outXml(&fileXml); - // outXml << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" <<endl; - // outXml << "<trajectoriesDataset>" <<endl; - // outXml << " <header>" <<endl; - // outXml << " <roomCaption>PeTrack: " << mAnimation->getFileBase() << "</roomCaption>" << endl; - // outXml << " <roomID>0</roomID>" <<endl; - // outXml << " <agents>" << mTracker->size() << "</agents>" << endl; - // outXml << " <frameRate>" << mAnimation->getFPS() << "</frameRate> <!--per second-->" << endl; - // // outXml << " <timeStep>" << 1000./mAnimation->getFPS() << "</timeStep> <!-- millisecond-->" << endl; inverse von - // outXml << " <timeFirstFrame sec=\"" << mAnimation->getFirstFrameSec() << "\" microsec=\"" << mAnimation->getFirstFrameMicroSec() - // << "\"/> <!-- " << mAnimation->getTimeString(0) << " -->" << endl; - // outXml << " </header>" <<endl<<endl; - // - // mTrackerReal->exportXml(outXml, mControlWidget->trackAlternateHeight->checkState(), mStereoWidget->stereoUseForExport->isChecked()); - // - // outXml << "</trajectoriesDataset>" <<endl; - // fileXml.close(); - // cout << " finished" << endl; } else if (dest.right(5) == ".trav") { @@ -3382,11 +2810,6 @@ void Petrack::exportTracker(QString dest) //default = "" mControlWidget->exportElimTp->isChecked(), mControlWidget->exportElimTrj->isChecked(), mControlWidget->exportSmooth->isChecked(), mControlWidget->exportViewDir->isChecked(), mControlWidget->exportAngleOfView->isChecked(), mControlWidget->exportMarkerID->isChecked(), autoCorrectOnlyExport); -// mTrackerReal->calculate(mTracker, mImageItem, mControlWidget->getColorPlot(), getImageBorderSize(), -// mControlWidget->trackMissingFrames->checkState(), -// mStereoWidget->stereoUseForExport->isChecked(), -// mControlWidget->trackAlternateHeight->checkState(), mControlWidget->coordAltitude->value(), mStereoWidget->stereoUseCalibrationCenter->isChecked(), -// mControlWidget->exportElimTp->isChecked(), mControlWidget->exportElimTrj->isChecked(), mControlWidget->exportSmooth->isChecked()); QTemporaryFile fileXml; if (!fileXml.open()) //!fileXml.open(QIODevice::WriteOnly | QIODevice::Text)) @@ -3432,10 +2855,6 @@ void Petrack::exportTracker(QString dest) //default = "" exportTracker(dest + ".trc"); exportTracker(dest + ".txt"); } - // else - // { - // QMessageBox::critical(this, tr("PeTrack"), tr("Cannot save %1 maybe because of wrong file extension.").arg(dest)); - // } lastFile = dest; } } @@ -3487,10 +2906,6 @@ void Petrack::trackAll() QProgressDialog progress("Tracking pedestrians through all frames...", "Abort tracking", 0, 2*mAnimation->getNumFrames()-memPos, this); progress.setWindowModality(Qt::WindowModal); // blocks main window - // mTracker()->init(); // wenn vorherige Daten weggenommen werden sollen - - // mPlayerWidget->skipToFrame(0); //man koennte an den Anfang springen - // vorwaertslaufen ab aktueller Stelle und trackOnlineCalc zum tracken nutzen do { @@ -3531,7 +2946,6 @@ void Petrack::trackAll() while (mPlayerWidget->frameBackward()); // bei abbruch koennen es auch mPlayerWidget->getPos() frames sein, die bisher geschrieben wurden - // debout << "wrote " << mPlayerWidget->getPos()+1 << " of " << mAnimation->getNumFrames() << " frames." << endl; progress.setValue(2*mAnimation->getNumFrames()-memPos); } @@ -3568,8 +2982,6 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n static int lastRecoFrame = -10000; static bool borderChangedForTracking = false; - //static QTime updateTime; // ergibt die gleichen werte wie benutzte native systemroutinben!!! - // need semaphore to guarrantee that updateImage only called once // updateValue of control automatically calls updateImage!!! static QSemaphore semaphore(1); @@ -3587,8 +2999,6 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n // have to store because evaluation sets the filter parameter to unchanged bool brightContrastChanged = mBrightContrastFilter.changed(); bool swapChanged = mSwapFilter.changed(); - // bool brightChanged = mBrightFilter.changed(); - // bool contrastChanged = mContrastFilter.changed(); bool borderChanged = mBorderFilter.changed(); bool calibChanged = mCalibFilter->changed(); @@ -3601,19 +3011,16 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n debout << "vor filter: " << getElapsedTime() <<endl; #endif -// debout << "swap: " << mIplImgFiltered << " " << mIplImg << endl; if (imageChanged || swapChanged) mImgFiltered = mSwapFilter.apply(mImgFiltered); else mImgFiltered = mSwapFilter.getLastResult(); -// debout << "b-c: " << mIplImgFiltered << " " << mIplImg << endl; if (imageChanged || swapChanged || brightContrastChanged) mImgFiltered = mBrightContrastFilter.apply(mImgFiltered); else mImgFiltered = mBrightContrastFilter.getLastResult(); -// debout << "border: " << mIplImgFiltered << " " << mIplImg << endl; if (imageChanged || swapChanged || brightContrastChanged || borderChanged) mImgFiltered = mBorderFilter.apply(mImgFiltered); // mIplImg else @@ -3656,7 +3063,6 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n mBackgroundFilter.reset(); // alle gesammelten hintergrundinfos werden verworfen und bg.changed auf true gesetzt } -// debout << "bg: " << mIplImgFiltered << " " << mIplImg << endl; if (imageChanged || mBackgroundFilter.changed()) mImgFiltered = mBackgroundFilter.apply(mImgFiltered); else @@ -3670,11 +3076,6 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n // delete track list, if intrinsic param have changed if (calibChanged && mTracker->size() > 0) //mCalibFilter.getEnabled() && { - //CvSize size; - //size.width = mIplImgFiltered->width; - //size.height = mIplImgFiltered->height; - //mTracker->init(size); - // Evtl. nicht Tracker loeschen sondern entsprechend der neuen Calibration verschieben?!?!? mTracker->clear(); mTracker->reset(); @@ -3705,8 +3106,6 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n myRound(mTrackingRoiItem->rect().width()), myRound(mTrackingRoiItem->rect().height())); -// mTracker->resize(Size(roi.width(),roi.height())); - if (borderChangedForTracking) { cv::Size size; @@ -3740,7 +3139,6 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n #ifdef TIME_MEASUREMENT debout << "nach track: " << getElapsedTime() <<endl; #endif -// debout << "track anz: " << anz << endl; mControlWidget->trackNumberNow->setText(QString("%1").arg(anz)); mTrackChanged = false; borderChangedForTracking = false; @@ -3748,10 +3146,7 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n else mControlWidget->trackNumberNow->setText(QString("0")); // hier muesste fuer ameisen etc allgemeinABC.getPosList(...) - //#static IplImage *tempImg = NULL; -// debout << "reco: " << mIplImgFiltered << " " << mIplImg << endl; -// debout << "imageChanged: " << imageChanged << " swapChanged: " << swapChanged << " b-c-Changed: " << brightContrastChanged << " borderChanged: "<< borderChanged << " calibChanged: " << calibChanged << " recognitionChanged: " << recognitionChanged() << endl; if (((((lastRecoFrame+mControlWidget->recoStep->value()) <= frameNum) || ((lastRecoFrame-mControlWidget->recoStep->value()) >= frameNum)) && imageChanged) || mAnimation->isCameraLiveStream() || swapChanged || brightContrastChanged || borderChanged || calibChanged || recognitionChanged()) @@ -3763,10 +3158,7 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n #endif if (borderChanged) mRecognitionRoiItem->checkRect(); - //#cvReleaseImage(&tempImg); - //#tempImg = cvCloneImage(mIplImgFiltered); // must be deleted, if marker in ebene darueber gemalt werden!!!!! - // QPointF p = mRecognitionRoiItem->mapToItem(mImageItem, QPointF(0.,0.)); nicht noetig da drag nun selber gemacht wird -// debout << "start reco" << endl; + if (mControlWidget->performRecognition->checkState() == Qt::Checked) { QRect rect(myRound(mRecognitionRoiItem->rect().x()+getImageBorderSize()), @@ -3774,7 +3166,6 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n myRound(mRecognitionRoiItem->rect().width()), myRound(mRecognitionRoiItem->rect().height())); QList<TrackPoint> persList; -// bool markerLess = true; auto recoMethod = mControlWidget->getRecoMethod(); #ifdef TIME_MEASUREMENT // "==========: " @@ -3784,17 +3175,7 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n || (recoMethod == reco::RecognitionMethod::Color) || (recoMethod == reco::RecognitionMethod::Japan) || (recoMethod == reco::RecognitionMethod::MultiColor) || (recoMethod == reco::RecognitionMethod::Code)) //else { - // persList == crossList - // getMarkerPos(mIplImgFiltered, rect, &persList, mControlWidget->markerBrightness->value(), - // getImageBorderSize(), (mControlWidget->markerIgnoreWithout->checkState() == Qt::Checked), - // (mControlWidget->recoAutoWB->checkState() == Qt::Checked), getBackgroundFilter(), recoMethod); //#tempImg reco::getMarkerPos(mImgFiltered, rect, &persList, mControlWidget, getImageBorderSize(), getBackgroundFilter()); -// markerLess = false; -// debout << "Testausgabe persList: [Frame " << frameNum << "] " << endl; -// for (int i = 0; i < persList.size(); ++i) -// { -// cout << persList.at(i) << endl; -// } } #ifndef STEREO_DISABLED if (mStereoContext && mStereoWidget->stereoUseForReco->isChecked()) @@ -3808,29 +3189,20 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n debout << "nach reco: " << getElapsedTime() <<endl; #endif mTracker->addPoints(persList, frameNum); -// debout << "reco anz: " << persList.size() << endl; + // folgendes lieber im Anschluss, ggf beim exportieren oder statt test direkt del: if (mStereoContext && mStereoWidget->stereoUseForReco->isChecked()) mTracker->purge(frameNum); // bereinigen wenn weniger als 0.2 recognition und nur getrackt mControlWidget->recoNumberNow->setText(QString("%1").arg(persList.size())); mRecognitionChanged = false; - // QString s("#%1%2%3"); // static moeglich? - // s = s.arg(qRed(col), 2, 16, QChar('0')).arg(qGreen(col), 2, 16, QChar('0')).arg(qBlue(col), 2, 16, QChar('0')); - // if ((qRed(col)+qGreen(col)+qBlue(col))/3 < 128) - // mStatusLabelColor->setText(QString("<font color=\"#ffffff\"> %1</font>").arg(s)); - // else - // mStatusLabelColor->setText(QString("<font color=\"#000000\"> %1</font>").arg(s)); - - // mControlWidget->getColorPlot()->updateTracker(); // oder nur wenn tab offen oder wenn sich mtracker geaendert hat??? + if (false) // hier muss Abfage hin ob kasernen marker genutzt wird mControlWidget->getColorPlot()->replot(); // oder nur wenn tab offen oder wenn sich mtracker geaendert hat??? } else mControlWidget->recoNumberNow->setText(QString("0")); lastRecoFrame = frameNum; -// debout << "end reco" << endl; - } else mControlWidget->recoNumberNow->setText(QString("0")); @@ -3866,60 +3238,23 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n // "==========: " debout << "stp update: " << getElapsedTime() <<endl; #endif -// debout << " ############ out ############## " << mIplImgFiltered << " " << mIplImg << endl; - -// debout << "mIplImage ok ? " << (mIplImg != NULL) << " +++ mIplImageFiltered ok ? " << (mIplImgFiltered != NULL) << endl; } void Petrack::updateImage(const cv::Mat &img) { mImg = img; -// namedWindow("Test"); -// imshow("Test",mImg); -// waitKey(); - updateImage(true); } -//void Petrack::updateImage(IplImage *iplImg) -//{ -// // static int prevFrame = -1; // only 1 instanze allowed!!!!!! - -// //if (iplImg != mIplImg) -// //{ -// //cvReleaseImage(&mIplImg); wird nun in animation gemacht -// mIplImg = iplImg; -// //} - -// // //if ( online calculation || calc all) -// // if (mIplImgFiltered) // != if mIplImgFiltered != NULL a picture was shown before -// // { -// // if (mPrevIplImgFiltered) -// // cvReleaseImage(&mPrevIplImgFiltered); -// // mPrevIplImgFiltered = cvCreateImage(cvGetSize(mIplImgFiltered),8,3); -// // } -// // mPrevFrame = prevFrame; -// // prevFrame = mAnimation->getCurrentFrameNum(); -//// debout << "test" << endl; -// updateImage(true); -//// debout << "test" << endl; - -//} void Petrack::updateSequence() { QImage *oldImage = mImage; - //cvReleaseImage(&mIplImg); darf niiiiiie gemacht werden - ewig nach fehler gesucht - kommt bei filern durcheinander!!! QSize size = mAnimation->getSize(); size.setWidth(size.width()+2*getImageBorderSize());// border is inside the mImage! size.setHeight(size.height()+2*getImageBorderSize()); mImage = new QImage(size, QImage::Format_RGB888);//32); //wird in updateImage gemacht - - - // cvReleaseImage(&mPrevIplImgFiltered); // vorheriges bild ; NULL zeigt an, dass neue bildfolge - // mPrevFrame = -1; - // set roi for recognition if image size changes or roi is zero //in oldImage steckt border drin, mIplImg->height zeigt noch auf altes ursprungsbild // mRecognitionRoiItem->rect().width() != 0 && oldImage == NULL wenn projektdatei eingelesen wird!!!!! @@ -3936,13 +3271,9 @@ void Petrack::updateSequence() mTracker->init(size2); mPlayerWidget->setAnim(mAnimation); -// debout << "test" << endl; mPlayerWidget->skipToFrame(0); -// debout << "test" << endl; mImageItem->setImage(mImage);//wird in updateImage gemacht -// debout << "test" << endl; delete oldImage; -// debout << "test" << endl; mSaveSeqVidAct->setEnabled(true); mSaveSeqVidViewAct->setEnabled(true); mSaveSeqImgAct->setEnabled(true); @@ -3963,21 +3294,18 @@ double Petrack::getCmPerPixel() const return mCmPerPixel; } -// die Groesse des kreises des durchschnittlichen Kopfdurchmessers, der ganzen kopf umfasst in Pixel -// annahmen: 21cm avg kopflaenge, mapDefaultheight genommen statt: 173cm avg koerpergroesse mann / frau mit Schuhen (180cm waere nur Mann) -// hS ==-1 als default besagt, dass mHeadSize neu berechnet statt gesetzt werden soll -// WENN HEADSIZE NEU BERECHNET WIRD WIRD AUTOMATISCH AUCH CMPERPIXEL MITBERECHNET /** * @brief Sets the size of the circle of the average head circumference in pixel. * * Assumption for default calculation: <br> * 21cm avg head length <br> - * default height of person accoring to mapDefaultHeigt <br> + * default height of person according to mapDefaultHeigt <br> * * Default case recalculates mCmPerPixel * + * If headsize get recalulated also mCmPerPixel will be calculated! * @see Petrack::getCmPerPixel - * @param hS new headsize or -1, for calculating default + * @param hS new headsize, if hS==-1 mHeadSize will be calculated instead of set */ void Petrack::setHeadSize(double hS) { @@ -4002,22 +3330,10 @@ double Petrack::getHeadSize(QPointF *pos, int pers, int frame) if( mControlWidget->getCalibCoordDimension() == 0 ) { - //debout << "getHeadSize: " << pers << " " << frame << endl; - //debout << mTracker->at(pers).trackPointAt(frame) << endl; - -// debout << "mTracker->at(pers).height(): " << mTracker->at(pers).height() << endl; -// debout << "mControlWidget->mapDefaultHeight->value(): " << mControlWidget->mapDefaultHeight->value() << endl; -// debout << "mControlWidget->mapHeight->value(): " << mControlWidget->mapHeight->value() << endl; int diff; cv::Point3f p3d = getExtrCalibration()->get3DPoint(cv::Point2f(mTracker->at(pers).trackPointAt(frame).x(), mTracker->at(pers).trackPointAt(frame).y()), mControlWidget->mapDefaultHeight->value()); - //mTracker->at(pers).height()); // mStatusPosRealHeight->value()); - -// debout << "Track position: (" << mTracker->at(pers).trackPointAt(frame).x() << ", " << mTracker->at(pers).trackPointAt(frame).y() << ")" << endl; -// debout << "P3D: (" << p3d.x << ", " << p3d.y << ", " << p3d.z << ")" << endl; - - //debout << "3D Punkt: x: " << p3d.x << ", y: " << p3d.y << ", z: " << p3d.z << endl; cv::Point2f p3d_x1 = getExtrCalibration()->getImagePoint( cv::Point3f(p3d.x+HEAD_SIZE*0.5, p3d.y, p3d.z) ); cv::Point2f p3d_x2 = getExtrCalibration()->getImagePoint( cv::Point3f(p3d.x-HEAD_SIZE*0.5, p3d.y, p3d.z) ); @@ -4026,11 +3342,6 @@ double Petrack::getHeadSize(QPointF *pos, int pers, int frame) diff = (int) std::max(sqrt(pow(p3d_x2.x-p3d_x1.x,2)+pow(p3d_x2.y-p3d_x1.y,2)), sqrt(pow(p3d_y2.x-p3d_y1.x,2)+pow(p3d_y2.y-p3d_y1.y,2))); -// max(abs(getExtrCalibration()->getImagePoint(Point3f(p3d.x+HEAD_SIZE*0.5, p3d.y, p3d.z)).x- -// getExtrCalibration()->getImagePoint(Point3f(p3d.x-HEAD_SIZE*0.5, p3d.y, p3d.z)).x) -// ,abs(getExtrCalibration()->getImagePoint(Point3f(p3d.x, p3d.y+HEAD_SIZE*0.5, p3d.z)).y- -// getExtrCalibration()->getImagePoint(Point3f(p3d.x, p3d.y-HEAD_SIZE*0.5, p3d.z)).y)); -// debout << "HeadSize: " << diff << endl; return diff;// < 8 ? 8 : diff; }else { @@ -4066,7 +3377,6 @@ QSet<int> Petrack::getOnlyVisible() { if ((mControlWidget->trackOnlyVisible->checkState() == Qt::Checked) && (mControlWidget->trackShowOnly->checkState() == Qt::Checked || mControlWidget->trackShowOnlyList->checkState() == Qt::Checked)) { -// int maxPed = mTracker->size(); if( mControlWidget->trackShowOnlyList->checkState() == Qt::Checked) { QStringList list = mControlWidget->trackShowOnlyNrList->text().split(",", Qt::SkipEmptyParts); @@ -4101,7 +3411,7 @@ QSet<int> Petrack::getOnlyVisible() } return onlyVisible; //in anzeige wird ab 1 gezaehlt, in datenstruktur ab 0 - }else // if(ControlWidget->trackShowOnly->checkState() == Qt::Checked) // + }else { QSet<int> onlyVisible; onlyVisible.insert(mControlWidget->trackShowOnlyNr->value()-1); @@ -4118,7 +3428,6 @@ void Petrack::addManualTrackPointOnlyVisible(const QPointF& pos) pers = mTracker->size()+1; pers = mControlWidget->trackShowOnlyNr->maximum(); mControlWidget->trackShowOnlyNr->setValue(pers); -// mControlWidget->trackShowOnlyNr->setText(QString::number(pers)); mControlWidget->trackShowOnly->setChecked(true); } @@ -4129,15 +3438,6 @@ void Petrack::updateControlWidget() mControlWidget->trackNumberVisible->setText(QString("%1").arg(mTracker->visible(mAnimation->getCurrentFrameNum()))); } -//void Petrack::showContextMenu(QPointF pos) -//{ -// QMenu menu(this); -// menu.addAction(mDelPastAct); -// menu.addAction(mDelFutureAct); -// menu.addAction(mDelAllRoiAct); -// menu.exec(pos.toPoint()); -//} - void Petrack::splitTrackPerson(QPointF pos) { mTracker->splitPersonAt((Vec2F) pos, mAnimation->getCurrentFrameNum(), getOnlyVisible()); diff --git a/src/player.cpp b/src/player.cpp index cf35bcd0e..fb450df5f 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -85,7 +85,6 @@ Player::Player(Animation *anim, QWidget *parent) : QWidget(parent) //slider mSlider = new QSlider(Qt::Horizontal); - //mSlider->setRange(0, anim->getNumFrames()>1 ? anim->getNumFrames()-1 : 0); 0 ist default unf setAnim macht rest mSlider->setTickPosition(QSlider::TicksAbove); mSlider->setMinimumWidth(100); connect(mSlider,SIGNAL(valueChanged(int)),this,SLOT(skipToFrame(int))); @@ -114,10 +113,8 @@ Player::Player(Animation *anim, QWidget *parent) : QWidget(parent) mFrameNum = new QLineEdit("0"); mFrameNum->setMaxLength(8); // bedeutet maxminal 1,1 stunden -// QSize sz = mFrameNum->minimumSizeHint(); //mFrameNum->minimumSizeHint(); // mFrameNum->sizeHint(); mFrameNum->setMaximumWidth(75); //5*sz.width() //62 mFrameNum->setAlignment(Qt::AlignRight); -// mFrameNum->setInputMask ("99999"); mFrameNum->setValidator(mFrameNumValidator); mFrameNum->setFont(f); connect(mFrameNum,SIGNAL(editingFinished()),this,SLOT(skipToFrame())); @@ -125,21 +122,15 @@ Player::Player(Animation *anim, QWidget *parent) : QWidget(parent) //frame number mFpsNum = new QLineEdit(QString::number(DEFAULT_FPS)); mFpsNum->setMaxLength(8); // bedeutet maxminal 999,99 -// QSize sz = mFrameNum->minimumSizeHint(); //mFrameNum->minimumSizeHint(); // mFrameNum->sizeHint(); mFpsNum->setMaximumWidth(62); //5*sz.width() mFpsNum->setAlignment(Qt::AlignRight); -// mFrameNum->setInputMask ("99999"); mFpsNumValidator = new QDoubleValidator(0.0, 999.99, 2, this); mFpsNum->setValidator(mFpsNumValidator); mFpsNum->setFont(f); connect(mFpsNum,SIGNAL(editingFinished()),this,SLOT(setFPS())); -// mFpsLabel = new QLabel(); -// mFpsLabel->setFont(f2); - //static QLabel atLabel("@"); QFont f2("Courier", 12, QFont::Normal); //Times Helvetica, Normal mAtLabel = new QLabel("@"); - //mAtLabel->setText(); mAtLabel->setFont(f2); mSourceInLabel = new QLabel("In:"); @@ -148,9 +139,7 @@ Player::Player(Animation *anim, QWidget *parent) : QWidget(parent) mSourceOutLabel = new QLabel("Out:"); mSourceOutLabel->setFont(f2); - //static QLabel fpsLabel("fps"); mFpsLabel = new QLabel("fps"); - //mFpsLabel->setText("fps"); mFpsLabel->setFont(f2); // default value mPlayerSpeedLimited = false; @@ -234,8 +223,6 @@ void Player::setAnim(Animation *anim) mFrameNumValidator->setTop(max); mFrameInNumValidator->setTop(anim->getSourceOutFrameNum()); mFrameOutNumValidator->setTop(anim->getMaxFrames()); -// mFpsLabel->setText(QString("@ %1 fps").arg(anim->getFPS())); -// mIplImg = NULL; // release? } } @@ -262,8 +249,6 @@ bool Player::updateImage() if (mImg.empty()) { pause(); - //cerr<<"No valid image to update"<<endl; -// mMainWindow->updateImage(Mat(mImg.rows,mImg.cols,CV_8UC3,Scalar(0,0,0))); return false; } qApp->processEvents(); @@ -271,13 +256,10 @@ bool Player::updateImage() double time1 = 0.0, tstart; tstart = clock(); #endif -// debout << "test" << endl; mMainWindow->updateImage(mImg); -// debout << "test" << endl; if (mRec) { mAviFile.appendFrame((const unsigned char*) mImg.data, true); - //mAviWriter.append(mIplImg); } #ifdef TIME_MEASUREMENT time1 += clock() - tstart; @@ -552,11 +534,10 @@ bool Player::skipTo(int proMil) // proMil = [0..1000] { if (mSliderSet) { -// mSliderSet = false; return false; } pause(); - mImg = mAnimation->getFrameAtPos(proMil/1000.0);//cvarrToMat(mAnimation->getFrameAtPos(proMil/1000.0)); // value between 0..1 + mImg = mAnimation->getFrameAtPos(proMil/1000.0); // value between 0..1 return updateImage(); } @@ -564,31 +545,19 @@ bool Player::skipToFrame(int f) // [0..mAnimation->getNumFrames()-1] { if (mSliderSet) { -// mSliderSet = false; return false; } pause(); -// debout << "test" << endl; - mImg = mAnimation->getFrameAtIndex(f);//cvarrToMat(mAnimation->getFrameAtIndex(f)); -// debout << "test" << endl; + mImg = mAnimation->getFrameAtIndex(f); return updateImage(); } bool Player::skipToFrame() // [0..mAnimation->getNumFrames()-1] { -// if (mSliderSet) -// { -// // mSliderSet = false; -// return false; -// } - //debout << "num: " << mFrameNum->text().toInt() << endl; if (mFrameNum->text().toInt() < getFrameInNum()) mFrameNum->setText(QString::number(getFrameInNum())); if (mFrameNum->text().toInt() > getFrameOutNum()) mFrameNum->setText(QString::number(getFrameOutNum())); -// pause(); -// mIplImg = mAnimation->getFrameAtIndex(mFrameNum->text().toInt()); -// return updateImage(); return skipToFrame(mFrameNum->text().toInt()); } @@ -659,8 +628,6 @@ void Player::setFrameOutNum(int out) mFrameInNumValidator->setTop(/*out*/getFrameOutNum()-1); mFrameNumValidator->setBottom(getFrameInNum()); mFrameNumValidator->setTop(/*out*/getFrameOutNum()); - - //update(); } int Player::getPos() diff --git a/src/recognition.cpp b/src/recognition.cpp index f63bc894a..174ce8bbd 100644 --- a/src/recognition.cpp +++ b/src/recognition.cpp @@ -43,15 +43,8 @@ namespace reco { using namespace detail; -//#include "Psapi.h" - -//#define WITH_RECT #define ELLIPSE_DISTANCE_TO_BORDER 10 -//#define SHOW_TMP_IMG - -//#define TIME_MEASUREMENT - struct ColorParameters { int h_low = 0; @@ -75,23 +68,12 @@ struct ColorParameters void thresholdHSV (const cv::Mat &src, cv::Mat &bin, const ColorParameters ¶m) { -// IplImage *hsvIpl; int h, s, v; int x, y; cv::Mat hsv {src.size(), src.type()}; - -// hsvIpl = cvCloneImage(srcIpl); // make a copy - -// cvCvtColor(srcIpl ,hsvIpl, CV_BGR2HSV); // convert to HSV color space - cv::cvtColor(src, hsv, cv::COLOR_BGR2HSV); -// unsigned char* dataImg = ((unsigned char*) hsvIpl->imageData); -// unsigned char* yDataImg = dataImg; -// unsigned char* data = ((unsigned char*) binIpl->imageData); -// unsigned char* yData = data; - for (y = 0; y < bin.rows/*binIpl->height*/; ++y) { for (x = 0; x < bin.cols/*binIpl->width*/; ++x) @@ -100,11 +82,6 @@ void thresholdHSV (const cv::Mat &src, cv::Mat &bin, const ColorParameters ¶ h = intensity.val[0]; s = intensity.val[1]; v = intensity.val[2]; -// debout << "h:" << h << ", s:" << s << ", v:" << v << endl; -// h = dataImg[0]; -// s = dataImg[1]; -// v = dataImg[2]; -// debout << "h:" << h << ", s:" << s << ", v:" << v << endl; // apply the thresholds if ((!param.inversHue && (h < param.h_low || param.h_high < h)) || @@ -113,25 +90,12 @@ void thresholdHSV (const cv::Mat &src, cv::Mat &bin, const ColorParameters ¶ (v < param.v_low || param.v_high < v)) { bin.at<uchar>(cv::Point(x, y)) = 0; -// *data = 0; }else { bin.at<uchar>(cv::Point(x, y)) = 255; -// *data = 255; } -// ++data; -// dataImg+=3; } -// data = (yData += binIpl->widthStep/sizeof(char)); //width); -// dataImg = (yDataImg += hsvIpl->widthStep/sizeof(char)); //width); } -// cvNamedWindow("hsv", CV_WINDOW_AUTOSIZE ); // 0 wenn skalierbar sein soll -// cvShowImage("hsv", hsv); -// binIpl = cvCreateImage(cvSize(bin.cols,bin.rows),8,3); -// IplImage tmpIpl = bin; -// cvCopy(&tmpIpl,binIpl); - -// cvReleaseImage(&hsvIpl); } #ifndef STEREO_DISABLED void thresholdHSV (const IplImage *srcIpl, IplImage *binIpl, const ColorParameters ¶m) @@ -185,31 +149,6 @@ void setColorParameter(const QColor &fromColor, const QColor &toColor, bool inve param.inversHue = inversHue; } -//A good starting point would be GetProcessMemoryInfo, which reports various memory info about the specified process. -//You can pass GetCurrentProcess() as the process handle in order to get information about the calling process. -//Probably the WorkingSetSize member of PROCESS_MEMORY_COUNTERS is the closest match to the Mem Usage coulmn in task manager, -//but it is not going to be exactly the same. -//I would experiment with the different values to find the one that is closest to your needs. -////Usage: -//#include "windows.h" -//#include "psapi.h" -// PROCESS_MEMORY_COUNTERS pmc; -// GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)); -// debout << pmc.WorkingSetSize/1000 <<"KB Usage of the process"<< endl; -//// typedef struct _PROCESS_MEMORY_COUNTERS { -//// DWORD cb; -//// DWORD PageFaultCount; -//// DWORD PeakWorkingSetSize; -//// DWORD WorkingSetSize; -//// DWORD QuotaPeakPagedPoolUsage; -//// DWORD QuotaPagedPoolUsage; -//// DWORD QuotaPeakNonPagedPoolUsage; -//// DWORD QuotaNonPagedPoolUsage; -//// DWORD PagefileUsage; -//// DWORD PeakPagefileUsage; -//// } PROCESS_MEMORY_COUNTERS,*PPROCESS_MEMORY_COUNTERS; - - /** * @brief calculates pixel-displacement due to oblique/angular view * @@ -230,15 +169,9 @@ Vec2F autoCorrectColorMarker(Vec2F &boxImageCentre, Control *controlWidget) boxImageCentreWithBorder += Vec2F(mainWindow->getImageBorderSize(), mainWindow->getImageBorderSize()); pixUnderCam += Vec2F(mainWindow->getImageBorderSize(), mainWindow->getImageBorderSize()); float angle = 90 - mainWindow->getImageItem()->getAngleToGround(boxImageCentreWithBorder.x(), boxImageCentreWithBorder.y(), 175);// Hoehe 175 cm ist egal, da auf jeder Hoehe gleicher Winkel - //debout << "Bordersize: " << mainWindow->getImageBorderSize() <<endl; - //debout << "Angle: " << angle <<endl; - //debout << "Pixel unter der Camera: " << pixUnderCam.x() << ", " << pixUnderCam.y() << endl; - - //QPointF cmPerPixel = mainWindow->getImageItem()->getCmPerPixel(boxImageCentre.x(), boxImageCentre.y(), 175); // durchschnittsgroesse von 175cm angenommen Vec2F moveDir = boxImageCentreWithBorder-pixUnderCam; moveDir.normalize(); - //debout << "Movedir: " << moveDir <<endl; cv::Point3f p3x1, p3x2; p3x1 = mainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(boxImageCentre.x(),boxImageCentre.y()),175); @@ -246,9 +179,6 @@ Vec2F autoCorrectColorMarker(Vec2F &boxImageCentre, Control *controlWidget) p3x1 = p3x1-p3x2; Vec2F cmPerPixel(p3x1.x, p3x1.y); - //debout << "cmPerPixel: " << p3x1 <<endl; - //debout << "Boximgcentre: " <<boxImageCentreWithBorder.x() <<" "<< boxImageCentreWithBorder.y() <<endl<<endl; - return (0.12*angle/cmPerPixel.length())*moveDir; // Maik Dissertation Seite 138 } @@ -849,13 +779,6 @@ void findColorMarker(cv::Mat &img, QList<TrackPoint> *crossList, Control *contro // run detection cv::Mat binary; - //cv::Mat kernel; -// IplConvKernel* kernel; - -#ifdef TIME_MEASUREMENT - // "==========: " - debout << "start col : " << getElapsedTime() <<endl; -#endif // erzeuge speicherplatz fuer mask // abfrage wird in createMask gemacht @@ -865,19 +788,11 @@ void findColorMarker(cv::Mat &img, QList<TrackPoint> *crossList, Control *contro // color thresholding thresholdHSV(img , binary, param); -#ifdef SHOW_TMP_IMG - namedWindow("image", CV_WINDOW_AUTOSIZE ); // 0 wenn skalierbar sein soll - imshow("image", binary); - waitKey(); -#endif - // close small holes: radius ( hole ) < radius ( close ) if (cmWidget->useClose->isChecked()) { int radius_close = cmWidget->closeRadius->value(); // siehe : http://opencv.willowgarage.com/documentation/c/image_filtering.html#createstructuringelementex -// kernel = cvCreateStructuringElementEx(2*radius_close+1, 2*radius_close+1, radius_close, radius_close, CV_SHAPE_ELLIPSE); -// cvMorphologyEx(binary, binary, NULL, kernel, CV_MOP_CLOSE); cv::morphologyEx(binary,binary,cv::MORPH_OPEN, getStructuringElement( cv::MORPH_ELLIPSE, cv::Size(2*radius_close+1,2*radius_close+1), @@ -887,74 +802,28 @@ void findColorMarker(cv::Mat &img, QList<TrackPoint> *crossList, Control *contro if (cmWidget->useOpen->isChecked()) { int radius_open = cmWidget->openRadius->value(); -// kernel = cvCreateStructuringElementEx(2*radius_open+1, 2*radius_open+1, radius_open, radius_open, CV_SHAPE_ELLIPSE); -// cvMorphologyEx(binary, binary, NULL, kernel, CV_MOP_OPEN); cv::morphologyEx(binary,binary,cv::MORPH_CLOSE, getStructuringElement( cv::MORPH_ELLIPSE, cv::Size(2*radius_open+1,2*radius_open+1), cv::Point(radius_open))); } -#ifdef SHOW_TMP_IMG - imshow("image", binary); - waitKey(); -#endif - -// CvSeq *contour; -// CvSeq *firstContour; std::vector<std::vector<cv::Point> > contours; double area; -// CvMemStorage *storage = cvCreateMemStorage(0); QColor col; -// CvMoments moments; -// double m00, m01, m10; -// int count; cv::RotatedRect box; double ratio; -// CvPoint* pointArray; bool atEdge; -#ifdef TIME_MEASUREMENT - // "==========: " - debout << "vor cont : " << getElapsedTime() << endl; -#endif - -// IplImage *clone = cvCloneImage(binary); // clone, da binary sonst veraendert wird cv::Mat clone = binary.clone();//(cvarrToMat(binary),true); 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!!! - -#ifdef SHOW_TMP_IMG - drawContours(clone,contours,0,CV_RGB(255,255,255)); - imshow("image", clone); - waitKey(); -#endif -// CV_RETR_EXTERNAL gives "outer" contours, so if you have (say) one contour enclosing another (like concentric circles), only the outermost is given. -// CV_RETR_LIST gives all the contours and doesn't even bother calculating the hierarchy -- good if you only want the contours and don't care whether one is nested inside another. -// CV_RETR_CCOMP gives contours and organises them into outer and inner contours. Every contour is either the outline of an object, or the outline of an object inside another object (i.e. hole). The hierarchy is adjusted accordingly. This can be useful if (say) you want to find all holes. -// CV_RETR_TREE calculates the full hierarchy of the contours. So you can say that object1 is nested 4 levels deep within object2 and object3 is also nested 4 levels deep. - -// firstContour = contour; -// cvReleaseImage(&clone); // test each contour while (!contours.empty()) { std::vector<cv::Point> contour = contours.back(); - //count = contour->total; // This is number of point in one contour area = cv::contourArea(contour); -// area = cvContourArea(contour, CV_WHOLE_SEQ); - -//#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 = cvContourArea(contours,CV_WHOLE_SEQ); -//#else -// //else -// contourArea = cvContourArea(contours,CV_WHOLE_SEQ, true); -//#endif - - box = cv::minAreaRect(contour);//cvMinAreaRect2(contour); + box = cv::minAreaRect(contour); if (box.size.height > box.size.width) { @@ -965,75 +834,23 @@ void findColorMarker(cv::Mat &img, QList<TrackPoint> *crossList, Control *contro ratio = box.size.width/box.size.height; } -// debout << box.center.x << " "<< box.center.y <<endl; -// debout << box.size.height << " "<< box.size.width <<endl; -// debout << img->width<< " " << img->height <<endl; -// if ((box.center.x+maxExpansion/2 > img->width-2) || (box.center.x-maxExpansion/2 < 2) || -// (box.center.y+maxExpansion/2 > img->height-2) || (box.center.y-maxExpansion/2 < 2)) -// debout << box.center.x << " "<< box.center.y <<endl; - // contour at border of roi, than neglect because of object going out of region has moving center -// pointArray = (CvPoint*)malloc(contour->total*sizeof(CvPoint)); -// cvCvtSeqToArray(contour, pointArray, CV_WHOLE_SEQ);// Get contour point set. atEdge = false; for(size_t i=0; i<contour.size(); i++) if ((contour.at(i).x <= 1) || (contour.at(i).x >= img.cols-2) || (contour.at(i).y <= 1) || (contour.at(i).y >= img.rows-2)) atEdge = true; -// free(pointArray); - -// cvMoments(contour, &moments); -// //moments.m00; -// m00 = cvGetCentralMoment(&moments, 0, 0); // == area -// m01 = cvGetCentralMoment(&moments, 0, 1); // irgendwie immer 0 -// m10 = cvGetCentralMoment(&moments, 1, 0); // irgendwie immer 0 -// crossList->append(TrackPoint(Vec2F(m10/m00, m01/m00), 100, col)); // 100 beste qualitaet if (!atEdge && area >= cmWidget->minArea->value() && area <= cmWidget->maxArea->value() && ratio <= cmWidget->maxRatio->value()) { // eine mittelung waere ggf sinnvoll, aber am rand aufpassen col.setRgb(getValue(img,myRound(box.center.x),myRound(box.center.y)).rgb()); -// getR(img, myRound(box.center.x), myRound(box.center.y)), -// getG(img, myRound(box.center.x), myRound(box.center.y)), -// getB(img, myRound(box.center.x), myRound(box.center.y))); crossList->append(TrackPoint(Vec2F(box.center.x, box.center.y), 100, Vec2F(box.center.x, box.center.y), col)); // 100 beste qualitaet } // take the next contour contours.pop_back(); -// contour = contour->h_next; } -// if (firstContour) -// cvClearSeq(firstContour); -// cvReleaseMemStorage(&storage); -#ifdef TIME_MEASUREMENT - // "==========: " - debout << "nach cont : " << getElapsedTime() <<endl; -#endif - - -// if (contours.size() == 0) -// return; - -// // go through all the connected components -// assert(hierarchy[0][3] < 0); // first entry on top level (no parent) - -// while (idx >= 0) -// { - -// //mmnt = moments(contours[idx], false); - -// crossList->append(TrackPoint(Vec2F(contours[idx][0].x, contours[idx][0].y), 100, col)); // 100 beste qualitaet -// //crossList->append(TrackPoint(Vec2F(mmnt.m10/mmnt.m00 , mmnt.m01/mmnt.m00), 100, col)); // 100 beste qualitaet -// // save more information about the blob and filter later or -// // filter the blobs by size, shape, ... -// // ... - -// idx = hierarchy[idx][0]; // jump to next contour -// } - - // results - //cout << "Found " << crossList->size() << " features.\n"; } /** @@ -1044,8 +861,6 @@ void findColorMarker(cv::Mat &img, QList<TrackPoint> *crossList, Control *contro */ void detail::findCodeMarker(cv::Mat &img, QList<TrackPoint> *crossList, Control *controlWidget, Vec2F offsetCropRect2Roi /*=(0,0)*/) { -//#if 0 // Maik temporaer, damit es auf dem Mac laeuft - CodeMarkerItem* codeMarkerItem = controlWidget->getMainWindow()->getCodeMarkerItem(); CodeMarkerWidget* codeMarkerWidget = controlWidget->getMainWindow()->getCodeMarkerWidget(); @@ -1069,8 +884,8 @@ void detail::findCodeMarker(cv::Mat &img, QList<TrackPoint> *crossList, Control { if (recoMethod == RecognitionMethod::Code) // for usage of codemarker with CodeMarker-function (-> without MulticolorMarker) { - QRect rect(myRound(mainWindow->getRecoRoiItem()->rect().x()),//+controlWidget->getMainWindow()->getImageBorderSize()), - myRound(mainWindow->getRecoRoiItem()->rect().y()),//+controlWidget->getMainWindow()->getImageBorderSize()), + QRect rect(myRound(mainWindow->getRecoRoiItem()->rect().x()), + myRound(mainWindow->getRecoRoiItem()->rect().y()), myRound(mainWindow->getRecoRoiItem()->rect().width()), myRound(mainWindow->getRecoRoiItem()->rect().height())); QPointF p1 = mainWindow->getImageItem()->getCmPerPixel(rect.x(),rect.y(),controlWidget->mapDefaultHeight->value()), @@ -1125,7 +940,6 @@ void detail::findCodeMarker(cv::Mat &img, QList<TrackPoint> *crossList, Control if(codeMarkerWidget->doCornerRefinement->isChecked()){ detectorParams->cornerRefinementMethod = cv::aruco::CornerRefineMethod::CORNER_REFINE_SUBPIX; } - //detectorParams->cornerRefinementMethod = codeMarkerWidget->doCornerRefinement->isChecked(); detectorParams->cornerRefinementWinSize = codeMarkerWidget->cornerRefinementWinSize->value(); detectorParams->cornerRefinementMaxIterations = codeMarkerWidget->cornerRefinementMaxIterations->value(); detectorParams->cornerRefinementMinAccuracy = codeMarkerWidget->cornerRefinementMinAccuracy->value(); @@ -1142,17 +956,7 @@ void detail::findCodeMarker(cv::Mat &img, QList<TrackPoint> *crossList, Control corners.clear(); rejected.clear(); -#ifdef TIME_MEASUREMENT - // "==========: " - debout << "start detectCodeMarkers : " << getElapsedTime() <<endl; -#endif - - cv::aruco::detectMarkers(img/*copy.clone()*/, dictionary, corners, ids, detectorParams, rejected); - -#ifdef TIME_MEASUREMENT - // "==========: " - debout << "end detectCodeMarkers : " << getElapsedTime() <<endl; -#endif + cv::aruco::detectMarkers(img, dictionary, corners, ids, detectorParams, rejected); codeMarkerItem->addDetectedMarkers(corners,ids, offsetCropRect2Roi); codeMarkerItem->addRejectedMarkers(rejected, offsetCropRect2Roi); @@ -1160,212 +964,54 @@ void detail::findCodeMarker(cv::Mat &img, QList<TrackPoint> *crossList, Control // detected code markers for(size_t i = 0; i<ids.size(); i++) { -// debout << "Detected MarkerID: " << ids.at(i) << " [( " << corners.at(i).at(0).x << "," << corners.at(i).at(0).y << "),( " -// << corners.at(i).at(1).x << "," << corners.at(i).at(1).y << "),( " -// << corners.at(i).at(2).x << "," << corners.at(i).at(2).y << "),( " -// << corners.at(i).at(3).x << "," << corners.at(i).at(3).y << ")]" << endl; - -// if (codeMarkerWidget->showMask->isChecked()) -// { -// detected_points[0] = CvPoint(corners.at(i).at(0).x, corners.at(i).at(0).y); -// detected_points[1] = CvPoint(corners.at(i).at(1).x, corners.at(i).at(1).y); -// detected_points[2] = CvPoint(corners.at(i).at(2).x, corners.at(i).at(2).y); -// detected_points[3] = CvPoint(corners.at(i).at(3).x, corners.at(i).at(3).y); - -// cvFillConvexPoly(binary,detected_points,4,RGB(255,255,255)); -// } - double x = (corners.at(i).at(0).x+corners.at(i).at(1).x+corners.at(i).at(2).x+corners.at(i).at(3).x)*0.25; double y = (corners.at(i).at(0).y+corners.at(i).at(1).y+corners.at(i).at(2).y+corners.at(i).at(3).y)*0.25; crossList->append(TrackPoint(Vec2F(x,y), 100, ids.at(i))); // 100 beste qualitaet } - -#ifdef TIME_MEASUREMENT - // "==========: " - debout << "nach cont : " << getElapsedTime() <<endl; -#endif - -//#endif } void findContourMarker(cv::Mat &img, QList<TrackPoint> *crossList, int markerBrightness, bool ignoreWithoutMarker, bool autoWB, RecognitionMethod recoMethod, float headSize) { int threshold, plus, count; double angle; - //MarkerCasernList markerList; - //MarkerHermesList markerList; MarkerHermesList markerHermesList; MarkerCasernList markerCasernList; MarkerJapanList markerJapanList(headSize); - //MarkerColorList markerList; -// void * markerList; - // 0 == Kaserne, 1 == Hermes, 2 == Ohne -// if (recoMethod == 0) -// markerList = (MarkerHermesList *) new MarkerHermesList; -// else if (recoMethod == 1) -// markerList = (MarkerHermesList *) new MarkerHermesList; -// else -// debout << "Error: this should never happen!" <<endl; cv::Size sz = cv::Size(img.cols & -2, img.rows & -2); cv::Mat gray = cv::Mat(sz,CV_8UC1); cv::Mat tgray; cv::Mat grayFix; -// IplImage *gray = cvCreateImage(sz, 8, 1); -// IplImage *tgray; -// IplImage *grayFix; -// CvPoint* PointArray; std::vector<std::vector<cv::Point> > contours; -// CvSeq *contours; -// CvSeq *firstContour; - -// Mat PointArray2D32f; cv::RotatedRect box; - //CvBox2D box; -// CvPoint center; int expansion; double contourArea; - //debout << "MemStorage" << endl; -// CvMemStorage *storage = cvCreateMemStorage(0); - bool added = false; - -#ifdef WITH_RECT - double area, length; - CvSeq* result; - Vec2F v[4]; -#endif - - // // down-scale and upscale the image to filter out the noise - // cvPyrDown(timg, pyr, 7); // 7 =? CV_GAUSSIAN_5x5 - // cvPyrUp(pyr, timg, 7); + if (img.channels() == 3) { tgray = cv::Mat(sz,CV_8UC1);//cvCreateImage(sz, 8, 1); - // folgende Zeilen erledigen das gleiche wie cvCvtColor(img, tgray, CV_RGB2GRAY); - // noetig gewesen, da opencv Probleme machte - //Y=0.299*R + 0.587*G + 0.114*B; - // int x,y; - // char *data = img->imageData; - // char *greyData = tgray->imageData; - // char *yData = data; - // char *yGreyData = greyData; - // for (y = 0; y < img->height; y++) - // { - // for (x = 0; x < img->width; x++) - // *(greyData) = 0.299*data[0]+0.587*data[1]+0.114*data[2]; - // data = (yData += img->widthStep); // because sometimes widthStep != width - // greyData = (yGreyData += tgray->widthStep); // because sometimes widthStep != width - // - // } cv::cvtColor(img,tgray,cv::COLOR_RGB2GRAY); -// cvCvtColor(img, tgray, CV_RGB2GRAY); } - //debout << "Threshold" << endl; - -#ifdef SHOW_TMP_IMG -namedWindow("img", CV_WINDOW_AUTOSIZE); // 0 wenn skalierbar sein soll -//IplImage *tmpAusgabe = cvCreateImage(cvGetSize(img), 8, 3); -//cvCvtColor(img ,tmpAusgabe, CV_GRAY2RGB); - Mat tmpAusgabe = img.clone(); // nur grauweert, wenn grauwertbild!!! - Mat tmpAusgabe2 = img.clone(); // nur grauweert, wenn grauwertbild!!! - - imShow("img", img); - waitKey(); -#endif - // try several threshold levels plus = (250-72)/10; // andere richtung der schwellwertanpassung koennte andere ergebnisse leifern // cw->markerBrightness->value()==markerBrightness hat default 50 for (threshold = 60+markerBrightness; threshold < 251 ; threshold += plus) //70..255, 20 //155+cw->temp2->value() { -#ifdef TIME_MEASUREMENT - // "==========: " - debout << "vor hellig: " << getElapsedTime() <<endl; -#endif - - //// hack: use Canny instead of zero threshold level. - //// Canny helps to catch squares with gradient shading - //if(l == 0) - //{ - // // apply Canny. Take the upper threshold from slider - // // and set the lower to 0 (which forces edges merging) - // cvCanny(tgray, gray, 0, thresh, 5); - // // dilate canny output to remove potential - // // holes between edge segments - // cvDilate(gray, gray, 0, 1); - //} - // cvCanny(tgray, gray, 4000, 2500, 5); guter kantenoperator aber keine geschlossene contour if (img.channels() == 3) { - // folgende Zeilen erledigen das gleiche wie cvThreshold(tgray, gray, threshold, 255, CV_THRESH_BINARY); - // noetig gewesen, da opencv Probleme machte - // int x, y; - // char *data = gray->imageData; - // char *greyData = tgray->imageData; - // char *yData = data; - // char *yGreyData = greyData; - // for (y = 0; y < gray->height; y++) - // { - // for (x = 0; x < gray->width; x++) - // { - // if (*(greyData) > threshold) - // *(data) = 255; - // else - // *(data) = 0; - // } - // 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); -// 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); else debout << "Error: Wrong number of channels: " << img.channels() <<std::endl; - grayFix = gray.clone();// = cvCloneImage(gray); // make a copy - + grayFix = gray.clone(); - //cvShowImage("img", grayFix); - //cvWaitKey(); -#ifdef TIME_MEASUREMENT - // "==========: " - debout << "vor iso: " << getElapsedTime() <<endl; -#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); -// cvFindContours(gray, storage, &firstContour, sizeof(CvContour), -// CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE); // gray wird auch veraendert!!! -// contours = firstContour; - -// int count_contours = 0; - -// while(contours){ - -// debout << "contour[" << ++count_contours << "]: " << contours->total << endl; -// contours = contours->h_next; -// } -// debout << "firstContour" << endl; -// contours = firstContour; -//#elif CV_MAJOR_VERSION == 3 - //Mat threshold_output; - //vector<Vec4i> hierarchy; - //threshold(cvarrToMat(tgray), threshold_output, threshold, 255, THRESH_BINARY); - //vector<vector<Point> > v_contours; - - //findContours(cvarrToMat(gray), contours,/* hierarchy,*/ CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0,0) ); -//#endif -//IplImage *tmpAusgabe = cvCloneImage(img); // make a copy -// char outstr[256]; - -#ifdef TIME_MEASUREMENT - // "==========: " - debout << "nach iso: " << getElapsedTime() <<endl; -#endif // test each contour while (!contours.empty()) @@ -1377,205 +1023,41 @@ namedWindow("img", CV_WINDOW_AUTOSIZE); // 0 wenn skalierbar sein soll // um kreise zu suchen koennte auch cvHoughCircles genutzt werden count = contour.size(); -// count = contours->total; // This is number point in contour // man koennte das Seitenverhaeltnis, contour-gesamtlaenge vorher ueberpruefen, um cont rauszuwerfen - //for (int iii=0; iii<contours->total; ++iii) - //{ - // CvPoint* ppp = (CvPoint*) cvGetSeqElem(contours, iii); - // printf("(%d,%d)\n", ppp->x, ppp->y); - //} - //printf("\n"); - //debout << "count: " << count << endl; + if (count > 5) { -#ifdef SHOW_TMP_IMG -// in rot contouren in eine drehrichtung, in gruen andere -cvDrawContours(tmpAusgabe,contours,CV_RGB(255,0,0),CV_RGB(0,255,0),0,1,8,cvPoint(0,0)); -cvShowImage("img", tmpAusgabe); -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 - - -// PointArray2D32f.create(count,2, CV_32F); -// //Mat(cvarrToMat(contours)).convertTo(PointArray2D32f.at(i), CV_32F); -// // Convert CvPoint set to Mat set. -// for(i=0; i<count; i++) -// { -// //debout << "in for" << endl; -// //debout << "(" << i << ") " << PointArray[i].x << ", " << PointArray[i].y << endl; -// PointArray2D32f.at<float>(i,0) = (float)PointArray[i].x; -// PointArray2D32f.at<float>(i,1) = (float)PointArray[i].y; -// //debout << "[" << i << "] " << PointArray2D32f.at<double>(i,0) << ", " << PointArray2D32f.at<double>(i,1) << endl; -// } - //debout << "FitEllipse" << endl; // Fits ellipse to current contour. - //debout << "count: " << count << endl; cv::Mat pointsf; cv::Mat(contour).convertTo(pointsf, CV_32F); box = fitEllipse(pointsf); -// box = fitEllipse(PointArray2D32f);//, count, &box); - - // neuer: - //// Fits ellipse to current contour. - //CvBox2D box = cvFitEllipse2(PointArray2D32f); - //debout << "expansion" << endl; - //ellipses are not allowed near border !!! expansion = box.size.width > box.size.height ? myRound(box.size.width*0.5) : myRound(box.size.height*0.5); - //debout << "if" << endl; + if (box.center.x-expansion > ELLIPSE_DISTANCE_TO_BORDER && box.center.x+expansion < gray.cols-ELLIPSE_DISTANCE_TO_BORDER && box.center.y-expansion > ELLIPSE_DISTANCE_TO_BORDER && box.center.y+expansion < gray.rows-ELLIPSE_DISTANCE_TO_BORDER) { - // debout << "in if" << endl; -// // Convert ellipse data from float to integer representation. -// center.x = myRound(box.center.x); -// center.y = myRound(box.center.y); - //box.angle = -box.angle; // war wohl in aelteren opencv versionen noetig - angle = (box.angle)/180.*PI; if (box.size.width<box.size.height) { angle -= PI / 2; } - //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!!!! - //else contourArea = cv::contourArea(contour,true); -// contourArea = cvContourArea(contours,CV_WHOLE_SEQ, true); - //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; - //debout << e.area() << " " << fabs(contourArea)<< endl; - //debout << "MyEllipse" << endl; + //contourArea koennte mit MyEllipse.area() verglichen werden und bei grossen abweichungen verworfen werden!!! MyEllipse e(box.center.x, box.center.y, box.size.width*0.5, box.size.height*0.5, angle); if (recoMethod == RecognitionMethod::Casern) // Casern - added = markerCasernList.mayAddEllipse(grayFix, e, (contourArea > 0)); + markerCasernList.mayAddEllipse(grayFix, e, (contourArea > 0)); else if (recoMethod == RecognitionMethod::Hermes) // Hermes - added = markerHermesList.mayAddEllipse(grayFix, e, (contourArea > 0)); + markerHermesList.mayAddEllipse(grayFix, e, (contourArea > 0)); else if (recoMethod == RecognitionMethod::Japan) // Japan - added = markerJapanList.mayAddEllipse(grayFix, e, (contourArea > 0)); - - if (added) -{ -// debout << cvContourArea(contours,CV_WHOLE_SEQ) << endl; // PointArray gerichteter Flaecheninhalt von const CvArr* - -#ifdef SHOW_TMP_IMG -Size sizeTmp; -Point ctr; -sizeTmp.width = myRound(box.size.width*0.5); -sizeTmp.height = myRound(box.size.height*0.5); -ctr.x = myRound(box.center.x); -ctr.y = myRound(box.center.y); - -// MyEllipse e(box.center.x, box.center.y, box.size.width*0.5, box.size.height*0.5, angle); -// int cx = myRound(e.center().x()); -// int cy = myRound(e.center().y()); - -// // debout << "****" << getR(img, 0, 0) << " " << getG(img, 0, 0) << " " << getB(img, 0, 0) << endl; -// // debout << cvGetDims(img)<<endl; -// // debout << ch<<endl; -// // debout << img->width<<endl; -// // debout << img->widthStep<<endl; -// // debout << cvGet2D(img, cx, cy).val[2] << " " << cvGet2D(img, cx, cy).val[1] << " " << cvGet2D(img, cx, cy).val[0] << endl; -// // QRgb col = qRgb(((int)(*(data+ch*(cx+cy*iw)+2)))+127, ((int)(*(data+ch*(cx+cy*iw)+1)))+127, ((int)(*(data+ch*(cx+cy*iw))))+127); -// QRgb col = qRgb(getR(img, cx, cy), getG(img, cx, cy), getB(img, cx, cy)); -// QString s("#%1%2%3"); -// s = s.arg(qRed(col), 2, 16, QChar('0')).arg(qGreen(col), 2, 16, QChar('0')).arg(qBlue(col), 2, 16, QChar('0')); -// debout << cx+1 << " " << cy+1 << ": "; -// cout << s <<endl; -// QColor col2 = QColor(getR(img, cx, cy), getG(img, cx, cy), getB(img, cx, cy)); -// // hue: 0..359, -// debout << "Farbe: " << col2.hue() << ", Saettigung: " << col2.saturation() << ", Helligkeit: " << col2.value() << endl; -// // debout << cx << " " << cy+1 << ": "; -// // cout << (int)*(data+ch*(cx+cy*iw-1)+2)+127 << " " << (int)*(data+ch*(cx+cy*iw-1)+1)+127 << " " << (int)*(data+ch*(cx+cy*iw-1))+127 << endl; -// // debout << cx+1 << " " << cy+1 << ": "; -// // cout << (int)*(data+ch*(cx+cy*iw)+2)+127 << " " << (int)*(data+ch*(cx+cy*iw)+1)+127 << " " << (int)*(data+ch*(cx+cy*iw))+127 << endl; -// // debout << cx+2 << " " << cy+1 << ": "; -// // cout << (int)*(data+ch*(cx+cy*iw+1)+2)+127 << " " << (int)*(data+ch*(cx+cy*iw+1)+1)+127 << " " << (int)*(data+ch*(cx+cy*iw+1))+127 << endl; - - -if (contourArea > 0) - ellipse(tmpAusgabe2, ctr, sizeTmp, box.angle, 0, 360, CV_RGB(0, 255, 0), 1, CV_AA, 0); -else - ellipse(tmpAusgabe2, ctr, sizeTmp, box.angle, 0, 360, CV_RGB(255, 0, 0), 1, CV_AA, 0); -namedWindow("img", CV_WINDOW_AUTOSIZE); // 0 wenn skalierbar sein soll -imShow("img", tmpAusgabe); -namedWindow("img2", CV_WINDOW_AUTOSIZE); // 0 wenn skalierbar sein soll -imShow("img2", tmpAusgabe2); -//static QLabel imgLabel; -//showImg(& imgLabel, tmpAusgabe2); -//cvWaitKey(0); // zahl statt null, wenn nach bestimmter zeit weitergegangen werden soll -#endif -} - + markerJapanList.mayAddEllipse(grayFix, e, (contourArea > 0)); } - //debout << "FreePointArray" << endl; -// free(PointArray); - -// PointArray2D32f.release(); } - //debout << "Free PointArray" << endl; - -#ifdef WITH_RECT - // approximate contour with accuracy proportional - // to the contour perimeter - approxPolyDP(Mat(contour, contour, 0.08*cv::arcLength(contour,true), false); -// result = cvApproxPoly(contours.at(k), sizeof(CvContour), storage, -// CV_POLY_APPROX_DP, 0.08*cvContourPerimeter(contours), 0); //cvContourPerimeter(contours)*0.02 - // square contours should have 4 vertices after approximation - // relatively large area (to filter out noisy contours) - // and be convex. - // Note: absolute value of an area is used because - // area may be positive or negative - in accordance with the - // contour orientation - area = cv::contourArea(contour); - length = cv::arcLength(result,false); - // cvContourPerimeter(contours) ist immer etwas groesser als length - warum? - if(contour.size() == 4 &&//&&result->total < 11 && - area > 1500 && area < 10000 && //cvCheckContourConvexity(result) - length >150 && length < 500) - { - for(i = 0; i < 4; ++i) - v[i] = (Vec2F)(CvPoint*) cvGetSeqElem(contours.at(k), i); - if (recoMethod == 0) // Casern - markerCasernList.mayAddQuadrangle(v); - else if (recoMethod == 1) // Hermes - markerHermesList.mayAddQuadrangle(v); - else if (recoMethod == 4) // Japan - markerJapanList.mayAddQuadrangle(v); - - } -#endif - //debout << "total number of contours: " << contours->total << endl; - // take the next contour -// contours = contours->h_next; contours.pop_back(); } - // debout << "after contours" << endl; - -//cvNamedWindow("img", CV_WINDOW_AUTOSIZE ); // 0 wenn skalierbar sein soll -//cvShowImage("img", tmpAusgabe); -// sprintf(outstr,"c:/%d.png",threshold); -// cvSaveImage(outstr, tmpAusgabe); -//cvWaitKey( 0 ); // zahl statt null, wenn nach bestimmter zeit weitergegangen werden soll - - // nicht noetig, aber so kann der neu erzeugte speicherplatz reduziert werden - // freigabe des speicherplatz erst bei cvClearMemStorage(storage) -// if (firstContour) -// cvClearSeq(firstContour); // not free only available for next push -// cvReleaseImage(&grayFix); } -#ifdef TIME_MEASUREMENT - // "==========: " - debout << "nach ellip: " << getElapsedTime() <<endl; -#endif - - //cvReleaseMemStorage() if (recoMethod == RecognitionMethod::Casern) // Casern { markerCasernList.organize(img, autoWB); @@ -1591,24 +1073,6 @@ imShow("img2", tmpAusgabe2); markerJapanList.organize(img, autoWB); markerJapanList.toCrossList(crossList, ignoreWithoutMarker); } -#ifdef TIME_MEASUREMENT - // "==========: " - debout << "nach ident: " << getElapsedTime() <<endl; -#endif - -#ifdef SHOW_TMP_IMG -//markerList.draw(tmpAusgabe); //diese zeile zeichnet alle marker, nun aber in trackeritem.cpp -//cvReleaseImage(&tmpAusgabe); -//cvReleaseImage(&tmpAusgabe2); -#endif - - // release all the temporary images -// cvReleaseImage(&gray); -// if (img->nChannels == 3) -// cvReleaseImage(&tgray); - -// cvReleaseMemStorage(&storage); // stand vorher in uebergeordneter Funktion -// //cvClearMemStorage(storage); // gibt nicht speicher an bs frei, sondern nur fuer neue sequenzen } @@ -1631,8 +1095,6 @@ void getMarkerPos(cv::Mat &img, QRect &roi, QList<TrackPoint> *crossList, Contro cv::Mat tImg; cv::Rect rect; - //debout << "recoMethod: " << recoMethod << endl; -// tImg = getRoi(img, roi, rect, !((recoMethod == 3)||(recoMethod == 5)||(recoMethod == 6))); tImg = getRoi(img, roi, rect, !((recoMethod == RecognitionMethod::Color) || (recoMethod == RecognitionMethod::MultiColor) || (recoMethod == RecognitionMethod::Code))); if (tImg.empty()) @@ -1640,7 +1102,6 @@ void getMarkerPos(cv::Mat &img, QRect &roi, QList<TrackPoint> *crossList, Contro // offset of rect Vec2F v(rect.x-borderSize, rect.y-borderSize); - //debout << "method: " << recoMethod << endl; if (recoMethod == RecognitionMethod::MultiColor) findMultiColorMarker(tImg, crossList, controlWidget, ignoreWithoutMarker, v); else if (recoMethod == RecognitionMethod::Color) @@ -1649,8 +1110,6 @@ void getMarkerPos(cv::Mat &img, QRect &roi, QList<TrackPoint> *crossList, Contro findCodeMarker(tImg, crossList, controlWidget); else findContourMarker(tImg, crossList, markerBrightness, ignoreWithoutMarker, autoWB, recoMethod, controlWidget->getMainWindow()->getHeadSize()); - //debout << "releaseImage" << endl; -// cvReleaseImage(&tImg); //war: cvFree(&tImg); // war: cvFree(&header); // (void**) only header // must be set because else hovermoveevent of recognitionRec moves also the colorMaskItem controlWidget->getMainWindow()->getColorMarkerItem()->setRect(v); @@ -1676,67 +1135,6 @@ void getMarkerPos(cv::Mat &img, QRect &roi, QList<TrackPoint> *crossList, Contro } } } - - - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // rauschen durch median-filter verringern - // subtract background - bringt bei den aufnahmen wenig - //farbwerte ausblenden (schwarz/rot?), da weisse pappe gesucht und sonst in grauwert knallrot ueberbewerttet - // segmentation - // floodfill -> minarea rect um pappe zu finden - // laplace -> fitellipse (auch fuer ohne marker) - // tracking: lkdemo, motemp, - // matchcontours matchtemplate matchshapes cvcamshift cvkalman (unter estimators) - // squere.exe - // motion templates - //optical flow - //back projection sagt voraus, wie das naechste bild aussehen wird - // richtige contour in graubild waere schoener als bi-bild, da bessere angleichung - - // color mapping - tracking nutzen und in allen bildern nach farbe suchen - addieren und durchschnitt? - - // wenn keine marker gefunden wurden, sollte ellipsenmitte genommen werden aber als schlechter bewertet werden - - //aequidensiten 2. ordnung (s.409) interessant - //cvAdaptiveThreshold nicht so interessant, da gerad enur extrme gesucht und nicht lokale kleinere aenderungen - //versch algorithmen zur auswahl stellen, die kreuz finden - - // die untere schwelle fuer threshold um 72 einstellbat machen !!!!!!!!!!!!!!!!!!!! - - // farben herausfiltern: wenn kanaele sich stark unterscheiden, dann pixel schwarz, wenn umgebung dunkel und - // weiss wenn umgebung hell - - // suchen vom KREUZ: - // MatchTemplate - // MatchShapes - - // int i, bin_w; - // float max_value = 0; - // static IplImage *hist_image = 0; - // CvHistogram *hist; - // int hist_size = 64; - // float range_0[]={0,256}; - // float* ranges[] = { range_0 }; - - // cvReleaseHist(&hist); // vom vorherigen lauf - // hist_image = cvCreateImage(cvSize(320,200), 8, 1); - // hist = cvCreateHist(1, &hist_size, CV_HIST_ARRAY, ranges, 1); - // cvNamedWindow("histogram", 0); - // hist = cvCreateHist(1, &hist_size, CV_HIST_ARRAY, ranges, 1); - // cvCalcHist(&img, hist, 0, NULL); - // cvGetMinMaxHistValue(hist, 0, &max_value, 0, 0); - // cvScale(hist->bins, hist->bins, ((double)hist_image->height)/max_value, 0); - // /*cvNormalizeHist(hist, 1000);*/ - - // cvSet(hist_image, cvScalarAll(255), 0); - // bin_w = myRound((double)hist_image->width/hist_size); - - // autoStart" value="1"for(i = 0; i < hist_size; i++) - // cvRectangle(hist_image, cvPoint(i*bin_w, hist_image->height), - // cvPoint((i+1)*bin_w, hist_image->height - myRound(cvGetReal1D(hist->bins,i))), - // cvScalarAll(0), -1, 8, 0); - - // cvShowImage("histogram", hist_image); } @@ -1773,5 +1171,4 @@ cv::Ptr<cv::aruco::Dictionary> detail::getDictMip36h12() return dictionary; } - } // namespace reco diff --git a/src/recognitionRoiItem.cpp b/src/recognitionRoiItem.cpp index 2b26cd364..d4c38c47a 100644 --- a/src/recognitionRoiItem.cpp +++ b/src/recognitionRoiItem.cpp @@ -36,38 +36,12 @@ RecognitionRoiItem::RecognitionRoiItem(QWidget *wParent, QGraphicsItem *parent) setAcceptHoverEvents(true); setFlags(ItemIsMovable); // default in control hide(); // default in control - // setEnabled(false); // all mouse events connot access this item, but it will be seen } -// QRectF RecognitionRoiItem::boundingRect() const -// { -// // QRectF rect = QGraphicsRectItem::boundingRect(); -// // debout << rect.x() << " " << rect.y() << " " << rect.width() << " " << rect.height() <<endl; -// return QGraphicsRectItem::boundingRect(); -// } -// // 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, -// // aber beim verkleinern des scrollbereichs nur der teil von coord neu gezeichnet -// QRectF RecognitionRoiItem::boundingRect() const -// { -// // bounding box wird in lokalen koordinaten angegeben!!! (+-10 wegen zahl "1") -// if (mControlWidget->getCalibCoordShow()) -// return QRectF(-110., -110., 220., 220.); -// else -// return QRectF(0., 0., 0., 0.); - -// // sicher ware diese boundingbox, da alles -// // return QRectF(xMin, yMin, xMax-xMin, yMax-yMin); -// // eigentlich muesste folgende Zeile reichen, aber beim ranzoomen verschwindet dann koord.sys. -// // return QRectF(mControlWidget->getCalibCoordTransX()/10.-scale, mControlWidget->getCalibCoordTransY()/10.-scale, 2*scale, 2*scale); -// } - void RecognitionRoiItem::mousePressEvent(QGraphicsSceneMouseEvent * event) { if (!mControlWidget->getRecoRoiFix()) { - //mPressRect = rect(); mPressRect = QRect(myRound(rect().left()), myRound(rect().top()), myRound(rect().width()), myRound(rect().height())); mPressPos = event->pos(); if ((event->pos()).x() < DISTANCE_TO_BORDER+mPressRect.x()) @@ -141,7 +115,6 @@ void RecognitionRoiItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) if (!mControlWidget->getRecoRoiFix()) { QImage *img = mMainWindow->getImage(); - //QPointF diff = event->pos()-mPressPos; QPoint diff = QPoint(myRound((event->pos()-mPressPos).x()), myRound((event->pos()-mPressPos).y())); // raender des bildes nicht ueberscheiten // swappen des rechtecks vermeiden, damit keine negativen width... @@ -201,19 +174,6 @@ void RecognitionRoiItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) QGraphicsRectItem::mouseMoveEvent(event); } -// // waere noetig, da sonst beim ersten pixel, wenn man objekt betritt, der cursor noch nicht richtig ist -// void RecognitionRoiItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -// { -// hoverMoveEvent(event); -// QGraphicsRectItem::hoverEnterEvent(event); -// } -// void RecognitionRoiItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -// { -// //hoverMoveEvent(event); -// setCursor(Qt::CrossCursor); -// QGraphicsRectItem::hoverLeaveEvent(event); -// } - // event, of moving mouse void RecognitionRoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { @@ -229,7 +189,6 @@ void RecognitionRoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) if (!mControlWidget->getRecoRoiFix()) { - //QRectF r = rect(); QRect r = QRect(myRound(rect().left()), myRound(rect().top()), myRound(rect().width()), myRound(rect().height())); if ((event->pos()).x() < DISTANCE_TO_BORDER+r.x()) { @@ -268,9 +227,9 @@ void RecognitionRoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) void RecognitionRoiItem::checkRect() { cv::Mat img = mMainWindow->getImageFiltered(); - // nicht QImage *img = mMainWindow->getImage(); da groesse noch nicht angepasst if (!img.empty()) { + // not QImage *img = mMainWindow->getImage(); as size is not adapted yet QRect r = QRect(myRound(rect().left()), myRound(rect().top()), myRound(rect().width()), myRound(rect().height())); if (r.x() > img.cols-mMainWindow->getImageBorderSize()-MIN_SIZE || r.y() > img.rows-mMainWindow->getImageBorderSize()-MIN_SIZE || diff --git a/src/stereoContext.cpp b/src/stereoContext.cpp index e4da4c02e..0d7a09c58 100644 --- a/src/stereoContext.cpp +++ b/src/stereoContext.cpp @@ -50,8 +50,6 @@ using namespace::cv; -//#define TIME_MEASUREMENT - pet::StereoContext::StereoContext(Petrack* main) { mMain = main; @@ -103,7 +101,6 @@ pet::StereoContext::StereoContext(Petrack* main) calFp.open(QIODevice::WriteOnly); calFp.write(calFpInt.readAll()); calFp.close(); - //debout << QFile::copy(":/calibCam1", calFile) <<endl; if (!QFile::exists(calFile)) { debout << "Error: Calibration file "<< calFile <<" could not be created!" << std::endl; @@ -174,21 +171,6 @@ pet::StereoContext::StereoContext(Petrack* main) #endif mBMdisparity16 = NULL; #endif -// unsigned char value; -// triclopsGetSurfaceValidationMapping(mTriclopsContext, &value); -// debout << (int) value <<endl; -// triclopsGetBackForthValidationMapping(mTriclopsContext, &value); -// debout << (int) value <<endl; - -// int nrows, ncols; -// triclopsError = triclopsGetResolution(mTriclopsContext, &nrows, &ncols); -// if (triclopsError != TriclopsErrorOk) -// debout << triclopsErrorToString(triclopsError) << endl; -// debout << nrows << ncols <<endl; - -// float base; -// triclopsGetBaseline(mTriclopsContext, &base); -// debout << base<<endl; mPointCloud = nullptr; } @@ -199,7 +181,6 @@ pet::StereoContext::~StereoContext() if (mTriclopsContext) triclopsDestroyContext(mTriclopsContext); #endif - //delete [] m_pTempBuffer; } #ifndef STEREO_DISABLED @@ -997,7 +978,7 @@ IplImage *pet::StereoContext::getDisparity(bool *dispNew) if (dispNew != NULL) *dispNew = true; - mMain->getStereoItem()->setDispNew(true); // ->updateData(); // das zu zeichnende Bild neu berechnen + mMain->getStereoItem()->setDispNew(true); // das zu zeichnende Bild neu berechnen diff --git a/src/stereoItem.cpp b/src/stereoItem.cpp index 4a851c9e5..e398e3751 100644 --- a/src/stereoItem.cpp +++ b/src/stereoItem.cpp @@ -37,10 +37,6 @@ StereoItem::StereoItem(QWidget *wParent, QGraphicsItem * parent) mImage = nullptr; mDispNew = true; setAcceptHoverEvents(true); - - // setEnabled(false); // all mouse events connot access this item, but it will be seen - // einzig move koennte interessant sein, um grid zu verschieben?! -// setAcceptsHoverEvents(true); } @@ -56,46 +52,13 @@ QRectF StereoItem::boundingRect() const { if (mMainWindow->getImage()) return QRectF(-mMainWindow->getImageBorderSize(), -mMainWindow->getImageBorderSize(), mMainWindow->getImage()->width(), mMainWindow->getImage()->height()); -// return QRectF(-mMainWindow->getImageBorderSize(), -mMainWindow->getImageBorderSize(), mImage->width(), mImage->height()); else return QRectF(0, 0, 0, 0); -// // bounding box wird in lokalen koordinaten angegeben!!! (+-10 wegen zahl "1") -// if (mControlWidget->getCalibCoordShow()) -// return QRectF(-110., -110., 220., 220.); -// else ; - -// return QRectF(0., 0., 0., 0.); - -// // sicher ware diese boundingbox, da alles -// // return QRectF(xMin, yMin, xMax-xMin, yMax-yMin); -// // eigentlich muesste folgende Zeile reichen, aber beim ranzoomen verschwindet dann koord.sys. -// // return QRectF(mControlWidget->getCalibCoordTransX()/10.-scale, mControlWidget->getCalibCoordTransY()/10.-scale, 2*scale, 2*scale); } // event, of moving mouse while button is pressed void StereoItem::mouseMoveEvent(QGraphicsSceneMouseEvent */*event*/) { -// if (!mControlWidget->getCalibCoordFix()) -// { -// setCursor(Qt::ClosedHandCursor); -// QPointF diff = event->scenePos()-event->lastScenePos(); //screenPos()-buttonDownScreenPos(Qt::RightButton) also interesting -// if (event->buttons() == Qt::RightButton) // event->button() doesnt work -// { -// mControlWidget->setCalibCoordRotate(mControlWidget->getCalibCoordRotate()+(int)(3.*(diff.x()+diff.y()))); //10* nicht noetig, da eh nur relativ -// //cout << diff.x()-diff.y() <<endl; //globalPos() -// } -// else if (event->buttons() == Qt::LeftButton) -// { -// mControlWidget->setCalibCoordTransX(mControlWidget->getCalibCoordTransX()+(int)(10.*diff.x())); -// mControlWidget->setCalibCoordTransY(mControlWidget->getCalibCoordTransY()+(int)(10.*diff.y())); -// } -// else if (event->buttons() == Qt::MidButton) -// { -// mControlWidget->setCalibCoordScale(mControlWidget->getCalibCoordScale()+(int)(10.*(diff.x()-diff.y()))); -// } -// } -// else -// QGraphicsItem::mouseMoveEvent(event); // drag mach ich selber } // event, of moving mouse @@ -128,21 +91,7 @@ void StereoItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) #endif } - // ACHTUNG: border nicht beachtet!!! - //QPointF pos = event->scenePos(); - //pos.setX(pos.x() + mMainWindow->getImageBorderSize()); - //pos.setY(pos.y() + mMainWindow->getImageBorderSize()); - mMainWindow->setMousePosOnImage(event->scenePos()); //pos); - -// if (pos.x() >=0 && pos.x() <= mMainWindow->getImage()->width() && pos.y() >=0 && pos.y() <= mMainWindow->getImage()->height()) -// mMainWindow->setMousePosOnImage(pos); -// -// if (!mControlWidget->getCalibCoordFix()) -// setCursor(Qt::OpenHandCursor); -// else -// setCursor(Qt::CrossCursor); -// - + mMainWindow->setMousePosOnImage(event->scenePos()); QGraphicsItem::hoverMoveEvent(event); } diff --git a/src/swapFilter.cpp b/src/swapFilter.cpp index f1c655c36..31987087a 100644 --- a/src/swapFilter.cpp +++ b/src/swapFilter.cpp @@ -35,111 +35,13 @@ SwapFilter::SwapFilter() mSwapHorizontally.setFilter(this); setOnCopy(true); - // setOnCopy(false); } cv::Mat SwapFilter::act(cv::Mat &img, cv::Mat &res) { - -// Mat img = cvarrToMat(imgIpl), -// res = cvarrToMat(resIpl); - -// bool useMat = true; - bool sV = (bool) mSwapVertically.getValue(); bool sH = (bool) mSwapHorizontally.getValue(); -// if (!useMat) -// { -// int x, y, xStep, yStep; - -// CvSize sz = cvGetSize(imgIpl); - -// if (imgIpl != resIpl) -// cvReleaseImage(&resIpl); -// resIpl = cvCreateImage(sz, 8, imgIpl->nChannels); // war 8, 3 -// // resIpl->origin = imgIpl->origin; // because 1 - bottom-left origin (Windows bitmaps style) is not default!!! -// setResStored(true); -// // Pointer to the data information in the IplImage -// char *dataIn = imgIpl->imageData - 1; -// char *dataOut; -// // set poiner to value before array, because ++i is more effective than i++ -// if (sH) -// { -// dataOut = resIpl->imageData + resIpl->nChannels * resIpl->width; -// xStep = - imgIpl->nChannels; -// } -// else -// { -// dataOut = resIpl->imageData - resIpl->nChannels; -// xStep = imgIpl->nChannels; -// } -// if (sV) -// { -// dataOut += (resIpl->height-1) * resIpl->widthStep; -// yStep = -resIpl->widthStep; -// } -// else -// { -// yStep = resIpl->widthStep; -// } -// char *yDataIn=dataIn, *yDataOut=dataOut; - -// // char *dataIn; -// // char *dataOut = mImage->imageData - 1; -// // int lineLen = tempImg->width*tempImg->nChannels; - -// // for (int i = mImage->height-1; i >= 0 ; --i) -// // { -// // dataIn = tempImg->imageData + i*lineLen - 1; // to swap data we go from bottom to top -// // for (int j = 0; j < mImage->width; ++j) -// // { -// // //cout << i << " " << j << endl; -// // *(++dataOut) = *(++dataIn); -// // *(++dataOut) = *(++dataIn); -// // *(++dataOut) = *(++dataIn); -// // } -// // } - - -// if (imgIpl->nChannels == 1) -// { -// for (y = 0; y < resIpl->height; ++y) -// { -// for (x = 0; x < resIpl->width; ++x) -// { -// dataOut+=xStep; -// *(dataOut) = *(++dataIn); -// } -// // we need this, because sometimes width != widthstep eg for width%4 != 0 -// dataIn = (yDataIn+=imgIpl->widthStep); -// dataOut = yDataOut+=yStep; -// } -// } -// else if (imgIpl->nChannels == 3) -// { -// for (y = 0; y < resIpl->height; ++y) -// { -// for (x = 0; x < resIpl->width; ++x) -// { -// dataOut+=xStep; -// *(dataOut) = *(++dataIn); -// *(dataOut+1) = *(++dataIn); -// *(dataOut+2) = *(++dataIn); -// } -// // we need this, because sometimes width != widthstep eg for width%4 != 0 -// dataIn = (yDataIn+=imgIpl->widthStep); -// dataOut = yDataOut+=yStep; -// } -// } -// else -// { -// debout << "Error: Channel different than 1 and 3 should not be allowed!" << endl; -// } -// }else -// { - - if (sV && sH) cv::flip(img, res, -1); // both else if (sV) diff --git a/src/tracker.cpp b/src/tracker.cpp index 2b142610e..9da77f757 100644 --- a/src/tracker.cpp +++ b/src/tracker.cpp @@ -33,10 +33,6 @@ #include "pMessageBox.h" #include "recognitionRoiItem.h" -// Measure Time spending in functions -//#define TIME_MEASUREMENT - - #define MIN_WIN_SIZE 3. /** @@ -95,15 +91,6 @@ TrackPoint::TrackPoint(const Vec2F &p, int qual, const Vec2F &colPoint, const QC { } -// const TrackPoint& TrackPoint::operator=(const TrackPoint& tp) -// { -// Vec2F::operator=(tp); -// mQual = tp.qual(); -// mColPoint = tp.colPoint(); -// mCol = tp.color(); -// return *this; -// } - const TrackPoint& TrackPoint::operator=(const Vec2F& v) { Vec2F::operator=(v); @@ -136,17 +123,6 @@ TrackPerson::TrackPerson() mColCount(0) { } -// TrackPerson::TrackPerson(int nr, int frame, const Vec2F &p) -// : mNr(0), -// mHeight(MIN_HEIGHT), -// mFirstFrame(frame), -// mLastFrame(frame), -// mNewReco(true) -// { -// //TrackPoint t = p; -// //for (int i = 0; i <= frame; ++i) -// append(p); -// } TrackPerson::TrackPerson(int nr, int frame, const TrackPoint &p) : mNr(nr), mMarkerID(-1), @@ -223,7 +199,6 @@ void TrackPerson::optimizeColor() vBefore = v; } } - //debout << anz1 << " " << anz2 <<endl; swap = false; if (at(i).color().isValid()) vBefore = at(i).colPoint() - at(i); @@ -276,11 +251,10 @@ void TrackPerson::optimizeColor() void TrackPerson::recalcHeight(float altitude) { double z = 0; - //double h = 0; // median statt mittelwert nehmen (bei gerader anzahl an werten den kleiner als mitte) QList<double> zList; - resetHeight(); // mHeight = MIN_HEIGHT, mHeightCount = 0 + resetHeight(); for (int i = 0; i < size(); ++i) { @@ -295,7 +269,6 @@ void TrackPerson::recalcHeight(float altitude) if (mHeightCount > 0) { std::sort(zList.begin(), zList.end()); - //mHeight = h / mHeightCount; mHeight = zList[mHeightCount/2]; mHeight = altitude - mHeight; } @@ -363,15 +336,11 @@ double TrackPerson::getNearestZ(int i, int *extrapolated) */ bool TrackPerson::insertAtFrame(int frame, const TrackPoint &p, int persNr, bool extrapolate) { -// if (frame == mLastFrame+1) //included in following lines -// append(p); int i; Vec2F tmp; // ua. zur linearen Interpolation TrackPoint tp; // default: 0 = ist schlechteste qualitaet double distance; -// debout << "frame: " << frame << " first: " << mFirstFrame << " last: " << mLastFrame << endl; - if (frame > mLastFrame) { // lineare interpolation, wenn frames uebersprungen wurden @@ -381,7 +350,6 @@ bool TrackPerson::insertAtFrame(int frame, const TrackPoint &p, int persNr, bool tmp.setY((p.y()-last().y())/(frame-mLastFrame)); tp = last(); tp.setQual(0); - //tp.setZdistanceToCam(p.zDistanceToCam()); keine Interpolation der Groesse for (i = 0; i < frame-mLastFrame-1; ++i) { tp += tmp; @@ -400,15 +368,10 @@ bool TrackPerson::insertAtFrame(int frame, const TrackPoint &p, int persNr, bool if (!((last().qual() == 0) && (at(size()-2).qual() == 0))) // das vorherige einfuegen ist 2x nicht auch schon schlecht gewesen { tp = p; -// if (tp.qual() == 100) // reco oder haendisch - KOMMT NIE VOR, DA VOR RECO AUCH IMMER GETRACKT WIRD !!!!!!! -// debout << "Warning: Big difference from tracked point in speed and direction between frame " << mLastFrame << " and " << mLastFrame+1 << "!" << endl; -// else -// { debout << "Warning: Extrapolation instaed of tracking because of big difference from tracked point in speed and direction of person " << persNr+1 << " between frame " << mLastFrame << " and " << mLastFrame+1 << "!" << std::endl; tp = last()+tmp; // nur vektor wird hier durch + geaendert tp.setQual(0); // im anschluss koennte noch dunkelster pkt in umgebung gesucht werden!!! -// } // keine Extrapolation der Groesse append(tp); } @@ -474,7 +437,6 @@ bool TrackPerson::insertAtFrame(int frame, const TrackPoint &p, int persNr, bool // dieser Zweig wird insbesondere von reco durchlaufen, da vorher immer auch noch getrackt wird und reco draufgesetzt wird!!! tp = p; -// debout << "qual: " << p.qual() << endl; if (p.qual()<100 && p.qual()>80) // erkannte Person aber ohne strukturmarker { // wenn in angrenzenden Frames qual groesse 90 (100 oder durch vorheriges verschieben entstanden), dann verschieben @@ -485,11 +447,6 @@ bool TrackPerson::insertAtFrame(int frame, const TrackPoint &p, int persNr, bool tp.set(tmp.x(),tmp.y()); debout << "Warning: move trackpoint according to last distance of structur marker and color marker of person "<< persNr+1 << ":"<< std::endl; debout << " "<< p <<" -> "<< tp << std::endl; - //debout <<trackPointAt(frame-1)<<endl; - //debout <<trackPointAt(frame)<<endl; - - //debout << trackPointAt(frame).colPoint()<<endl; - //at(frame-mFirstFrame) } else if (trackPointExist(frame+1) && trackPointAt(frame+1).qual()>90) { @@ -500,11 +457,9 @@ bool TrackPerson::insertAtFrame(int frame, const TrackPoint &p, int persNr, bool debout << " "<< p <<" -> "<< tp << std::endl; } } -// debout << tp.qual()<<endl; -// debout << at(frame-mFirstFrame).qual()<<endl; // ueberprueft, welcher punkt besser - if (tp.qual() > at(frame-mFirstFrame).qual()) // at(frame-mFirstFrame) == trackPointAt(frame) + if (tp.qual() > at(frame-mFirstFrame).qual()) { // warnung ausgeben, wenn replacement (fuer gewoehnlich von reco) den pfadverlauf abrupt aendert if (trackPointExist(frame-1)) @@ -532,7 +487,6 @@ bool TrackPerson::insertAtFrame(int frame, const TrackPoint &p, int persNr, bool if (tp.qual() > 100) // manual add // after inserting, because p ist const (*this)[frame-mFirstFrame].setQual(100); // so moving of a point is possible - //debout << "Warning: frame exists already in trajectory!" << endl; } else return false; @@ -549,20 +503,9 @@ bool TrackPerson::trackPointExist(int frame) const } const TrackPoint& TrackPerson::trackPointAt(int frame) const // & macht bei else probleme, sonst mit [] zugreifbar { -// if (frame >= mFirstFrame && frame <= mLastFrame) ////!!!! muss vorher ueberprueft werden, ob es existiert!!! return at(frame-mFirstFrame); -// else -// return TrackPoint(); } -// ~TrackerPerson(); - -// inline const MyEllipse& head() const -// { -// return mHead; -// } - //void draw(IplImage *img) const; - /** * @brief Absolute distance to next frame * @@ -589,31 +532,8 @@ double TrackPerson::distanceToNextFrame(int frame) const // 7. recalc coord with real coord with known height Tracker::Tracker(QWidget *wParent) -// : QList::QList() { mMainWindow = (class Petrack*) wParent; - -// mGrey = NULL; -// mPrevGrey = NULL; -// mPyramid = NULL; -// mPrevPyramid = NULL; -// mPrevImg = NULL; - -// mPrevFeaturePoints.resize(MAX_COUNT);// = vector<Point2f>(MAX_COUNT); -// mPrevFeaturePointsIdx.resize(MAX_COUNT);// = vector<int>(MAX_COUNT); -// mFeaturePoints.resize(MAX_COUNT);// = vector<Point2f>(MAX_COUNT); -// mStatus.resize(MAX_COUNT);// = vector<uchar>(MAX_COUNT); -// mTrackError.resize(MAX_COUNT);// = vector<float>(MAX_COUNT); - -// mPrevFeaturePoints = (CvPoint2D32f*) cvAlloc(MAX_COUNT*sizeof(CvPoint2D32f)); //points[0] -//// mPrevColorFeaturePoints = (CvPoint2D32f*) cvAlloc(MAX_COUNT*sizeof(CvPoint2D32f)); //points[0] -// mFeaturePoints = (CvPoint2D32f*) cvAlloc(MAX_COUNT*sizeof(CvPoint2D32f)); //points[1] -//// mColorFeaturePoints = (CvPoint2D32f*) cvAlloc(MAX_COUNT*sizeof(CvPoint2D32f)); //points[1] -// mStatus = (char*) cvAlloc(MAX_COUNT); -//// mColorStatus = (char*) cvAlloc(MAX_COUNT); -// mPrevFeaturePointsIdx = (int*) cvAlloc(MAX_COUNT*sizeof(int)); -// mTrackError = (float*) cvAlloc(MAX_COUNT*sizeof(float)); -//// mColorTrackError = (float*) cvAlloc(MAX_COUNT*sizeof(float)); mTermCriteria = cv::TermCriteria(cv::TermCriteria::COUNT|cv::TermCriteria::EPS, 20, 0.03); ///< maxIter=20 and epsilon=0.03 reset(); @@ -625,23 +545,10 @@ void Tracker::init(cv::Size size) { clear(); // loescht liste aller getrackten personen // nicht mehr noetig, da nicht mehr in track selber // jetzt start, war prevImg == NULL && prevFrame == -1 zeigt an, dass ein neuer Trackingprozess beginnt / neue Bildfolge -// if (mGrey) -// cvReleaseImage(&mGrey); -// if (mPrevGrey) -// cvReleaseImage(&mPrevGrey); -// if (mPyramid) -// cvReleaseImage(&mPyramid); -// if (mPrevPyramid) -// cvReleaseImage(&mPrevPyramid); -//debout << "test" << endl; - mGrey.create(size,CV_8UC1);// = cvCreateImage(size, 8, 1); - mPrevGrey.create(size,CV_8UC1);// = cvCreateImage(size, 8, 1); -// debout << "test" << endl; -// mPyramid.create(size,CV_8UC1);// = cvCreateImage(size, 8, 1); -// mPrevPyramid.create(size,CV_8UC1);// = cvCreateImage(size, 8, 1); - -//if (mGrey) debout << "mGrey: " << mGrey << " " << (void *) mGrey->imageData<<endl; -//if (mMainWindow->getIplImage()) debout << "mImage: " << mMainWindow->getIplImage()<< " " << (void *) mMainWindow->getIplImage()->imageData<<endl; + + mGrey.create(size,CV_8UC1); + mPrevGrey.create(size,CV_8UC1); + reset(); } @@ -668,8 +575,6 @@ void Tracker::resize(cv::Size size) mPrevGrey = mPrevGrey(cv::Rect(-s,-s,mPrevGrey.cols+2*s,mPrevGrey.rows+2*s)); } } -// ; //anpassungen von prev bildmaterial (und punkten selber?) -// // -getImgBorderSize() nutzen } /// split trajectorie pers before frame frame @@ -706,7 +611,7 @@ bool Tracker::splitPersonAt(const Vec2F& p, int frame, QSet<int> onlyVisible) int i; for (i = 0; i < size(); ++i) // ueber TrackPerson - if (((onlyVisible.empty()) || (onlyVisible.contains(i))) && (at(i).trackPointExist(frame) && (at(i).trackPointAt(frame).distanceToPoint(p) < mMainWindow->getHeadSize(nullptr, i, frame)/2.))) // war: MIN_DISTANCE)) // 30 ist abstand zwischen kopfen + if (((onlyVisible.empty()) || (onlyVisible.contains(i))) && (at(i).trackPointExist(frame) && (at(i).trackPointAt(frame).distanceToPoint(p) < mMainWindow->getHeadSize(nullptr, i, frame)/2.))) { splitPerson(i, frame); @@ -761,7 +666,7 @@ bool Tracker::delPoint(const Vec2F& p, int direction, int frame, QSet<int> onlyV int i; for (i = 0; i < size(); ++i) // ueber TrackPerson - if (((onlyVisible.empty()) || (onlyVisible.contains(i))) && (at(i).trackPointExist(frame) && (at(i).trackPointAt(frame).distanceToPoint(p) < mMainWindow->getHeadSize(nullptr, i, frame)/2.))) // war: MIN_DISTANCE)) // 30 ist abstand zwischen kopfen + if (((onlyVisible.empty()) || (onlyVisible.contains(i))) && (at(i).trackPointExist(frame) && (at(i).trackPointAt(frame).distanceToPoint(p) < mMainWindow->getHeadSize(nullptr, i, frame)/2.))) { delPointOf(i, direction, frame); return true; @@ -863,65 +768,6 @@ void Tracker::delPointROI() } } debout << "deleted "<<anz<<" trajectories!"<< std::endl; - -// for (i = 0; i < size(); ++i) // ueber TrackPerson -// { -// for (j = 0; j < at(i).lastFrame(); ++j) -// (*this)[i]. removeLast(); -// if (rect.contains(at(i).at(j).x(), at(i).at(j).y()) - - -// if (at(i).trackPointExist(frame)) // -// { -// if (direction == -1) -// { -// for (j = 0; j < frame-at(i).firstFrame(); ++j) -// (*this)[i].removeFirst(); -// (*this)[i].setFirstFrame(frame); -// } -// else if (direction == 0) -// removeAt(i--); // nach Loeschen wird i um 1 erniedrigt -// else if (direction == 1) -// { -// for (j = 0; j < at(i).lastFrame()-frame; ++j) -// (*this)[i].removeLast(); -// (*this)[i].setLastFrame(frame); -// } -// } -// else if (((direction == -1) && (frame > at(i).lastFrame())) || -// (direction == 0) || -// ((direction == 1) && (frame < at(i).firstFrame()))) -// { -// removeAt(i--); // nach Loeschen wird i um 1 erniedrigt -// } - - - -// x = (*this)[i].first().x(); -// y = (*this)[i].first().y(); -// // mGrey hat gleiche groesse wie zuletzt getracktes bild -// if ((*this)[i].firstFrame() != 0 && x >= MAX(margin, rect.x()) && y >= MAX(margin, rect.y()) && x <= MIN(mGrey->width-1-2*bS-margin, rect.x()+rect.width()) && y <= MIN(mGrey->height-1-2*bS-margin, rect.y()+rect.height())) -// { -// debout << "Warning: Start of trajectory inside picture and recognition area of person " << i+1 << "!" << endl; -// pers.append(i+1); -// frame.append((*this)[i].firstFrame()); -// } - -// x = (*this)[i].last().x(); -// y = (*this)[i].last().y(); -// // mGrey hat gleiche groesse wie zuletzt getracktes bild -// if ((*this)[i].lastFrame() != lastFrame && x >= MAX(margin, rect.x()) && y >= MAX(margin, rect.y()) && x <= MIN(mGrey->width-1-2*bS-margin, rect.x()+rect.width()) && y <= MIN(mGrey->height-1-2*bS-margin, rect.y()+rect.height())) -// { -// debout << "Warning: End of trajectory inside picture and recognition area of person " << i+1 << "!" << endl; -// pers.append(i+1); -// frame.append((*this)[i].lastFrame()); -// } - - - -// } - - } /** @@ -988,10 +834,6 @@ bool Tracker::setTrackPersonHeight(const Vec2F& p, int frame, QSet<int> onlyVisi { bool ok; -// if (at(i).height() > MIN_HEIGHT) - //QString comment = QInputDialog::getMultiLineText(mMainWindow, QObject::tr("Add Comment"), - // QObject::tr("Comment:"), at(i).comment() , &ok); - double col_height; // col_height is negative, if height is determined through color and not yet set manually if( at(i).height() < MIN_HEIGHT+1 ) @@ -1148,25 +990,9 @@ bool Tracker::addPoint(TrackPoint &p, int frame, const QSet<int>& onlyVisible, i for (i = 0; i < size(); ++i) // !found && // ueber TrackPerson { if (((onlyVisible.empty()) || (onlyVisible.contains(i))) && at(i).trackPointExist(frame)) - //&& (!multiColorWithDot && (at(i).trackPointAt(frame).distanceToPoint(p) < scaleHead*mMainWindow->getHeadSize(NULL, i, frame)/2.)) && - //((mMainWindow->getControlWidget()->getRecoMethod() == 5 && // multicolor marker - // mMainWindow->getMultiColorMarkerWidget()->useDot->isChecked() && // nutzung von black dot - // !mMainWindow->getMultiColorMarkerWidget()->ignoreWithoutDot->isChecked()) && // auch reine farbige muetze wird akzeptiert - // (at(i).trackPointAt(frame).colPoint().distanceToPoint(p.colPoint()) < scaleHead*mMainWindow->getHeadSize(NULL, i, frame)/2.))) // ist kaserne: 52/2 war: MIN_DISTANCE)) // 30 ist Abstand zwischen Koepfen { -// if (i+1 == 14) -// { -// debout << i+1 << " " << multiColorWithDot << endl; -// debout << at(i).trackPointAt(frame)<<endl; -// debout << p << endl; -// debout << mMainWindow->getHeadSize(NULL, i, frame)/2.<<endl; -// debout << at(i).trackPointAt(frame).distanceToPoint(p)<<endl; -// debout << at(i).trackPointAt(frame).distanceToPoint(p.colPoint())<<endl; - -// } dist = at(i).trackPointAt(frame).distanceToPoint(p); - if (( //(!multiColorWithDot || !p.color().isValid()) && //|| !at(i).trackPointAt(frame).color().isValid() - dist < scaleHead*mMainWindow->getHeadSize(nullptr, i, frame)/2.) || + if ((dist < scaleHead*mMainWindow->getHeadSize(nullptr, i, frame)/2.) || // fuer multifarbmarker mit schwarzem punkt wird nur farbmarker zur Abstandbetrachtung herangezogen // at(i).trackPointAt(frame).colPoint() existiert nicht an dieser stelle, da bisher nur getrackt wurde!!!! (multiColorWithDot && p.color().isValid() && (at(i).trackPointAt(frame).distanceToPoint(p.colPoint()) < mMainWindow->getHeadSize(nullptr, i, frame)/2.))) @@ -1218,14 +1044,13 @@ bool Tracker::addPoint(TrackPoint &p, int frame, const QSet<int>& onlyVisible, i } - //--i; if ((onlyVisible.empty()) && !found) { - iNearest = size(); // << " (new) "; + iNearest = size(); if (p.qual() > 100) //manual add p.setQual(100); - append(TrackPerson(/*p.markerID()>0 ? p.markerID() :*/ 0, frame, p, p.getMarkerID())); // 0 is person number/markerID; newReco is set to true by default + append(TrackPerson(0, frame, p, p.getMarkerID())); // 0 is person number/markerID; newReco is set to true by default } if ((z > 0) && ((onlyVisible.empty()) || found)) @@ -1257,11 +1082,6 @@ void Tracker::addPoints(QList<TrackPoint> &pL, int frame) } } -// calculate height of person - -// convert all trajectory coordinates in real coordinate (height needed) - - int Tracker::visible(int frameNum) { int i, anz = 0; @@ -1430,13 +1250,13 @@ int Tracker::insertFeaturePoints(int frame, size_t count, cv::Mat &img, int bord } #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 -// // wenn sprung sehr unterschiedlich, wird lieber interpoliert oder stehen geblieben -// // ist richtung ok, dann wird dunkelstes pixel gesucht -// // (subpixel aufgrund von nachbarpixel) -// // oder einfach bei schlechtem fehler mit groesserem winSize=30 den Problempunkt nochmal machen - // NOTE Wird gerade eben nicht gemacht. Sollten wir??? + // wenn bei punkten, die nicht am rand liegen, der fehler gross ist, + // wird geguckt, ob der sprung sich zur vorherigen richtung stark veraendert hat + // wenn sprung sehr unterschiedlich, wird lieber interpoliert oder stehen geblieben + // ist richtung ok, dann wird dunkelstes pixel gesucht + // (subpixel aufgrund von nachbarpixel) + // oder einfach bei schlechtem fehler mit groesserem winSize=30 den Problempunkt nochmal machen + // TODO Wird gerade eben nicht gemacht. Sollten wir??? // ueberpruefen, ob tracking ziel auf anderem tracking path landet, dann beide trackpaths verschmelzen lassen @@ -1559,8 +1379,6 @@ bool Tracker::tryMergeTrajectories(const TrackPoint& v, size_t i, int frame) */ int Tracker::track(cv::Mat &img, cv::Rect &rect, int frame, bool reTrack, int reQual, int borderSize, int level, QSet<int> onlyVisible, int errorScaleExponent) { -// debout << "frame="<<frame<<" reTrack="<<reTrack<<" reQual="<<reQual<<" borderSize="<<borderSize<<" level="<<level<<" errorScaleExponent="<<errorScaleExponent << endl; - [[maybe_unused]] int inserted = 0; QList<int> trjToDel; float errorScale = pow(1.5,errorScaleExponent); // 0 waere neutral @@ -1624,7 +1442,7 @@ int Tracker::track(cv::Mat &img, cv::Rect &rect, int frame, bool reTrack, int re refineViaNearDarkPoint(); } - inserted = insertFeaturePoints(frame, numOfPeopleToTrack, img, borderSize, errorScale); + insertFeaturePoints(frame, numOfPeopleToTrack, img, borderSize, errorScale); } cv::swap(mPrevGrey, mGrey); @@ -2002,7 +1820,6 @@ void Tracker::checkPlausibility(QList<int> &pers, QList<int> &frame, #endif } -// debout << rect.x() << " " <<rect.y() << " " <<rect.width() << " " <<rect.height() << " " <<endl; // check, if trajectory starts and ends outside the recognition area if (testInside) { @@ -2017,11 +1834,6 @@ void Tracker::checkPlausibility(QList<int> &pers, QList<int> &frame, { qApp->processEvents(); progress.setValue(100+i*100./size()); - // if (i == 11) - // { - // debout << (*this)[i].first().x() << " " << (*this)[i].first().y() <<endl; - // debout << MAX(margin, rect.x()) << " " << MAX(margin, rect.y()) << " " << MIN(mGrey->width-1-2*bS-margin, rect.x()+rect.width()) << " " << MIN(mGrey->height-1-2*bS-margin, rect.y()+rect.height())<<endl; - // } x = (*this)[i].first().x(); y = (*this)[i].first().y(); // mGrey hat gleiche groesse wie zuletzt getracktes bild @@ -2189,7 +2001,6 @@ bool Tracker::printHeightDistribution() anz += j.value(); ++j; } - //debout << "Attention: persons with height lower 0 are ignored!" << endl; debout << "number of persons with measured height : " << anz << std::endl; debout << "person without measured height (not included in calculated values): " << noHeight << " (using default height for export)" << std::endl; if (anz == 0) @@ -2285,21 +2096,10 @@ void Tracker::purge(int frame) { if (at(i).at(j).qual() < 100.) ++count; - //debout << i << " " << j << " " << at(i).at(j).qual() <<endl; } if (count/at(i).size() > 0.8) // Achtung, wenn roi klein, dann viele tp nur getrackt removeAt(i); // delete trj } - - // wenn x/y/z gesetzt ist, dann koennte auch eine hoehenschwankung zum eliminieren fuehren - -// if ((*this)[i].height() > MIN_HEIGHT) // !=-1// insbesondere von hand eingefuegte trackpoint/persons haben keine farbe -// { -// ++dict[(((int) (*this)[i].height())/heightStep)*heightStep]; -// avg += (*this)[i].height(); -// } -// else -// ++noHeight; } } diff --git a/src/trackerItem.cpp b/src/trackerItem.cpp index a77627834..344d240b3 100644 --- a/src/trackerItem.cpp +++ b/src/trackerItem.cpp @@ -39,13 +39,6 @@ TrackerItem::TrackerItem(QWidget *wParent, Tracker *tracker, QGraphicsItem * par mMainWindow = (class Petrack*) wParent; mControlWidget = mMainWindow->getControlWidget(); mTracker = tracker; - - //acceptHoverEvents(); - - updateData(); // um zB setFlags(ItemIsMovable) je nach anzeige zu aendern - // setEnabled(false); // all mouse events connot access this item, but it will be seen - // einzig move koennte interessant sein, um grid zu verschieben?! -// setAcceptsHoverEvents(true); } /** @@ -60,28 +53,14 @@ QRectF TrackerItem::boundingRect() const { if (mMainWindow->getImage()) return QRectF(-mMainWindow->getImageBorderSize(), -mMainWindow->getImageBorderSize(), mMainWindow->getImage()->width(), mMainWindow->getImage()->height()); -// return QRectF(-mMainWindow->getImageBorderSize(), -mMainWindow->getImageBorderSize(), mImage->width(), mImage->height()); else return QRectF(0, 0, 0, 0); -// // bounding box wird in lokalen koordinaten angegeben!!! (+-10 wegen zahl "1") -// if (mControlWidget->getCalibCoordShow()) -// return QRectF(-110., -110., 220., 220.); -// else ; - -// return QRectF(0., 0., 0., 0.); - -// // sicher ware diese boundingbox, da alles -// // return QRectF(xMin, yMin, xMax-xMin, yMax-yMin); -// // eigentlich muesste folgende Zeile reichen, aber beim ranzoomen verschwindet dann koord.sys. -// // return QRectF(mControlWidget->getCalibCoordTransX()/10.-scale, mControlWidget->getCalibCoordTransY()/10.-scale, 2*scale, 2*scale); } void TrackerItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { if( !(event->modifiers() & Qt::ShiftModifier || event->modifiers() & Qt::ControlModifier || event->modifiers() & Qt::AltModifier) ) { - //debout << "start contextMenuEvent..." << endl; TrackPoint p((Vec2F) event->pos(), 110); // 110 ist ueber 100 (hoechste Qualitaetsstufe) und wird nach einfuegen auf 100 gesetzt - //debout << "p: " << p.x() << ", " << p.y() << endl; bool found = false; int i, iNearest = -1; float dist, minDist = 1000000.; @@ -125,66 +104,46 @@ void TrackerItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) bool height_set_by_user = false; QAction *delTrj = nullptr, *delFutureTrj = nullptr, *delPastTrj = nullptr, *creTrj = nullptr, *infoTrj = nullptr, *addComment = nullptr, *setHeight = nullptr, *resetHeight = nullptr; - //debout << "mTracker->size(): " << mTracker->size() << endl; if(found) { i = iNearest; - //debout << "found: " << found << " iNearest: " << iNearest << endl; tp = mTracker->at(i); - //debout << "test" << endl; height = tp.height(); - //debout << "height: " << height << endl; - //debout << "height<MIN_HEIGHT: " << height << endl; - //debout << "mTracker.color: valid? " << tp.color().isValid() << endl; - //debout << "tp.color: " << tp.color() << endl; - //QRgb col = mMainWindow->getImage()->pixel(QPoint(event->scenePos().x(),event->scenePos().y())); - //QColor color(qRed(col), qGreen(col), qBlue(col)); - - //debout << "color: " << color << endl; + if (height < MIN_HEIGHT+1) { if (tp.color().isValid()) height = mControlWidget->getColorPlot()->map(tp.color()); - //debout << "height: " << height << endl; }else { - //height = mControlWidget->mapDefaultHeight->value(); - //debout << "height(default): " << height << endl; height_set_by_user = true; } - //debout << "setHeight" << endl; - // tp.setHeight(height); + infoTrj = menu.addAction(QString("PersonNr: %1 height: %2 frames: [%3..%4]").arg(i+1).arg(height).arg(tp.firstFrame()).arg(tp.lastFrame())); delTrj = menu.addAction("Delete whole trajectory"); delFutureTrj = menu.addAction("Delete past part of the trajectory"); delPastTrj = menu.addAction("Delete future part of the trajectory"); setHeight = menu.addAction("Set person height"); if(height_set_by_user) resetHeight = menu.addAction("Reset height"); - addComment = menu.addAction("Edit comment"); - }else + addComment = menu.addAction("Edit comment"); + } + else { creTrj = menu.addAction("Create new trajectory"); } - //debout << "selectedAction: " << endl; QAction *selectedAction = menu.exec(event->screenPos()); - //debout << "screenPos: " << event->scenePos() << endl; if( selectedAction == creTrj ) { - //debout << "Create new trajectory..." << endl; mMainWindow->addOrMoveManualTrackPoint(event->scenePos()); - //debout << "addManuelTrackPoint: " << res << endl; }else if( selectedAction == delTrj ) { - //debout << "Delete trajectory..." << endl; mMainWindow->deleteTrackPoint(event->scenePos(),0); }else if( selectedAction == delFutureTrj ) { - //debout << "Delete future part of trajectory..." << endl; mMainWindow->deleteTrackPoint(event->scenePos(),-1); }else if( selectedAction == delPastTrj ) { - //debout << "Delete past part of trajectory..." << endl; mMainWindow->deleteTrackPoint(event->scenePos(),1); }else if( selectedAction == addComment ) { @@ -279,89 +238,10 @@ void TrackerItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) } } mMainWindow->getScene()->update(); - //debout << "finished contextMenuEvent!" << endl; -} - -//// event, of moving mouse while button is pressed -//void TrackerItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -//{ - -// setCursor(Qt::ClosedHandCursor); -// QPointF diff = event->scenePos()-event->lastScenePos(); //screenPos()-buttonDownScreenPos(Qt::RightButton) also interesting -// if (event->buttons() == Qt::RightButton) // event->button() doesnt work -// { -// debout << "right mouse button" << endl; -// } -// else if (event->buttons() == Qt::LeftButton) -// { -// debout << "left mouse button" << endl; -// } -// else if (event->buttons() == Qt::MidButton) -// { -// debout << "mid mouse button" << endl; -// } -//} - -//// event, of moving mouse -//void TrackerItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -//{ -// QPointF pos = event->scenePos(); -// pos.setX(pos.x() + mMainWindow->getImageBorderSize()); -// pos.setY(pos.y() + mMainWindow->getImageBorderSize()); -// if (pos.x() >=0 && pos.x() <= mMainWindow->getImage()->width() && pos.y() >=0 && pos.y() <= mMainWindow->getImage()->height()) -// mMainWindow->setMousePosOnImage(pos); - -// if (!mControlWidget->getCalibCoordFix()) -// setCursor(Qt::OpenHandCursor); -// else -// setCursor(Qt::CrossCursor); - - //debout << "hover Move Event" << endl; - //QGraphicsItem::hoverMoveEvent(event); -//} - -void TrackerItem::updateData() -{ -// if (!mControlWidget->getCalibCoordFix()) -// setFlags(ItemIsMovable); // noetig, damit mouseEvent leftmousebutton weitergegeben wird, aber drag mach ich selber -// else -// setFlags(!ItemIsMovable); - -// if (mControlWidget->getCalibCoordShow()) -// { -// double sc=mControlWidget->getCalibCoordScale()/10.; -// double tX=mControlWidget->getCalibCoordTransX()/10.; -// double tY=mControlWidget->getCalibCoordTransY()/10.; -// double ro=mControlWidget->getCalibCoordRotate()/10.; - -// // aktualisierung der transformationsmatrix -// QMatrix matrix; -// // matrix wird nur bei aenderungen neu bestimmt -// matrix.translate(tX, tY); -// matrix.rotate(ro); -// matrix.scale(sc/100., sc/100.); -// setMatrix(matrix); -// } - -// mMainWindow->updateSceneRect(); - -// // QGraphicsItem::update(); -// mScene->update(); } void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) { -// debout << "TrackerItem::paint" << endl; -// double scale=mControlWidget->getCalibCoordScale()/10.; - -// //eigentliche BoundingBox: painter->drawRect(QRectF(mControlWidget->getCalibCoordTransX()/10.-scale, mControlWidget->getCalibCoordTransY()/10.-scale, 2*scale, 2*scale)); -// matrix.translate(mControlWidget->getCalibCoordTransX()/10., mControlWidget->getCalibCoordTransY()/10.); -// matrix.rotate((mControlWidget->getCalibCoordRotate())/10.); -// mit folgender zeile wuerde nur der painter bewegt, nicht aber das koord des items!!! -// painter->setWorldMatrix(matrix, true); // true sagt, dass relativ und nicht absolut (also zusaetzlichj zur uebergeordneten matrizen) - - //cycle on frame -// painter->setPen(Qt::red); int from, to; int curFrame = mMainWindow->getAnimation()->getCurrentFrameNum(); QPen ellipsePen; @@ -382,22 +262,14 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt double pSGP = (double) mControlWidget->trackGroundPathSize->value(); QColor pGPC = mControlWidget->getTrackGroundPathColor(); - QColor pTPC = mControlWidget->getTrackPathColor();//Qt::red; + QColor pTPC = mControlWidget->getTrackPathColor(); QFont font, heightFont; - //double headSize = mMainWindow->getHeadSize(); float x_offset=0, y_offset=0; float y_switch=0, x_switch=0; double hS; painter->drawRect( boundingRect() ); - // die Groesse des kreises fuer die aktuelle position kann auf durchschnittlichen Kopfdurchmessers gestell werden - // 21cm avg kopflaenge, 173cm avg koerpergroesse mann / frau mit Schuhen (180cm nur Mann) - //if (mControlWidget->trackHeadSized->checkState() == Qt::Checked) - // pSP = headSize; - //else - // pSP = (double) mControlWidget->trackCurrentPointSize->value(); - linePen.setColor(pTPC); linePen.setWidth(mControlWidget->trackPathWidth->value()); @@ -409,7 +281,6 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt font.setBold(false); font.setPixelSize(mControlWidget->trackNumberSize->value()); heightFont.setPixelSize(mControlWidget->trackColColorSize->value()); - //font.setPointSize(pSN); painter->setFont(font); numberPen.setColor(Qt::red); groundPositionPen.setColor(Qt::green); @@ -422,18 +293,15 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt { // ToDo: adjust subdiv rect to correct area QRectF qrect = mMainWindow->getRecoRoiItem()->rect(); -// debout << "rect: " << rect.left() << ", " << rect.top() << ", " << rect.right() << ", " << rect.bottom() << endl; cv::Point3f leftTop = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(qrect.left(),qrect.top()),0); cv::Point3f rightBottom = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(qrect.right(),qrect.bottom()),0); - // subdiv.initDelaunay(Rect(mMainWindow->getRecoRoiItem()->rect().left(),mMainWindow->getRecoRoiItem()->rect().top(),mMainWindow->getRecoRoiItem()->rect().width(),mMainWindow->getRecoRoiItem()->rect().height())); x_offset = -std::min(leftTop.x,rightBottom.x); y_offset = -std::min(leftTop.y,rightBottom.y); x_switch = rightBottom.x < leftTop.x ? abs(rightBottom.x-leftTop.x) : 0; y_switch = rightBottom.y < leftTop.y ? abs(leftTop.y-rightBottom.y) : 0; debout << "x_offset: " << x_offset << ", y_offset: " << y_offset << ", x_switch: " << x_switch << ", y_switch: " << y_switch << std::endl; -// debout << "leftTop: " << leftTop.x+x_offset << ", " << leftTop.y+y_offset << " rightBottom: " << rightBottom.x+x_offset << ", " << rightBottom.y+y_offset << endl; cv::Rect rect(cv::Rect(leftTop.x+x_offset,leftTop.y+y_offset,x_switch>0 ? x_switch : (rightBottom.x-leftTop.x),y_switch>0 ? y_switch : (rightBottom.y-leftTop.y))); debout << "Rect size: P(" << rect.x << ", " << rect.y << "), width: " << rect.width << ", height: " << rect.height << std::endl; @@ -459,9 +327,7 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt painter->setPen(Qt::green); else painter->setPen(Qt::blue); - //TrackPoint tp = mTracker->at(i).trackPointAt(curFrame); // kostet mehr zeit - //int idx = curFrame-mTracker->at(i).firstFrame(); - rect.setRect(tp.x()-pSP/2., tp.y()-pSP/2., pSP, pSP); //10 //mTracker->at(i).at(idx) + rect.setRect(tp.x()-pSP/2., tp.y()-pSP/2., pSP, pSP); painter->drawEllipse(rect); // direkt waere nur int erlaubt tp.x()-5., tp.y()-5., 10., 10. } @@ -469,26 +335,26 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt { painter->setBrush(Qt::NoBrush); painter->setPen(Qt::yellow); - hS = mMainWindow->winSize(nullptr, i, curFrame); //headSize * 1.6 * (mControlWidget->trackRegionScale->value() / 10.); + hS = mMainWindow->winSize(nullptr, i, curFrame); if (hS < 2) hS = 2; // entspricht Vorgehen in tracker.cpp for (j = 0; j <= mControlWidget->trackRegionLevels->value(); ++j) { rect.setRect(tp.x()-hS/2., tp.y()-hS/2., hS, hS); painter->drawRect(rect); - hS *= 2; //hS / pow(2,j); + hS *= 2; } } - if (mControlWidget->trackShowColorMarker->checkState() == Qt::Checked) //(mControlWidget->recoShowColor->checkState() == Qt::Checked) + if (mControlWidget->trackShowColorMarker->checkState() == Qt::Checked) { // farbe des trackpoints if (tp.color().isValid()) { painter->setBrush(Qt::NoBrush); ellipsePen.setColor(tp.color()); - painter->setPen(ellipsePen); //tp.color() - rect.setRect(tp.colPoint().x()-pSM/2., tp.colPoint().y()-pSM/2., pSM, pSM); // 14 //mTracker->at(i).at(idx) + painter->setPen(ellipsePen); + rect.setRect(tp.colPoint().x()-pSM/2., tp.colPoint().y()-pSM/2., pSM, pSM); painter->drawEllipse(rect); } } @@ -497,7 +363,7 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt if (((mControlWidget->trackShowColColor->checkState() == Qt::Checked) && (mTracker->at(i).color().isValid())) || (mControlWidget->trackShowNumber->checkState() == Qt::Checked) || ((mControlWidget->trackShowColColor->checkState() == Qt::Checked) && - ((mTracker->at(i).height() > MIN_HEIGHT) || ((tp.sp().z() > 0.) && (mControlWidget->trackShowHeightIndividual->checkState() == Qt::Checked))))) // && (mTracker->at(i).height() > 0.) Hoehe kann auf Treppen auch negativ werden, wenn koord weiter oben angesetzt wird + ((mTracker->at(i).height() > MIN_HEIGHT) || ((tp.sp().z() > 0.) && (mControlWidget->trackShowHeightIndividual->checkState() == Qt::Checked))))) // Hoehe kann auf Treppen auch negativ werden, wenn koord weiter oben angesetzt wird { if (tp.color().isValid()) { @@ -505,8 +371,6 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt n.normalize(); if (n.length()<.001) // wenn to und colpoint aufeinander liegen z bei colorMarker! n.set(1., 0.); - // rect.setRect(tp.x()+13*n.x()-5.5, tp.y()+13*n.y()-5.5, 11., 11.); - // rect.setRect(tp.x()+(tp.x()-tp.colPoint().x())-5, tp.y()+(tp.y()-tp.colPoint().y())-5., 10., 10.); } else { @@ -532,9 +396,6 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt break; } } - // rect.setRect(tp.x()+13*n.x()-5.5, tp.y()+13*n.y()-5.5, 11., 11.); - // mTracker->at(i).getLastPointDif(curFrame) schoener waere eine andere position - // rect.setRect(tp.x()+7., tp.y()-5., 10., 10.); } } @@ -610,8 +471,6 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt if( mControlWidget->getCalibCoordDimension() == 0) // 3D { double cross_size = 15+pSG*0.25; - //debout << "2D Point: (" << tp.x() << ", " << tp.y() << "), height: " << height << endl; - //debout << "mTracker.at(i).height(): " << mTracker->at(i).height() << " tp.sp().z(): " << tp.sp().z() << endl; cv::Point3f p3d_height; if (height < MIN_HEIGHT+1) { @@ -623,15 +482,11 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt else p3d_height = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(tp.x(),tp.y()),height/*mControlWidget->mapDefaultHeight->value()*/); } - //debout << "3D Point: (" << p3d_height.x << ", " << p3d_height.y << ", " << p3d_height.z << ")" << endl; p3d_height.z = 0; cv::Point2f p2d_ground = mMainWindow->getExtrCalibration()->getImagePoint(p3d_height); QPointF axis = mMainWindow->getImageItem()->getCmPerPixel(p2d_ground.x, p2d_ground.y, 0); - //debout << "2D Point: (" << p2d_ground.x << ", " << p2d_ground.y << ")" << endl; - //rect.setRect(p2d_ground.x-cross_size/2., p2d_ground.y-cross_size/2., cross_size, cross_size); painter->drawLine(QLineF(p2d_ground.x-cross_size*0.5*pow(axis.x(),-1),p2d_ground.y-cross_size*0.5*pow(axis.y(),-1),p2d_ground.x+cross_size*0.5*pow(axis.x(),-1),p2d_ground.y+cross_size*0.5*pow(axis.y(),-1))); painter->drawLine(QLineF(p2d_ground.x-cross_size*0.5*pow(axis.x(),-1),p2d_ground.y+cross_size*0.5*pow(axis.y(),-1),p2d_ground.x+cross_size*0.5*pow(axis.x(),-1),p2d_ground.y-cross_size*0.5*pow(axis.y(),-1))); - //painter->drawEllipse(rect); painter->drawLine(QLineF(p2d_ground.x,p2d_ground.y,tp.x(),tp.y())); @@ -673,7 +528,7 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt from = 0; else { - from = curFrame-mTracker->at(i).firstFrame()-mControlWidget->trackShowBefore->value();// mTracker->at(i).firstFrame(); + from = curFrame-mTracker->at(i).firstFrame()-mControlWidget->trackShowBefore->value(); if (from < 0) from = 0; } @@ -681,7 +536,7 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt to = mTracker->at(i).size(); else { - to = curFrame-mTracker->at(i).firstFrame()+mControlWidget->trackShowAfter->value()+1;// mTracker->at(i).firstFrame(); + to = curFrame-mTracker->at(i).firstFrame()+mControlWidget->trackShowAfter->value()+1; if (to > mTracker->at(i).size()) to = mTracker->at(i).size(); } @@ -694,11 +549,7 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt { painter->setPen(linePen); painter->setBrush(Qt::NoBrush); -// if (i==45) -// { -// debout << mTracker->at(i).at(j-1) <<endl; -// debout << mTracker->at(i).at(j).toQPointF() <<endl <<endl; -// } + // nur Linie zeichnen, wenn x oder y sich unterscheidet, sonst Punkt // die Unterscheidung ist noetig, da Qt sonst grosses quadrat beim ranzoomen zeichnet if ((mTracker->at(i).at(j-1).toQPointF().x() != mTracker->at(i).at(j).toQPointF().x()) || @@ -719,8 +570,6 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt painter->setBrush(Qt::NoBrush); if( mControlWidget->getCalibCoordDimension() == 0) // 3D { - //debout << "2D Point: (" << tp.x() << ", " << tp.y() << "), height: " << height << endl; - //debout << "mTracker.at(i).height(): " << mTracker->at(i).height() << " tp.sp().z(): " << tp.sp().z() << endl; cv::Point3f p3d_height_p1, p3d_height_p2; if (mTracker->at(i).height() < MIN_HEIGHT+1) { @@ -734,21 +583,14 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt p3d_height_p2 = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(mTracker->at(i).at(j).x(),mTracker->at(i).at(j).y()),-mControlWidget->getCalibExtrTrans3()-mTracker->at(i).at(j).sp().z()); }else { - p3d_height_p1 = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(mTracker->at(i).at(j-1).x(),mTracker->at(i).at(j-1).y()),mTracker->at(i).height()/*mControlWidget->mapDefaultHeight->value()*/); - p3d_height_p2 = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(mTracker->at(i).at(j).x(),mTracker->at(i).at(j).y()),mTracker->at(i).height()/*mControlWidget->mapDefaultHeight->value()*/); + p3d_height_p1 = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(mTracker->at(i).at(j-1).x(),mTracker->at(i).at(j-1).y()),mTracker->at(i).height()); + p3d_height_p2 = mMainWindow->getExtrCalibration()->get3DPoint(cv::Point2f(mTracker->at(i).at(j).x(),mTracker->at(i).at(j).y()),mTracker->at(i).height()); } } - //debout << "3D Point: (" << p3d_height.x << ", " << p3d_height.y << ", " << p3d_height.z << ")" << endl; p3d_height_p1.z = 0; p3d_height_p2.z = 0; cv::Point2f p2d_ground_p1 = mMainWindow->getExtrCalibration()->getImagePoint(p3d_height_p1); cv::Point2f p2d_ground_p2 = mMainWindow->getExtrCalibration()->getImagePoint(p3d_height_p2); - //QPointF axis = mMainWindow->getImageItem()->getCmPerPixel(p2d_ground.x, p2d_ground.y, 0); - //debout << "2D Point: (" << p2d_ground.x << ", " << p2d_ground.y << ")" << endl; - //rect.setRect(p2d_ground.x-pSG/2., p2d_ground.y-pSG/2., pSG, pSG); - //painter->drawLine(QLineF(p2d_ground.x-pSG*0.5*pow(axis.x(),-1),p2d_ground.y-pSG*0.5*pow(axis.y(),-1),p2d_ground.x+pSG*0.5*pow(axis.x(),-1),p2d_ground.y+pSG*0.5*pow(axis.y(),-1))); - //painter->drawLine(QLineF(p2d_ground.x-pSG*0.5*pow(axis.x(),-1),p2d_ground.y+pSG*0.5*pow(axis.y(),-1),p2d_ground.x+pSG*0.5*pow(axis.x(),-1),p2d_ground.y-pSG*0.5*pow(axis.y(),-1))); - //painter->drawEllipse(rect); // nur Linie zeichnen, wenn x oder y sich unterscheidet, sonst Punkt // die Unterscheidung ist noetig, da Qt sonst grosses quadrat beim ranzoomen zeichnet if (p2d_ground_p1.x != p2d_ground_p2.x || p2d_ground_p1.y != p2d_ground_p2.y ) @@ -769,7 +611,6 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt { if ((mControlWidget->trackShowPointsColored->checkState() == Qt::Checked) && (mTracker->at(i).at(j).color().isValid())) { - //debout << "person: " << i+1 << " frame: " << j << " color: " << mTracker->at(i).at(j).color() <<endl; painter->setPen(Qt::NoPen); painter->setBrush(QBrush(mTracker->at(i).at(j).color())); rect.setRect(mTracker->at(i).at(j).x()-pS/2., mTracker->at(i).at(j).y()-pS/2., pS, pS); // 7 @@ -810,7 +651,7 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt cv::Point2f center2D = mMainWindow->getExtrCalibration()->getImagePoint(cv::Point3f(centers3D.at(i).x, centers3D.at(i).y,0)); - std::vector<QPointF> ifacet2D;//[facets[i].size()];//.resize(facets[i].size()); + std::vector<QPointF> ifacet2D; QPointF circleStart, circleEnd; float area = 0; float r = 50, m = 0, n = 0, s1_x = 0, s2_x = 0, s1_y = 0, s2_y = 0; @@ -824,7 +665,6 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt debout << "facets3D.at(" << i << ").at(" << j << ").x = " << facets3D.at(i).at(j).x << ", .y = " << facets3D.at(i).at(j).y << std::endl; debout << "point2D.x = " << point2D.x << " , .y = " << point2D.y << std::endl; - // ifacet[j] = QPointF(facets.at(i).at(j).x,facets.at(i).at(j).y);//facets[i][j]; if ( false && sqrt(pow((facets3D.at(i).at(j).x - centers3D.at(i).x),2) + pow((facets3D.at(i).at(j).y - centers3D.at(i).y),2)) > r ) @@ -856,20 +696,11 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt point2D = mMainWindow->getExtrCalibration()->getImagePoint(cv::Point3f(s1_x,s1_y,0)); circleEnd = QPointF(point2D.x,point2D.y); - // - // painter->setBrush(Qt::blue); - // point2D = mMainWindow->getExtrCalibration()->getImagePoint(Point3f(facets3D.at(i).at(j).x,facets3D.at(i).at(j).y,0)); - // painter->drawEllipse(QPointF(point2D.x,point2D.y),10,10); - // point2D = mMainWindow->getExtrCalibration()->getImagePoint(Point3f(facets3D.at(i).at((j+1)%facets3D.at(i).size()).x,facets3D.at(i).at((j+1)%facets3D.at(i).size()).y,0)); - // painter->drawEllipse(QPointF(point2D.x,point2D.y),10,10); ifacet2D.push_back(QPointF(center2D.x,center2D.y)); ifacet2D.push_back(QPointF(point2D.x,point2D.y)); - // - // painter->drawLine(circleEnd,QPointF(center2D.x,center2D.y)); - debout << "End point: (" << s1_x << ", " << s1_y << ")" << std::endl; - // area += (M_PI*pow(r,2)*angle/360); + debout << "End point: (" << s1_x << ", " << s1_y << ")" << std::endl; }else { // start punkt berechnen @@ -897,88 +728,43 @@ void TrackerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*opt point2D = mMainWindow->getExtrCalibration()->getImagePoint(cv::Point3f(s1_x,s1_y,0)); ifacet2D.push_back(QPointF(point2D.x,point2D.y)); - // facets3D[i][j] = Point2f(s1_x,m*s1_x+n); circleStart = QPointF(point2D.x,point2D.y); circleStarted = true; - // painter->drawLine(circleStart,QPointF(center2D.x,center2D.y)); debout << "Start point: (" << s1_x << ", " << s1_y << ")" << std::endl; } }else { - // if (facets3D.at(i).at(j).x > -450 && facets3D.at(i).at(j).x < 900 && facets3D.at(i).at(j).y > -450 && facets3D.at(i).at(j).y < 1250 ) - // { ifacet2D.push_back(QPointF(point2D.x,point2D.y)); area += (facets3D.at(i).at(j).x*facets3D.at(i).at((j+1)%facets3D[i].size()).y); area -= (facets3D.at(i).at((j+1)%facets3D[i].size()).x*facets3D.at(i).at(j).y); - // } } - // for( size_t k = 0; k < j; k++) - // { - // if( sqrt(pow((facets.at(i).at(j).x-facets.at(i).at(k).x),2) + - // pow((facets.at(i).at(j).y-facets.at(i).at(k).y),2)) > 100 ) - // toBig = true; - // } - //if( toBig ) - // break; } - //if( toBig ) - // continue; area *= 0.5; - area = 1.0/area;//*= 0.00002; + area = 1.0/area; area *= 10000; - // debout << "area: " << area << endl; QColor color; - // color.setRgb(125,125,125,125); - color.setHsv((255-area*25.5)<0?0:(255-area*25.5),255,255,/*toBig ? 20 : */128); + color.setHsv((255-area*25.5)<0?0:(255-area*25.5),255,255,128); -// QPointF ifacet_array[ifacet2D.size()]; QVector<QPointF> ifacet_vec; for(size_t i=0; i<ifacet2D.size(); i++) { -// ifacet_array[i] = ifacet2D.at(i); ifacet_vec.append(ifacet2D.at(i)); } - // color[0] = rand() & 255; - // color[1] = rand() & 255; - // color[2] = rand() & 255; - painter->setBrush(color);//QColor(rand()&255,rand()&255,rand()&255,128))); - painter->setPen(/*toBig ? Qt::transparent : */Qt::black); + painter->setBrush(color); + painter->setPen(Qt::black); if( ifacet2D.size() == 0 ) painter->drawEllipse(QPointF(center2D.x,center2D.y),100,100); - //else - // voronoi cell - // if (circleStarted) - // painter->drawLine(circleStart,circleEnd); - // painter->drawPolygon(ifacet_array,ifacet2D.size()); -// painter->drawConvexPolygon(ifacet_array,ifacet2D.size()); painter->drawConvexPolygon(QPolygonF(ifacet_vec)); - // fillConvexPoly(img, ifacet, color, 8, 0); - // if (circleStarted) - // QPointF cmPerPixel = mMainWindow->getImageItem()->getCmPerPixel(center2D.x,center2D.y); - // painter->drawPie(center2D.x-50/cmPerPixel.x(),center2D.y-50/cmPerPixel.y(),100/cmPerPixel.x(),100/cmPerPixel.y(),0*16,360*16); - // ifacets[0] = ifacet; - // polylines(img, ifacets, true, Scalar(), 1, CV_AA, 0); - // circle(img, centers[i], 3, Scalar(), CV_FILLED, CV_AA, 0); - // painter->setPen(Qt::PenStyle); - // painter->drawPoint(centers.at(i).x,centers.at(i).y); - // fillConvexPoly(cvarrToMat(mMainWindow->getIplImageFiltered()),ifacet_array, Scalar(125,125,125), 8, 0); // voronoi cell point painter->setBrush(Qt::black); painter->setPen(Qt::red); painter->drawEllipse(QPointF(center2D.x,center2D.y),5,5); - // if( circleStarted && circleEnded) - // i = facets3D.size(); - } - } - - - } diff --git a/src/trackerReal.cpp b/src/trackerReal.cpp index 299a54f2a..cbadaef61 100644 --- a/src/trackerReal.cpp +++ b/src/trackerReal.cpp @@ -22,10 +22,6 @@ #include "helper.h" #include "recognition.h" -// TrackPointReal::TrackPointReal() -// : mQual(0) -// { -// } TrackPointReal::TrackPointReal(const Vec3F &p, int frameNum) : Vec3F(p), mFrameNum(frameNum) { @@ -40,22 +36,6 @@ TrackPointReal::TrackPointReal(const Vec3F &p, int frameNum, const Vec2F &d) mMarkerID = -1; } -// const TrackPointReal& TrackPointReal::operator=(const Vec2F& v) -// { -// Vec2F::operator=(v); -// return *this; -// } - -// const TrackPointReal& TrackPointReal::operator+=(const Vec2F& v) -// { -// Vec2F::operator+=(v); -// return *this; -// } -// const TrackPointReal TrackPointReal::operator+(const Vec2F& v) const -// { -// return TrackPointReal(*this) += v; //Vec2F(mX + v.mX, mY + v.mY); -// } - //-------------------------------------------------------------------------- // the list index is the frame number plus mFirstFrame 0..mLastFrame-mFirstFrame @@ -83,10 +63,7 @@ bool TrackPersonReal::trackPointExist(int frame) const } const TrackPointReal& TrackPersonReal::trackPointAt(int frame) const // & macht bei else probleme, sonst mit [] zugreifbar { -// if (frame >= mFirstFrame && frame <= mLastFrame) ////!!!! muss vorher ueberprueft werden, ob es existiert!!! return at(frame-mFirstFrame); -// else -// return TrackPointReal(); } // gibt -1 zurueck, wenn frame oder naechster frame nicht existiert @@ -111,8 +88,6 @@ void TrackPersonReal::addEnd(const QPointF& pos, int frame) { Vec3F p(pos.x(), pos.y(), -1.); addEnd(p, frame); - //++mLastFrame; - //append(TrackPointReal(p, frame)); } void TrackPersonReal::addEnd(const Vec3F& pos, int frame) { @@ -137,11 +112,6 @@ TrackerReal::TrackerReal(QWidget *wParent) mMainWindow = (class Petrack*) wParent; } - -// TrackerReal::~TrackerReal() -// { -// } - // default: int imageBorderSize = 0, bool missingFramesInserted = true, bool useTrackpoints = false int TrackerReal::calculate(Tracker *tracker, ImageItem *imageItem, ColorPlot *colorPlot, int imageBorderSize, bool missingFramesInserted, bool useTrackpoints, bool alternateHeight, double altitude, bool useCalibrationCenter, @@ -153,11 +123,6 @@ int TrackerReal::calculate(Tracker *tracker, ImageItem *imageItem, ColorPlot *co if (size() > 0) { clear(); -// debout << "Recalculating real tracking data" <<endl; - } - else - { -// debout << "Calculating real tracking data" <<endl; } int i, j, f; @@ -212,7 +177,6 @@ int TrackerReal::calculate(Tracker *tracker, ImageItem *imageItem, ColorPlot *co } // fps ist nicht aussagekraeftig, da sie mgl von ausgelassenen herruehren - besser immer 25,01 fps annehmen - // out << tracker->size() << " " << mAnimation->getFPS() << endl << endl; double height; // groesse in cm int firstFrame, addFrames, anz; @@ -250,7 +214,6 @@ int TrackerReal::calculate(Tracker *tracker, ImageItem *imageItem, ColorPlot *co { tmpMissingList.removeFirst(); // frame addFrames += tmpMissingListAnz.takeFirst(); // anzahl - //tmpMissingListAnz.removeFirst(); // anzahl } } @@ -272,24 +235,9 @@ int TrackerReal::calculate(Tracker *tracker, ImageItem *imageItem, ColorPlot *co nrFor++; while ((j-nrRew >= 0) && ((*tracker)[i].at(j-nrRew).sp().z() < 0)) // nach && wird nur ausgefuehrt, wenn erstes true == size() also nicht nrRew++; - //if ((j+nrFor == tsize) && (j-nrRew < 0)) // gar keine Hoeheninfo in trj gefunden if (((j-nrRew >= 0) && (j+nrFor == tsize)) || ((j-nrRew >= 0) && (nrRew < nrFor))) // nur oder eher in Vergangenheit hoeheninfo gefunden { -//if (i == 175) // N:\tagDerNeugier\14.19.21.trc -//{ -// debout << i+1 << endl; -// debout << (*tracker)[i] << endl; -// debout << (*tracker)[i].size() << endl; -// debout << j << " " << nrRew << endl; -//// (*tracker)[i] -//// 0 138.869 2927 2928 1 -1 -1 -1 2 -//// 952.885 550.538 -1 -1 -1 100 0 0 -1 -1 -1 -//// 965.469 564.862 104.295 28.3304 316.131 100 0 0 -1 -1 -1 -//// i j nrRew: -//// 175 1 2 -//} -// in diesem if kam es zum Absturz, da j = 1 und nrRew = 2 if(fabs((*tracker)[i].at(j-nrRew).sp().z()-(*tracker)[i].at(j).sp().z()) > nrRew*40.) // 40cm { (*tracker)[i][j].setSp((*tracker)[i].at(j).sp().x(),(*tracker)[i].at(j).sp().y(),(*tracker)[i].at(j-nrRew).sp().z()); @@ -298,7 +246,6 @@ int TrackerReal::calculate(Tracker *tracker, ImageItem *imageItem, ColorPlot *co } else if (((j+nrFor != tsize) && (j-nrRew < 0)) || ((j+nrFor != tsize) && (nrFor < nrRew))) // nur oder eher in der zukunft hoeheninfo gefunden { - //debout << nrRew << " " << nrFor << " " << (*tracker)[i].at(j+nrFor).sp().z() << " " << (*tracker)[i].at(j).sp().z() << " " << endl; if(fabs((*tracker)[i].at(j+nrFor).sp().z()-(*tracker)[i].at(j).sp().z()) > nrFor*40.) // 40cm { (*tracker)[i][j].setSp((*tracker)[i].at(j).sp().x(),(*tracker)[i].at(j).sp().y(),(*tracker)[i].at(j+nrFor).sp().z()); @@ -310,7 +257,6 @@ int TrackerReal::calculate(Tracker *tracker, ImageItem *imageItem, ColorPlot *co // median genommen um zwei fehlmessungen nebeneinander nicht dazu fuehren zu lassen, dass bessere daten veraendert werden zMedian = getMedianOf3((*tracker)[i].at(j).sp().z(), (*tracker)[i].at(j-nrRew).sp().z(), (*tracker)[i].at(j+nrFor).sp().z()); // lineare interpolation - //zInter=(*tracker)[i].at(j-nrRew).sp().z()+nrRew*((*tracker)[i].at(j+nrFor).sp().z()-(*tracker)[i].at(j-nrRew).sp().z())/(nrFor+nrRew); if(fabs(zMedian-(*tracker)[i].at(j).sp().z()) > 20.*(nrFor+nrRew)) // 20cm { (*tracker)[i][j].setSp((*tracker)[i].at(j).sp().x(),(*tracker)[i].at(j).sp().y(),zMedian); @@ -402,8 +348,6 @@ int TrackerReal::calculate(Tracker *tracker, ImageItem *imageItem, ColorPlot *co { trackPersonReal.last().setMarkerID((*tracker)[i][j].getMarkerID()); } - - // firstFrame+j+addFrames //ist die kontinuierliche frame number } } @@ -418,7 +362,6 @@ int TrackerReal::calculate(Tracker *tracker, ImageItem *imageItem, ColorPlot *co // border unberuecksichtigt for (f = 1; f <= anz; ++f) { - //trackPersonReal.addEnd((*tracker)[i][j].sp()+f*((*tracker)[i][j+1].sp()-(*tracker)[i][j].sp())/(anz+1), -1); // -1 zeigt an, dass nur interpoliert sp = (*tracker)[i][j].sp()+f*((*tracker)[i][j+1].sp()-(*tracker)[i][j].sp())/(anz+1); if (useCalibrationCenter) trackPersonReal.addEnd(Vec3F(sp.x()+center.x(), center.y()-sp.y(), altitude-sp.z()), firstFrame+j); @@ -441,14 +384,12 @@ int TrackerReal::calculate(Tracker *tracker, ImageItem *imageItem, ColorPlot *co pos2 = (imageItem->getPosReal(((*tracker)[i][j+1]+moveDir+br).toQPointF(), height) - pos)/(anz+1); for (f = 1; f <= anz; ++f) trackPersonReal.addEnd(pos+f*pos2, -1); // -1 zeigt an, dass nur interpoliert - //addFrames += anz; } } } else if (tmpMissingList.first() < firstFrame) // while, wenn nicht kontinuierlich waere { tmpMissingList.removeFirst(); // frame - //addFrames += tmpMissingListAnz.takeFirst(); // anzahl tmpMissingListAnz.removeFirst(); // anzahl } } @@ -465,7 +406,6 @@ int TrackerReal::calculate(Tracker *tracker, ImageItem *imageItem, ColorPlot *co if ((j < numBorderPoints) && ((trackPersonReal.at(j).z()-trackPersonReal.at(j-1).z()) > maxHeightDiff)) { delNumFront = j; - //debout << i << " " << j << " " <<trackPersonReal.at(j).z()-trackPersonReal.at(j-1).z() <<endl; } else if (((tsize - numBorderPoints) < j) && ((trackPersonReal.at(j).z()-trackPersonReal.at(j-1).z()) > maxHeightDiff)) { @@ -591,17 +531,6 @@ void TrackerReal::exportTxt(QTextStream &out, bool alternateHeight, bool useTrac else scale = 1.; -// if (useTrackpoints) -// { -// for (int i = 0; i < size(); ++i) -// for (int j = 0; j < at(i).size(); ++j) -// // Umrechnung in coordSystem fehlt, auch camera altitude unberuecksichtigt!!! -// out << i+1 << " " << at(i).firstFrame()+j << " " << at(i).at(j).x() << " " << at(i).at(j).y() << " " << at(i).at(j).z()*scale <<endl; -// war: out << i+1 << " " << at(i).firstFrame()+j << " " << at(i).at(j) << " " << at(i).at(j).z()*scale <<endl; -// } //<< " " << tp.qual(); -// else -// { - // out << *this; QProgressDialog progress("Export TXT-File",nullptr,0,size(),mMainWindow->window()); progress.setWindowTitle("Export .txt-File"); progress.setWindowModality(Qt::WindowModal); @@ -619,7 +548,6 @@ void TrackerReal::exportTxt(QTextStream &out, bool alternateHeight, bool useTrac for (int j = 0; j < at(i).size(); ++j) { out << i+1 << " " << at(i).firstFrame()+j << " " << at(i).at(j).x()*scale << " " << at(i).at(j).y()*scale << " "; - //out << i+1 << " " << at(i).firstFrame()+j << " " << at(i).at(j).x()*scale << " " << at(i).at(j).y()*scale << " "; if (alternateHeight || useTrackpoints) out << at(i).at(j).z()*scale; @@ -640,14 +568,6 @@ void TrackerReal::exportTxt(QTextStream &out, bool alternateHeight, bool useTrac } } -// inline QTextStream& operator<<(QTextStream& s, const TrackerReal& trackerReal) -// { -// for (int i = 0; i < trackerReal.size(); ++i) -// for (int j = 0; j < trackerReal.at(i).size(); ++j) -// s << i+1 << " " << trackerReal.at(i).firstFrame()+j << " " << trackerReal.at(i).at(j) << " " << trackerReal.at(i).height() <<endl; //<< " " << tp.qual(); -// return s; -// } - // old - not all export options supported!!!! void TrackerReal::exportDat(QTextStream &out, bool alternateHeight, bool useTrackpoints) // fuer gnuplot { @@ -697,7 +617,6 @@ void TrackerReal::exportXml(QTextStream &outXml, bool alternateHeight, bool useT { int i, j, largestLastFr = largestLastFrame(); double z; - //TrackPointReal tp; int defaultPersonHeight = 176; QProgressDialog progress("Export XML-File",nullptr,0,largestLastFr,mMainWindow->window()); @@ -708,7 +627,6 @@ void TrackerReal::exportXml(QTextStream &outXml, bool alternateHeight, bool useT progress.setLabelText(QString("Export tracking data ...")); qApp->processEvents(); - // j = person outXml << " <shape>" << Qt::endl; for (j = 0; j < size(); ++j) { @@ -749,38 +667,4 @@ void TrackerReal::exportXml(QTextStream &outXml, bool alternateHeight, bool useT } outXml << " </frame>" << Qt::endl; } - - // alte Version der trav datei -// // j = person -// outXml << " <persons>" << endl; -// for (j = 0; j < size(); ++j) -// { -// outXml << " " << j+1 << " " << at(j).height() << endl; -// } -// outXml << " </persons>" << endl <<endl; - -// // i = frame; j = person -// for (i = smallestFirstFrame(); i <= largestLastFr; ++i) -// { -// outXml << " <data>" << endl; -// for (j = 0; j < size(); ++j) -// { -// if (at(j).trackPointExist(i)) -// { -// // z-wert ist hier ausnahmsweise nicht der kopf, sondern der boden, die prsonengroesse wird dem obigem person-datenentnommen -// //personID, Frame ID(?) , X , Y , Z -// if (useTrackpoints) -// z = at(j).trackPointAt(i).z()+at(j).height(); -// else -// { -// if (alternateHeight) -// z = at(j).trackPointAt(i).z()-at(j).height(); -// else -// z = 0; //at(j).height(); -// } -// outXml << " " << j+1 << " " << i << " " << at(j).trackPointAt(i) << " " << z << " 1" << endl; // z Koordinate ist Boden -// } -// } -// outXml << " </data>" << endl; -// } } diff --git a/src/trackingRoiItem.cpp b/src/trackingRoiItem.cpp index 6fd44b613..2a484a9fc 100644 --- a/src/trackingRoiItem.cpp +++ b/src/trackingRoiItem.cpp @@ -36,38 +36,12 @@ TrackingRoiItem::TrackingRoiItem(QWidget *wParent, QGraphicsItem *parent) setAcceptHoverEvents(true); setFlags(ItemIsMovable); // default in control hide(); // default in control - // setEnabled(false); // all mouse events connot access this item, but it will be seen } -// QRectF RecognitionRoiItem::boundingRect() const -// { -// // QRectF rect = QGraphicsRectItem::boundingRect(); -// // debout << rect.x() << " " << rect.y() << " " << rect.width() << " " << rect.height() <<endl; -// return QGraphicsRectItem::boundingRect(); -// } -// // 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, -// // aber beim verkleinern des scrollbereichs nur der teil von coord neu gezeichnet -// QRectF RecognitionRoiItem::boundingRect() const -// { -// // bounding box wird in lokalen koordinaten angegeben!!! (+-10 wegen zahl "1") -// if (mControlWidget->getCalibCoordShow()) -// return QRectF(-110., -110., 220., 220.); -// else -// return QRectF(0., 0., 0., 0.); - -// // sicher ware diese boundingbox, da alles -// // return QRectF(xMin, yMin, xMax-xMin, yMax-yMin); -// // eigentlich muesste folgende Zeile reichen, aber beim ranzoomen verschwindet dann koord.sys. -// // return QRectF(mControlWidget->getCalibCoordTransX()/10.-scale, mControlWidget->getCalibCoordTransY()/10.-scale, 2*scale, 2*scale); -// } - void TrackingRoiItem::mousePressEvent(QGraphicsSceneMouseEvent * event) { if (!mControlWidget->getTrackRoiFix()) { - //mPressRect = rect(); mPressRect = QRect(myRound(rect().left()), myRound(rect().top()), myRound(rect().width()), myRound(rect().height())); mPressPos = event->pos(); if ((event->pos()).x() < DISTANCE_TO_BORDER+mPressRect.x()) @@ -142,7 +116,6 @@ void TrackingRoiItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) if (!mControlWidget->getTrackRoiFix()) { QImage *img = mMainWindow->getImage(); - //QPointF diff = event->pos()-mPressPos; QPoint diff = QPoint(myRound((event->pos()-mPressPos).x()), myRound((event->pos()-mPressPos).y())); // raender des bildes nicht ueberscheiten // swappen des rechtecks vermeiden, damit keine negativen width... @@ -179,7 +152,6 @@ void TrackingRoiItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } if (mPressLocation == topLeft) setRect(mPressRect.x()+diff.x(), mPressRect.y()+diff.y(), mPressRect.width()-diff.x(), mPressRect.height()-diff.y()); - // setRect(mPressRect.x()+diff.x(), mPressRect.y()+mPressRect.x()+diff.x(), mPressRect.y()+diff.y(), mPressRect.width()-diff.x(), mPressRect.height()-diff.y()diff.y(), mPressRect.width()-diff.x(), mPressRect.height()-diff.y()); else if (mPressLocation == topRight) setRect(mPressRect.x(), mPressRect.y()+diff.y(), mPressRect.width()+diff.x(), mPressRect.height()-diff.y()); else if (mPressLocation == bottomLeft) @@ -202,19 +174,6 @@ void TrackingRoiItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) QGraphicsRectItem::mouseMoveEvent(event); } -// // waere noetig, da sonst beim ersten pixel, wenn man objekt betritt, der cursor noch nicht richtig ist -// void RecognitionRoiItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -// { -// hoverMoveEvent(event); -// QGraphicsRectItem::hoverEnterEvent(event); -// } -// void RecognitionRoiItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -// { -// //hoverMoveEvent(event); -// setCursor(Qt::CrossCursor); -// QGraphicsRectItem::hoverLeaveEvent(event); -// } - // event, of moving mouse void TrackingRoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { @@ -230,7 +189,6 @@ void TrackingRoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) if (!mControlWidget->getTrackRoiFix()) { - //QRectF r = rect(); QRect r = QRect(myRound(rect().left()), myRound(rect().top()), myRound(rect().width()), myRound(rect().height())); if ((event->pos()).x() < DISTANCE_TO_BORDER+r.x()) { @@ -268,8 +226,9 @@ void TrackingRoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) // check rect because bordersize changes and without mouse event nothing changes the rect void TrackingRoiItem::checkRect() { + // not QImage *img = mMainWindow->getImage(); as size is not adapted yet cv::Mat img = mMainWindow->getImageFiltered(); - // nicht QImage *img = mMainWindow->getImage(); da groesse noch nicht angepasst + if (!img.empty()) { QRect r = QRect(myRound(rect().left()), myRound(rect().top()), myRound(rect().width()), myRound(rect().height())); @@ -286,7 +245,6 @@ void TrackingRoiItem::checkRect() setRect(r.x(), -mMainWindow->getImageBorderSize(), r.width(), r.height()+(mMainWindow->getImageBorderSize()+r.y())); if (r.x()+mMainWindow->getImageBorderSize()+r.width() > img.cols) { - //debout << r.x()+mMainWindow->getImageBorderSize()+r.width() << endl; setRect(r.x(), r.y(), img.cols-r.x()-mMainWindow->getImageBorderSize(), r.height()); } if (r.y()+mMainWindow->getImageBorderSize()+r.height() > img.rows) diff --git a/src/vector.cpp b/src/vector.cpp index 455d7f414..57fce64ea 100644 --- a/src/vector.cpp +++ b/src/vector.cpp @@ -37,32 +37,6 @@ Vec3F::Vec3F(double x, double y, double z) mZ(z) { } -// Vec3F::Vec3F(const QPointF& v) -// : mX(v.x()), -// mY(v.y()) -// { -// } -// Vec3F::Vec3F(const CvPoint* v) -// : mX(v->x), -// mY(v->y) -// { -// } - -// CvPoint Vec3F::toCvPoint() const -// { -// CvPoint p; -// p.x = myRound(mX); -// p.y = myRound(mY); -// return p; -// } -// QPoint Vec3F::toQPoint() const -// { -// return QPoint(myRound(mX), myRound(mY)); -// } -// QPointF Vec3F::toQPointF() const -// { -// return QPointF(mX, mY); -// } double Vec3F::x() const { @@ -97,13 +71,6 @@ void Vec3F::set(double x, double y, double z) mZ = z; } -// automatisch vom compiler (komponentenweise) -//Vec3F Vec3F::operator=(const Vec3F& v) -// Vec3F Vec3F::operator=(const CvPoint *v) -// { -// return Vec3F(v->x, v->y); -// } - Vec3F Vec3F::operator+(const Vec3F& v) const { return Vec3F(mX + v.mX, mY + v.mY, mZ + v.mZ); @@ -150,11 +117,6 @@ double Vec3F::operator*(const Vec3F& v) const return mX * v.mX + mY * v.mY; } -// double Vec3F::operator%(const Vec3F& v) const -// { -// return mX * v.mY - mY * v.mX; -// } - bool Vec3F::operator==(const Vec3F& v) const { return mX == v.mX && mY == v.mY && mZ == v.mZ; @@ -170,11 +132,6 @@ double Vec3F::length() const return sqrt(mX*mX+mY*mY+mZ*mZ); } -// double Vec3F::angle() const -// { -// return atan2(mY, mX); -// } - Vec3F Vec3F::unit() const { if(mX == 0 && mY == 0) @@ -184,10 +141,6 @@ Vec3F Vec3F::unit() const return Vec3F(mX / len, mY / len, mZ / len); } -// Vec3F Vec3F::normal() const -// { -// return Vec3F(-mY, mX); -// } void Vec3F::normalize() { double len = length(); @@ -204,21 +157,6 @@ double Vec3F::distanceToPoint(const Vec3F& p) const return ((operator-)(p)).length(); } -// double Vec3F::distanceToLine(const Vec3F& p1, const Vec3F& p2) const -// { -// Vec3F n = (p2-p1).normal(); // normal vector -// n.normalize(); // normalized normal vector -// return fabs((operator*)(n) - p1*n); -// } -// double Vec3F::angleBetweenVec(const Vec3F& v) const -// { -// return acos((operator*)(v)/(length()*v.length())); -// } - -// Vec3F Vec3F::fromAngle(double angle) -// { -// return Vec3F(cos(angle), sin(angle)); -// } //--------------------------------------------------------------------------- @@ -303,7 +241,6 @@ void Vec2F::set(double x, double y) } // automatisch vom compiler (komponentenweise) -//Vec2F Vec2F::operator=(const Vec2F& v) Vec2F Vec2F::operator=(const CvPoint *v) { return Vec2F(v->x, v->y); @@ -317,7 +254,7 @@ const Vec2F& Vec2F::operator+=(const Vec2F& v) } const Vec2F Vec2F::operator+(const Vec2F& v) const { - return Vec2F(*this) += v; //Vec2F(mX + v.mX, mY + v.mY); + return Vec2F(*this) += v; } const Vec2F Vec2F::operator-=(const Vec2F& v) @@ -325,11 +262,10 @@ const Vec2F Vec2F::operator-=(const Vec2F& v) mX -= v.mX; mY -= v.mY; return *this; - // return Vec2F(mX - v.mX, mY - v.mY); } const Vec2F Vec2F::operator-(const Vec2F& v) const { - return Vec2F(*this) -= v; //Vec2F(mX - v.mX, mY - v.mY); + return Vec2F(*this) -= v; } Vec2F Vec2F::operator-() const @@ -352,11 +288,6 @@ double Vec2F::operator*(const Vec2F& v) const return mX * v.mX + mY * v.mY; } -// double Vec2F::operator%(const Vec2F& v) const // eher det -// { -// return mX * v.mY - mY * v.mX; -// } - bool Vec2F::operator==(const Vec2F& v) const { return mX == v.mX && mY == v.mY; diff --git a/src/view.cpp b/src/view.cpp index ebc1b7b41..a8d26a9a5 100644 --- a/src/view.cpp +++ b/src/view.cpp @@ -34,56 +34,13 @@ GraphicsView::GraphicsView(ViewWidget *viewWidget) setTransformationAnchor(AnchorUnderMouse); // for wheel setResizeAnchor(AnchorUnderMouse); // for scroll? - - // alignment kann man nicht komplett ausstellen! - //transformationAnchor -// QGraphicsView::NoAnchor -// QGraphicsView::AnchorViewCenter -// QGraphicsView::AnchorUnderMouse } -// void mousePressEvent ( QMouseEvent * event ) -// { -// if (event->button() == Qt::RightButton) { -// setDragMode(ScrollHandDrag); -// } -// } -// void mouseReleaseEvent ( QMouseEvent * event ) -// { -// if (event->button() == Qt::RightButton) { -// setDragMode(RubberBandDrag); -// } -// } -// void mouseMoveEvent(QMouseEvent *event) -// { -// if (event->buttons() & Qt::RightButton) -// setDragMode(QGraphicsView::ScrollHandDrag); -// } - void GraphicsView::wheelEvent(QWheelEvent * event) { QPoint numDegrees = event->angleDelta() / 8; - // hier koennte man einstellen, dass das pixel unter cursor stehen bleibt das dort bereits steht - // (dorhin gezoomt wird, wo mouse steht!!!) - // nicht noetig, denn es gibt: setTransformationAnchor(AnchorUnderMouse); (siehe constructor) - //fitInView(rect) - //ensureVisible(rect) - - -// QMatrix mat = matrix(); -// debout << "----------------------" <<endl; -// debout << mat.m11() << " " << mat.m22() <<endl; -// QPointF sp = mapToScene(event->pos()); -// debout << sp.x() << " " << sp.y() <<endl; -// debout << event->pos().x() << " " << event->pos().y() <<endl; -// // debout << event->globalPos().x() << " " << event->globalPos().x() <<endl; -// // QRectF sr = sceneRect(); -// // debout << sr.x() << " " << sr.width() <<endl; -// debout << numDegrees/2 <<endl; -// // centerOn(mapToScene(event->pos())); - if (event->modifiers() == Qt::ShiftModifier) // nur shift zugelassen ... { // Check if horizontal scroll @@ -100,38 +57,8 @@ void GraphicsView::wheelEvent(QWheelEvent * event) else mViewWidget->zoomOut(numDegrees.y()/2); } - -// mat = matrix(); -// debout << mat.m11() << " " << mat.m22() <<endl; - -// qreal factor = matrix().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width(); -// if (factor < 0.07 || factor > 100) -// return; - -// scale(scaleFactor, scaleFactor); - -// QGraphicsView::wheelEvent(event); LANGE NACH GESUCHT: UNBEDINGT RAUS, DA NACH ZOOM NOCH EIN SCROLLEN GEMACHT WIRD } -//void GraphicsView::mouseReleaseEvent(QMouseEvent *event) -//{ -// if (event->button() == Qt::LeftButton) -// { - -// } -// else if (event->button() == Qt::RightButton) -// { -// emit mouseRightClick(mapToScene(event->pos())); -// } -// else if (event->button() == Qt::MiddleButton) -// { - -// } -// scene()->update(); - -// //QGraphicsScene::mouseReleaseEvent(event); -//} - void GraphicsView::mouseDoubleClickEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) @@ -174,7 +101,6 @@ void GraphicsView::mouseDoubleClickEvent(QMouseEvent *event) void GraphicsView::keyPressEvent(QKeyEvent *event) { -// debout << "key: " << event->key() << endl; // forward the arrow keys for handling in petrack player switch(event->key()) { @@ -214,13 +140,9 @@ ViewWidget::ViewWidget(QWidget *parent) { mMainWindow = (class Petrack*) parent; setContentsMargins(0, 0, 0, 0); - //setFrameStyle(Sunken | StyledPanel); mGraphicsView = new GraphicsView(this); mGraphicsView->setRenderHint(QPainter::Antialiasing, false); mGraphicsView->setDragMode(QGraphicsView::ScrollHandDrag); //RubberBandDrag -// mGraphicsView->setFrameStyle(QFrame::StyledPanel|QFrame::Plain); -// mGraphicsView->setLineWidth(0); -// mGraphicsView->setMidLineWidth(0); int size = style()->pixelMetric(QStyle::PM_ToolBarIconSize); QSize iconSize(size, size); @@ -247,7 +169,6 @@ ViewWidget::ViewWidget(QWidget *parent) rotateRightIcon->setIcon(QPixmap(":/rotright")); rotateRightIcon->setIconSize(iconSize); mRotateSlider = new QSlider; - //mRotateSlider->setOrientation(Qt::Horizontal); mRotateSlider->setMinimum(-180); //-360 mRotateSlider->setMaximum(180); // 360 mRotateSlider->setValue(0); @@ -326,10 +247,6 @@ void ViewWidget::fitInView() void ViewWidget::fitInROI(QRectF rect) { - - //QRect rect(myRound(mRecognitionRoiItem->rect().x()+getImageBorderSize()), myRound(mRecognitionRoiItem->rect().y()+getImageBorderSize()), myRound(mRecognitionRoiItem->rect().width()), myRound(mRecognitionRoiItem->rect().height())); - - mGraphicsView->fitInView(rect, Qt::KeepAspectRatio); // Qt::KeepAspectRatioByExpanding wuerde nur in eine dimension passend machen // doesnt work: mGraphicsView->fitInView(mGraphicsView->sceneRect(), Qt::KeepAspectRatio); // two times, while in the first run possibly the scrollbars have been there for calculation QTransform matrix = mGraphicsView->transform(); @@ -347,22 +264,9 @@ void ViewWidget::setupMatrix() matrix.scale(scale, scale); matrix.rotate(mRotateSlider->value()); -// debout << matrix.m11() << " " << matrix.m12() <<endl; -// debout << matrix.m21() << " " << matrix.m22() <<endl; -// debout << matrix.dx() << " " << matrix.dy() <<endl; mGraphicsView->setTransform(matrix); } -// void View::print() -// { -// QPrinter printer; -// QPrintDialog dialog(&printer, this); -// if (dialog.exec() == QDialog::Accepted) { -// QPainter painter(&printer); -// mGraphicsView->render(&painter); -// } -// } - void ViewWidget::zoomIn(int i) //default i = 1 { mZoomSlider->setValue(mZoomSlider->value() + i); -- GitLab