LiveFit
Track and plot projectiles for in-class demonstration
TrackVideoWidget.hpp
1 /*
2  * LiveFit
3  * Copyright (C) 2016 The University of Georgia
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef TRACKVIDEOWIDGET_H
21 #define TRACKVIDEOWIDGET_H
22 
23 #define UL_CORNER 0
24 #define BL_CORNER 1
25 #define BR_CORNER 2
26 #define UR_CORNER 3
27 
28 #include "KFPrediction.hpp"
29 #include "TrackingBall.hpp"
30 #include "ui_TrackVideoWidget.h"
31 #include <opencv2/core.hpp>
32 #include <QWidget>
33 
40 class TrackVideoWidget : public QWidget
41 {
42  Q_OBJECT
43 
45  QList<TrackingBall> mBalls;
47  QList<KFPrediction> mPreds;
48 
49 public:
50  explicit TrackVideoWidget(QWidget *parent = 0);
51 
53  void updateCorners();
55  QList<QPoint> getCorners();
56 
57 signals:
59  void resized(QSize size);
61  void cornersChanged(std::vector<cv::Point2f>);
62 
63 public slots:
65  void setImage(const QImage &image);
66 
68  void setCorners(QList<QPoint> corners);
69 
71  void ulCornerDropped(QPoint point);
73  void blCornerDropped(QPoint point);
75  void brCornerDropped(QPoint point);
77  void urCornerDropped(QPoint point);
78 
80  void pushBall(TrackingBall ball);
82  void pushPred(KFPrediction pred);
83 protected:
84 
86  void paintEvent(QPaintEvent* event);
88  void resizeEvent(QResizeEvent *event);
89 private:
91  Ui::trackVideoWidget ui;
93  QImage currentFrame;
94 
95 };
96 
97 #endif // TRACKVIDEOWIDGET_HPP
Displays a video stream and tracking data.
Definition: TrackVideoWidget.hpp:40
void setImage(const QImage &image)
Set the current display image of the widget to image.
Definition: TrackVideoWidget.cpp:87
void setCorners(QList< QPoint > corners)
Set all 4 corners of the projector screen (in-frame coordinates)
Definition: TrackVideoWidget.cpp:101
void cornersChanged(std::vector< cv::Point2f >)
Signal sent whenever the corners of the projector in frame change.
void ulCornerDropped(QPoint point)
Called when the UL corner widget is dropped at point.
Definition: TrackVideoWidget.cpp:121
void resizeEvent(QResizeEvent *event)
Called on resize event;.
Definition: TrackVideoWidget.cpp:82
void brCornerDropped(QPoint point)
Called when the BR corner widget is dropped at point.
Definition: TrackVideoWidget.cpp:131
QImage currentFrame
Current video frame to be displayed by widget.
Definition: TrackVideoWidget.hpp:93
QList< KFPrediction > mPreds
A list of KF prediction data in the frame.
Definition: TrackVideoWidget.hpp:47
A ball which has been tracked by the software.
Definition: TrackingBall.hpp:30
void blCornerDropped(QPoint point)
Called when the BL corner widget is dropped at point.
Definition: TrackVideoWidget.cpp:126
Object which represents a prediction from the Kalman filter.
Definition: KFPrediction.hpp:34
QList< QPoint > getCorners()
Return the list of projector corners in image coordinates.
Definition: TrackVideoWidget.cpp:164
void paintEvent(QPaintEvent *event)
Called on paint event; drawing logic goes here (Draw frame, points, etc)
Definition: TrackVideoWidget.cpp:45
void resized(QSize size)
Signal sent whenever the widget is resized.
void pushPred(KFPrediction pred)
Push the KFPrediction pred to the list of predictions.
Definition: TrackVideoWidget.cpp:114
void urCornerDropped(QPoint point)
Called when the UR corner widget is dropped at point.
Definition: TrackVideoWidget.cpp:136
Ui::trackVideoWidget ui
UI data edited in QDesigner; see TrackVideoWidget.ui.
Definition: TrackVideoWidget.hpp:91
void updateCorners()
Refresh the corners (ie send signal that corners changed to listeners)
Definition: TrackVideoWidget.cpp:142
void pushBall(TrackingBall ball)
Push the TrackingBall ball to the list of balls.
Definition: TrackVideoWidget.cpp:93
QList< TrackingBall > mBalls
A list of raw ball contour data in the frame.
Definition: TrackVideoWidget.hpp:45