20 #ifndef TRACKINGSTREAM_HPP 21 #define TRACKINGSTREAM_HPP 23 #include "ColorSpace.hpp" 24 #include "DisplayFrameType.hpp" 25 #include "KFBallTracker.hpp" 26 #include "KFPrediction.hpp" 28 #include <QBasicTimer> 31 #include <opencv2/videoio.hpp> 35 #define SETT_DEF_DISPLAYTYPE 0 36 #define SETT_DEF_XYCOVAR 1.0 37 #define SETT_DEF_FOV 56 38 #define SETT_DEF_PROJW 50 39 #define SETT_DEF_PROJH 50 40 #define SETT_DEF_BALLZ 0 149 void frameReady(
const cv::Mat &,
enum ColorSpace=TS_BGR);
169 void start(
int cam = 0);
171 void start(QString fname);
240 void processThresh(
const cv::Mat &,
enum ColorSpace=TS_GRAY);
242 void processBlur(
const cv::Mat &,
enum ColorSpace=TS_BGR);
330 #endif // TRACKINGSTREAM_HPP void setFov(int fov)
Set the camera FOV.
Definition: TrackingStream.cpp:69
QSize mProjSize
The dimensions (in real world units) of the projector screen.
Definition: TrackingStream.hpp:77
int mFps
The FPS of the video stream (=0 for webcam stream)
Definition: TrackingStream.hpp:133
void changeBlurSize(double blurSize)
Set the strength of blur in preprocessing step.
Definition: TrackingStream.cpp:328
cv::Point2f projectorToImage(cv::Point3d prP)
projectorToImage converts projector (world) coords to image coords
Definition: TrackingStream.cpp:218
void changeMinRadius(double radius)
Set the min viable radius of a ball blob.
Definition: TrackingStream.cpp:338
void processThresh(const cv::Mat &, enum ColorSpace=TS_GRAY)
Process a "thresholded" frame, with white blobs.
Definition: TrackingStream.cpp:375
void timerEvent(QTimerEvent *)
Process a timer event: Read the next frame, process it, emit it.
Definition: TrackingStream.cpp:398
void processContour(const cv::Mat &, enum ColorSpace=TS_GRAY)
Process a "contour" frame, which marks contours.
Definition: TrackingStream.cpp:391
void changeProjWidth(int width)
changeProjWidth sets the width of the projector screen (in inches)
Definition: TrackingStream.cpp:310
void changeDisplayFrameType(QString s)
Set the type of video frame to actually be emitted.
Definition: TrackingStream.cpp:358
void started()
Signal emitted when stream starts processing.
void ballProjSpotted(TrackingBall ball)
A ball has been spotted (proj coordinates)
void processBlur(const cv::Mat &, enum ColorSpace=TS_BGR)
Process a "blurred" frame.
Definition: TrackingStream.cpp:384
bool mProjReady
Whether there is enough projector data for transform.
Definition: TrackingStream.hpp:130
bool cameraValid(int idx)
Check if a camera index is valid.
Definition: TrackingStream.cpp:175
void pauseStream()
Pause the current video stream.
Definition: TrackingStream.cpp:280
void setProjSize(const QSize &projSize)
Set the size of the projector (in real units)
Definition: TrackingStream.cpp:227
KFBallTracker mTracker
The ball tracker; we give it frames, it gives us ball predictions.
Definition: TrackingStream.hpp:138
void changeBallZ(double z)
changeBallZ sets the z-plane that the ball is thrown in (in inches)
Definition: TrackingStream.cpp:322
cv::Mat mFrame
The present frame received from the video stream.
Definition: TrackingStream.hpp:122
void start(int cam=0)
Start a stream with a camera input.
Definition: TrackingStream.cpp:232
void predictionBall(KFPrediction pred)
Alert the stream to a predicted ball.
Definition: TrackingStream.cpp:296
void refreshCameraMatrix()
Update the camera matrices.
Definition: TrackingStream.cpp:75
void changeClipTrack(bool checked)
Set whether or not tracking is clipped to projector.
Definition: TrackingStream.cpp:290
void processVideoFrame(const cv::Mat &mat, ColorSpace=TS_BGR)
Process a "video" frame, which is raw video input.
Definition: TrackingStream.cpp:368
std::vector< cv::Point2f > mBallPlane
The bounding polygon of image coordinates which project to ball coordinates that live in the projecto...
Definition: TrackingStream.hpp:102
cv::Mat mCameraMatrix
The intrinsic camera matrix.
Definition: TrackingStream.hpp:107
void updateProjectorCoordinates(std::vector< cv::Point2f > corners)
Set the in-image coordinates of the projector corners.
Definition: TrackingStream.cpp:91
QBasicTimer mTimer
Timer for processing frames.
Definition: TrackingStream.hpp:51
void ballSpotted(TrackingBall ball)
A ball has been spotted (image coordinates)
A ball which has been tracked by the software.
Definition: TrackingBall.hpp:30
QScopedPointer< cv::VideoCapture > mVideoHandle
The handler for the input video stream.
Definition: TrackingStream.hpp:56
double mBallZ
The distance of the ball plane from the projector plane (in real world units)
Definition: TrackingStream.hpp:82
void changeXYCovariance(double sigma)
Set the covariance in predicted X, Y (a KF parameter)
Definition: TrackingStream.cpp:353
Contains most of the logic for live-tracking objects.
Definition: KFBallTracker.hpp:50
void stop()
Terminate the video stream.
Definition: TrackingStream.cpp:275
void frameReady(const cv::Mat &, enum ColorSpace=TS_BGR)
frameReady emits a cv::Mat of specified color space for processing
void changeMaxRadius(double radius)
Set the max viable radius of a ball blob.
Definition: TrackingStream.cpp:343
An object which owns some sort of input video stream, manages running it (and any tracking...
Definition: TrackingStream.hpp:47
void refreshProjectorMatrices()
Update the projector transformation matrices.
Definition: TrackingStream.cpp:133
bool mStreamPaused
Whether the stream is currently paused.
Definition: TrackingStream.hpp:131
cv::Point2f imageToProjector(cv::Point2f imP, double z=0)
Convert image coordinates to projector coordinates.
Definition: TrackingStream.cpp:180
Object which represents a prediction from the Kalman filter.
Definition: KFPrediction.hpp:34
void changeProjectorCorners(std::vector< cv::Point2f > corners)
Set the location of projector corners in the image.
Definition: TrackingStream.cpp:285
std::vector< cv::Point2f > mCorners
The location of projector coordinates in the image.
Definition: TrackingStream.hpp:96
void changeGravConstant(double g)
Set the accel due to gravity g.
Definition: TrackingStream.cpp:348
bool mClipTrack
Whether we should clip tracking to the proj screen.
Definition: TrackingStream.hpp:142
cv::Mat mTVector
The camera's extrinsic(?) translation vector.
Definition: TrackingStream.hpp:117
cv::Mat mRMatrix
The camera's extrinsic(?) rotation matrix.
Definition: TrackingStream.hpp:112
int mFov
The FOV of the camera.
Definition: TrackingStream.hpp:68
void ballProjPredicted(KFPrediction pred)
A ball has been predicted (proj coordinates)
QSize mVideoSize
The dimensions of the video stream.
Definition: TrackingStream.hpp:72
void changeThreshVal(double thresh)
Set the threshold in preprocessing step.
Definition: TrackingStream.cpp:333
void changeProjHeight(int height)
changeProjHeight sets the height of the projector screen (in inches)
Definition: TrackingStream.cpp:316
void ballLost()
We have lost track of the ball entirely.
void startProcess()
Start the tracking process.
bool mDisplayVideo
Whether we should display video or not.
Definition: TrackingStream.hpp:139
void ballPredicted(KFPrediction pred)
A ball has been predicted (image coordinates)
QPolygonF mProjScreen
Region to crop to if mClipTrack is on.
Definition: TrackingStream.hpp:141
DisplayFrameType mEmitFrameType
The type (e.g.
Definition: TrackingStream.hpp:127
bool mStarted
Whether the video stream is started.
Definition: TrackingStream.hpp:129
cv::Mat mProjCornersCamera
The location of projector coordinates in world (real units)
Definition: TrackingStream.hpp:89