EgoVideoStabilizer  1.0.0
homography.h File Reference

Header functions for the homography.cpp. More...

#include <stdio.h>
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/nonfree/nonfree.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "definitions/define.h"
Include dependency graph for homography.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  HomogCoverage { NO_AREA, DROP_AREA, CROP_AREA }
 The HomogCoverage enum. More...
 

Functions

bool findHomographyMatrix (const cv::Mat &image_src, const cv::Mat &image_dst, cv::Mat &homography_matrix, cv::Mat &ransac_mask)
 Function that find the homography matrix that leave the imageSrc to the plan of the imageDst. More...
 
bool findHomographyMatrix (const cv::Mat &image_src, const cv::Mat &image_dst, cv::Mat &homography_matrix)
 Function that find the homography matrix that leave the imageSrc to the plan of the imageDst. More...
 
bool findHomographyMatrix (const std::vector< cv::KeyPoint > &keypoints_image_src, const std::vector< cv::KeyPoint > &keypoints_image_dst, const cv::Mat &descriptors_image_src, const cv::Mat &descriptors_image_dst, cv::Mat &homography_matrix, cv::Mat &ransac_mask)
 Function that finds the homography matrix given the keypoints and descriptors. More...
 
bool findHomographyMatrix (const std::vector< cv::KeyPoint > &keypoints_image_src, const std::vector< cv::KeyPoint > &keypoints_image_dst, const cv::Mat &descriptors_image_src, const cv::Mat &descriptors_image_dst, cv::Mat &homography_matrix)
 Function that find the homography matrix that leaves the imageSrc to the plan of the imageDst. More...
 
bool applyHomographyMatrix (const cv::Mat &image_src, const cv::Mat &homography_matrix, cv::Mat &image_result)
 Function that apply homography matrix in a given image. More...
 
bool checkHomographyConsistency (const std::vector< cv::Point2f > img_corners, const cv::Mat &homography_matrix)
 Function that checks if after made the homography transformation the corner consistency is maintained. More...
 
bool checkHomographyConsistency (const std::vector< cv::Point2f > new_img_corners)
 Function that checks if after made the homography transformation the corner consistency is maintained. More...
 
double getAreaRatio (const cv::Mat &image_src, const cv::Mat &homography_matrix, const cv::Rect &frame_limits)
 Function that calculates the loss(%) of the homography transformation in a ROI. More...
 
HomogCoverage getHomogCoverage (const cv::Mat &image_src, const cv::Mat &homography_matrix, const cv::Rect &drop_area, const cv::Rect &crop_area)
 Function that calculates the loss(%) of the homography transformation in a ROI. More...
 
void getKeypointsAndDescriptors (const cv::Mat &image, std::vector< cv::KeyPoint > &keypoints, cv::Mat &descriptors)
 Function that gets the keypoints and describe an image in order to avoid unnecessary computations for tasks like finding the homography matrix. More...
 

Detailed Description

Header functions for the homography.cpp.

Enumeration Type Documentation

The HomogCoverage enum.

Enumerator
NO_AREA 
DROP_AREA 

It can't cover neither the drop area nor the crop area.

CROP_AREA 

It covers the drop area, but doesn't cover the crop area.

It covers both the drop and the crop areas

Function Documentation

bool applyHomographyMatrix ( const cv::Mat &  image_src,
const cv::Mat &  homography_matrix,
cv::Mat &  image_result 
)

Function that apply homography matrix in a given image.

Parameters
image_src- image where the homography matrix will be applied.
homography_matrix- homography matrix.
image_result- object to save the image after the application of the homography matrix.
Returns
bool true - if the corner consistency is maintained after application of the homography matrix.
bool false - if the consistency is not maintained after application of the homography matrix. In this case the imageResult is a simple copy of the imageSrc.
Author
Michel Melo da Silva
Date
25/03/2016
bool checkHomographyConsistency ( const std::vector< cv::Point2f >  img_corners,
const cv::Mat &  homography_matrix 
)

Function that checks if after made the homography transformation the corner consistency is maintained.

Parameters
img_corners- image corners in the following order:
img_corners[0] = 0 , 0
img_corners[1] = cols , 0
img_corners[2] = 0 , rows
img_corners[3] = cols , rows
homography_matrix- homography matrix that will be checked the consistency.
Returns
bool true - if the consistency is maintained.
bool false - if the consistency is not maintained.
Author
Michel Melo da Silva
Date
08/04/2016
bool checkHomographyConsistency ( const std::vector< cv::Point2f >  new_img_corners)

Function that checks if after made the homography transformation the corner consistency is maintained.

Parameters
new_img_corners- image corners in the following order:
img_corners[0] = 0 , 0
img_corners[1] = cols , 0
img_corners[2] = 0 , rows
img_corners[3] = cols , rows
Returns
bool true - if the consistency is maintained.
bool false - if the consistency is not maintained.
Author
Michel Melo da Silva
Date
12/04/2016
bool findHomographyMatrix ( const cv::Mat &  image_src,
const cv::Mat &  image_dst,
cv::Mat &  homography_matrix,
cv::Mat &  ransac_mask 
)

Function that find the homography matrix that leave the imageSrc to the plan of the imageDst.

Returns the Ransak mask after finding the homography matrix.

Parameters
image_src- image to where the homography will be calculated.
image_dst- image of the destination of the homography.
homography_matrix- object to homography matrix calculated.
ransac_mask- RANSAC mask of the homography matrix. 1 means inliers and 0 means outliers.
Returns
bool true - if there is enough points in both images and good matches between them to find a homography matrix.
bool false - if there is not enough points in both images or good matches between them to find a homography matrix.
Author
Michel Melo da Silva
Date
28/03/2016

Function that find the homography matrix that leave the imageSrc to the plan of the imageDst.

Returns the Ransak mask after finding the homography matrix.

Parameters
image_src- image to where the homography will be calculated.
image_dst- image of the destination of the homography.
homography_matrix- object to homography matrix calculated.
ransac_mask- RANSAC mask of the homography matrix. 1 means inliers and 0 means outliers.
Returns
bool true - if there is enough points in both images and good matches between them to find a homography matrix.
bool false - if there is not enough points in both images or good matches between them to find a homography matrix.
Author
Michel Melo da Silva
Date
28/03/2016
bool findHomographyMatrix ( const cv::Mat &  image_src,
const cv::Mat &  image_dst,
cv::Mat &  homography_matrix 
)

Function that find the homography matrix that leave the imageSrc to the plan of the imageDst.

Parameters
image_src- image to where the homography will be calculated.
image_dst- image of the destination of the homography.
homography_matrix- object to save the homography matrix calculated.
Returns
bool true - if there is enough points in both images and good matches between them to find a homography matrix.
bool false - if there is not enough points in both images or good matches between them to find a homography matrix.
Author
Michel Melo da Silva
Date
28/03/2016

Function that find the homography matrix that leave the imageSrc to the plan of the imageDst.

Parameters
image_src- image to where the homography will be calculated.
image_dst- image of the destination of the homography.
homography_matrix- object to save the homography matrix calculated.
Returns
bool true - if there is enough points in both images and good matches between them to find a homography matrix.
bool false - if there is not enough points in both images or good matches between them to find a homography matrix.
Author
Michel Melo da Silva
Date
28/03/2016
bool findHomographyMatrix ( const std::vector< cv::KeyPoint > &  keypoints_image_src,
const std::vector< cv::KeyPoint > &  keypoints_image_dst,
const cv::Mat &  descriptors_image_src,
const cv::Mat &  descriptors_image_dst,
cv::Mat &  homography_matrix,
cv::Mat &  ransac_mask 
)

Function that finds the homography matrix given the keypoints and descriptors.

Returns the Ransak mask after finding the homography matrix.

Parameters
keypoints_image_src- keypoints of the source image.
keypoints_image_dst- keypoints of the target image.
descriptors_image_src- descriptors of the source image.
descriptors_image_dst- descriptors of the target image.
homography_matrix- object to homography matrix calculated.
ransac_mask- RANSAC mask of the homography matrix. 1 means inliers and 0 means outliers.
Returns
bool true - if there is enough points in both images and good matches between them to find a homography matrix.
bool false - if there is not enough points in both images or good matches between them to find a homography matrix.
Author
Washington Luis de Souza Ramos
Date
30/08/2016
bool findHomographyMatrix ( const std::vector< cv::KeyPoint > &  keypoints_image_src,
const std::vector< cv::KeyPoint > &  keypoints_image_dst,
const cv::Mat &  descriptors_image_src,
const cv::Mat &  descriptors_image_dst,
cv::Mat &  homography_matrix 
)

Function that find the homography matrix that leaves the imageSrc to the plan of the imageDst.

Parameters
keypoints_image_src- keypoints of the source image.
keypoints_image_dst- keypoints of the target image.
descriptors_image_src- descriptors of the source image.
descriptors_image_dst- descriptors of the target image.
homography_matrix- object to save the homography matrix calculated.
Returns
bool true - if there is enough points in both images and good matches between them to find a homography matrix.
bool false - if there is not enough points in both images or good matches between them to find a homography matrix.
Author
Washington Luis de Souza Ramos
Date
09/09/2016
double getAreaRatio ( const cv::Mat &  image_src,
const cv::Mat &  homography_matrix,
const cv::Rect &  frame_limits 
)

Function that calculates the loss(%) of the homography transformation in a ROI.

It returns the ratio between the non-image area and the frame_limits area.

Parameters
image_src- The source image.
homography_matrix- The homography matrix.
frame_limits- The region of interest (ROI).
Returns
double - The ratio between non-image area and the whole frame area.
Author
Washington Luis de Souza Ramos
Date
14/04/2016
HomogCoverage getHomogCoverage ( const cv::Mat &  image_src,
const cv::Mat &  homography_matrix,
const cv::Rect &  drop_area,
const cv::Rect &  crop_area 
)

Function that calculates the loss(%) of the homography transformation in a ROI.

It returns the coverage of a transformation which is NONE, DROP_AREA or CROP_AREA.

Parameters
image_src- The source image.
homography_matrix- The homography matrix.
drop_area- The region of interest (ROI) for the drop area.
crop_area- The region of interest (ROI) for the crop area.
Returns
The HomogCoverage enum value
Author
Washington Luis de Souza Ramos
Date
10/09/2016
void getKeypointsAndDescriptors ( const cv::Mat &  image,
std::vector< cv::KeyPoint > &  keypoints,
cv::Mat &  descriptors 
)

Function that gets the keypoints and describe an image in order to avoid unnecessary computations for tasks like finding the homography matrix.

Parameters
image- image to where the keypoints and descriptors are to be extracted from.
keypoints- the keypoints found in the image.
descriptors- the descriptors of the image.
Author
Washington Luis de Souza Ramos
Date
30/08/2016