SLProject
4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
|
CVTrackedFeatures is the main part of the AR Christoffelturm scene. More...
#include <CVTrackedFeatures.h>
Classes | |
struct | SLFeatureMarker2D |
Data of a 2D marker image. More... | |
struct | SLFrameData |
Feature date for a video frame. More... | |
Public Member Functions | |
CVTrackedFeatures (string markerFilename) | |
~CVTrackedFeatures () | |
Show statistics if program terminates. More... | |
bool | track (CVMat imageGray, CVMat image, CVCalibration *calib) final |
bool | forceRelocation () |
CVDetectDescribeType | type () |
void | forceRelocation (bool fR) |
void | type (CVDetectDescribeType ddType) |
Setter of the feature detector & descriptor type. More... | |
Public Member Functions inherited from CVTracked | |
CVTracked () | |
virtual | ~CVTracked ()=default |
void | drawDetection (bool draw) |
bool | isVisible () |
bool | drawDetection () |
CVMatx44f | objectViewMat () |
Private Member Functions | |
void | loadMarker (string markerFilename) |
Loads the marker image form the filesystem. More... | |
void | initFeaturesOnMarker () |
void | relocate () |
void | tracking () |
void | drawDebugInformation (bool drawDetection) |
void | transferFrameData () |
void | detectKeypointsAndDescriptors () |
CVVDMatch | getFeatureMatches () |
bool | calculatePose () |
void | optimizeMatches () |
bool | trackWithOptFlow (CVMat rvec, CVMat tvec) |
Private Attributes | |
cv::Ptr< cv::DescriptorMatcher > | _matcher |
Descriptor matching algorithm. More... | |
CVCalibration * | _calib |
Current calibration in use. More... | |
int | _frameCount |
NO. of frames since process start. More... | |
bool | _isTracking |
True if tracking. More... | |
SLFeatureMarker2D | _marker |
2D marker data More... | |
SLFrameData | _currentFrame |
The current video frame data. More... | |
SLFrameData | _prevFrame |
The previous video frame data. More... | |
bool | _forceRelocation |
Force relocation every frame (no opt. flow tracking) More... | |
CVFeatureManager | _featureManager |
Feature detector-descriptor wrapper instance. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from CVTracked | |
static cv::Matx44f | createGLMatrix (const CVMat &tVec, const CVMat &rVec) |
Create an OpenGL 4x4 matrix from an OpenCV translation & rotation vector. More... | |
static void | createRvecTvec (const CVMatx44f &glMat, CVMat &tVec, CVMat &rVec) |
Creates the OpenCV rvec & tvec vectors from an column major OpenGL 4x4 matrix. More... | |
static CVMatx44f | calcObjectMatrix (const CVMatx44f &cameraObjectMat, const CVMatx44f &objectViewMat) |
static CVVec3f | averageVector (vector< CVVec3f > vectors, vector< float > weights) |
static SLQuat4f | averageQuaternion (vector< SLQuat4f > quaternions, vector< float > weights) |
static void | resetTimes () |
Resets all static variables. More... | |
Static Public Attributes inherited from CVTracked | |
static AvgFloat | trackingTimesMS |
Averaged time for video tracking in ms. More... | |
static AvgFloat | detectTimesMS |
Averaged time for video feature detection & description in ms. More... | |
static AvgFloat | detect1TimesMS |
Averaged time for video feature detection subpart 1 in ms. More... | |
static AvgFloat | detect2TimesMS |
Averaged time for video feature detection subpart 2 in ms. More... | |
static AvgFloat | matchTimesMS |
Averaged time for video feature matching in ms. More... | |
static AvgFloat | optFlowTimesMS |
Averaged time for video feature optical flow tracking in ms. More... | |
static AvgFloat | poseTimesMS |
Averaged time for video feature pose estimation in ms. More... | |
Protected Attributes inherited from CVTracked | |
bool | _isVisible |
Flag if marker is visible. More... | |
bool | _drawDetection |
Flag if detection should be drawn into image. More... | |
CVMatx44f | _objectViewMat |
view transformation matrix More... | |
HighResTimer | _timer |
High resolution timer. More... | |
CVTrackedFeatures is the main part of the AR Christoffelturm scene.
The implementation tries to find a valid pose based on feature points in realtime. The feature matching algorithm checks the points of the current camera frame with against a reference. There are two important parts of this procedure: The relocalisation, which will be called if we have to find the pose with no hint where the camera could be. The other one is called feature tracking: If a pose was found, the implementation tries to track them and update the pose respectively.
Definition at line 66 of file CVTrackedFeatures.h.
|
explicit |
Definition at line 42 of file CVTrackedFeatures.cpp.
CVTrackedFeatures::~CVTrackedFeatures | ( | ) |
Show statistics if program terminates.
Definition at line 72 of file CVTrackedFeatures.cpp.
|
private |
This method does the most important work of the whole pipeline:
RANSAC: We execute first RANSAC to eliminate wrong feature correspondences (outliers) and only use the correct ones (inliers) for PnP solving (https://en.wikipedia.org/wiki/Perspective-n-Point).
Methods of solvePnP:
Definition at line 568 of file CVTrackedFeatures.cpp.
|
private |
Get keypoints and descriptors in one step. This is a more efficient way since we have to build the scaling pyramide only once. If we detect and describe seperatly, it will lead in two scaling pyramids and is therefore less meaningful.
Definition at line 485 of file CVTrackedFeatures.cpp.
|
private |
Visualizes the following parts of the whole Pose estimation:
Definition at line 305 of file CVTrackedFeatures.cpp.
|
inline |
Definition at line 75 of file CVTrackedFeatures.h.
|
inline |
Definition at line 79 of file CVTrackedFeatures.h.
|
private |
Get matching features with the defined feature matcher. Since we are using the k-next-neighbour matcher, we check if the best and second best match are not too identical with the so called ratio test.
Definition at line 501 of file CVTrackedFeatures.cpp.
|
private |
Prepares the reference tracker:
Definition at line 134 of file CVTrackedFeatures.cpp.
|
private |
Loads the marker image form the filesystem.
Definition at line 107 of file CVTrackedFeatures.cpp.
|
private |
To get more matches with the calculated pose, we reproject the reference points to our current frame. Within a predefined patch, we try to rematch not matched features with the reprojected point. If not possible, we increase the patch size until we found a match for the point or we reach a threshold.
Definition at line 664 of file CVTrackedFeatures.cpp.
|
private |
If relocation should be done, the following steps are necessary:
Definition at line 273 of file CVTrackedFeatures.cpp.
|
finalvirtual |
The main part of this tracker is to calculate a correct Pose.
imageGray | Current grayscale frame |
image | Current RGB frame |
calib | Calibration information |
Implements CVTracked.
Definition at line 218 of file CVTrackedFeatures.cpp.
|
private |
To track the already detected keypoints after a sucessful pose estimation, we track the features with optical flow
Definition at line 288 of file CVTrackedFeatures.cpp.
Tracks the features with Optical Flow (Lucas Kanade). This will only try to predict the new location of keypoints. If they were found, we perform a solvePnP to get the new Pose from feature tracking. The method performs tests if the Pose is good enough (not too much difference between previous and new Pose).
rvec | Rotation vector (will be used for extrinsic guess) |
tvec | Translation vector (will be used for extrinsic guess) |
Definition at line 850 of file CVTrackedFeatures.cpp.
|
private |
Copies the current frame data to the previous frame data struct for the next frame handling. TODO: more elegant way to do this whole copy action
Definition at line 444 of file CVTrackedFeatures.cpp.
|
inline |
Definition at line 76 of file CVTrackedFeatures.h.
void CVTrackedFeatures::type | ( | CVDetectDescribeType | ddType | ) |
Setter of the feature detector & descriptor type.
Definition at line 200 of file CVTrackedFeatures.cpp.
|
private |
Current calibration in use.
Definition at line 96 of file CVTrackedFeatures.h.
|
private |
The current video frame data.
Definition at line 129 of file CVTrackedFeatures.h.
|
private |
Feature detector-descriptor wrapper instance.
Definition at line 132 of file CVTrackedFeatures.h.
|
private |
Force relocation every frame (no opt. flow tracking)
Definition at line 131 of file CVTrackedFeatures.h.
|
private |
NO. of frames since process start.
Definition at line 97 of file CVTrackedFeatures.h.
|
private |
True if tracking.
Definition at line 98 of file CVTrackedFeatures.h.
|
private |
2D marker data
Definition at line 128 of file CVTrackedFeatures.h.
|
private |
Descriptor matching algorithm.
Definition at line 95 of file CVTrackedFeatures.h.
|
private |
The previous video frame data.
Definition at line 130 of file CVTrackedFeatures.h.