-
Notifications
You must be signed in to change notification settings - Fork 41
Feature/optiflow #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
norru
wants to merge
15
commits into
nebgnahz:master
Choose a base branch
from
norru:feature/optiflow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+460
−5
Open
Feature/optiflow #93
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d6be815
Optiflow integration test
161f68b
Cleaned up project, added basic wrapper for optiflow call
cc7815e
Doc
bacc5d6
Added Linux paths
1383dd7
Added other optflow methods
d3fc57f
Build fix
94f6257
Farneback implementation
f7d35a5
Optical flow converts to grayscale if required
21ff71e
Fixed formats causing Cargo fmt check failures
328b607
More formatting to keep cargo format check happy
4d4c225
Fixed formats causing Cargo fmt check failures
746c3c7
Reverted file that didn't need to be formatted
0991e78
Removed unnecessary Eclipse project file
norru 3f3d846
Removed unnecessary InputOutput arrays
57f59dc
c_int -> i32, c_double -> f64
norru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#include "optflow.h" | ||
#include "utils.h" | ||
|
||
extern "C" { | ||
|
||
void calc_optical_flow_sf(cv::Mat* from, | ||
cv::Mat* to, | ||
cv::Mat* out, | ||
int layers, | ||
int averaging_block_size, | ||
int max_flow, | ||
double sigma_dist, | ||
double sigma_color, | ||
int postprocess_window, | ||
double sigma_dist_fix, | ||
double sigma_color_fix, | ||
double occ_thr, | ||
int upscale_averaging_radius, | ||
double upscale_sigma_dist, | ||
double upscale_sigma_color, | ||
double speed_up_thr) { | ||
cv::optflow::calcOpticalFlowSF(*from, | ||
*to, | ||
*out, | ||
layers, | ||
averaging_block_size, | ||
max_flow, | ||
sigma_dist, | ||
sigma_color, | ||
postprocess_window, | ||
sigma_dist_fix, | ||
sigma_color_fix, | ||
occ_thr, | ||
upscale_averaging_radius, | ||
upscale_sigma_dist, | ||
upscale_sigma_color, | ||
speed_up_thr); | ||
} | ||
|
||
void calc_optical_flow_df(cv::Mat* from, cv::Mat* to, cv::Mat* out) { | ||
auto optical_flow = cv::optflow::createOptFlow_DeepFlow(); | ||
optical_flow->calc(*from, *to, *out); | ||
} | ||
|
||
void calc_optical_flow_farneback(cv::Mat* from, | ||
cv::Mat* to, | ||
cv::Mat* out, | ||
int numLevels, | ||
double pyrScale, | ||
bool fastPyramids, | ||
int winSize, | ||
int numIters, | ||
int polyN, | ||
double polySigma, | ||
int flags) { | ||
auto optical_flow = | ||
cv::FarnebackOpticalFlow::create(numLevels, pyrScale, fastPyramids, winSize, numIters, polyN, polySigma, flags); | ||
|
||
optical_flow->calc(*from, *to, *out); | ||
} | ||
|
||
void calc_optical_flow_dtvl1(cv::Mat* from, | ||
cv::Mat* to, | ||
cv::Mat* out, | ||
double tau, | ||
double lambda, | ||
double theta, | ||
int nscales, | ||
int warps, | ||
double epsilon, | ||
int innerIterations, | ||
int outerIterations, | ||
double scaleStep, | ||
double gamma, | ||
int medianFiltering, | ||
bool useInitialFlow) { | ||
auto optical_flow = cv::DualTVL1OpticalFlow::create(tau, | ||
lambda, | ||
theta, | ||
nscales, | ||
warps, | ||
epsilon, | ||
innerIterations, | ||
outerIterations, | ||
scaleStep, | ||
gamma, | ||
medianFiltering, | ||
useInitialFlow); | ||
|
||
optical_flow->calc(*from, *to, *out); | ||
} | ||
|
||
void calc_optical_flow_dis(cv::Mat* from, cv::Mat* to, cv::Mat* out, unsigned int preset) { | ||
auto optical_flow = cv::optflow::createOptFlow_DIS(preset); | ||
optical_flow->calc(*from, *to, *out); | ||
} | ||
|
||
void calc_optical_flow_std(cv::Mat* from, cv::Mat* to, cv::Mat* out) { | ||
auto optical_flow = cv::optflow::createOptFlow_SparseToDense(); | ||
optical_flow->calc(*from, *to, *out); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#ifndef CV_RS_OPTFLOW_H | ||
#define CV_RS_OPTFLOW_H | ||
|
||
#include "common.h" | ||
#include <opencv2/core.hpp> | ||
#include <opencv2/optflow.hpp> | ||
#include <opencv2/video/tracking.hpp> | ||
|
||
extern "C" { | ||
void calc_optical_flow_sf(cv::Mat* from, | ||
cv::Mat* to, | ||
cv::Mat* out, | ||
int layers, | ||
int averaging_block_size, | ||
int max_flow, | ||
double sigma_dist, | ||
double sigma_color, | ||
int postprocess_window, | ||
double sigma_dist_fix, | ||
double sigma_color_fix, | ||
double occ_thr, | ||
int upscale_averaging_radius, | ||
double upscale_sigma_dist, | ||
double upscale_sigma_color, | ||
double speed_up_thr); | ||
|
||
void calc_optical_flow_df(cv::Mat* from, cv::Mat* to, cv::Mat* out); | ||
|
||
void calc_optical_flow_farneback(cv::Mat* from, | ||
cv::Mat* to, | ||
cv::Mat* out, | ||
int numLevels = 5, | ||
double pyrScale = 0.5, | ||
bool fastPyramids = false, | ||
int winSize = 13, | ||
int numIters = 10, | ||
int polyN = 5, | ||
double polySigma = 1.1, | ||
int flags = 0); | ||
|
||
void calc_optical_flow_dtvl1(cv::Mat* from, | ||
cv::Mat* to, | ||
cv::Mat* out, | ||
double tau = 0.25, | ||
double lambda = 0.15, | ||
double theta = 0.3, | ||
int nscales = 5, | ||
int warps = 5, | ||
double epsilon = 0.01, | ||
int innerIterations = 30, | ||
int outerIterations = 10, | ||
double scaleStep = 0.8, | ||
double gamma = 0.0, | ||
int medianFiltering = 5, | ||
bool useInitialFlow = false); | ||
|
||
void calc_optical_flow_std(cv::Mat* from, cv::Mat* to, cv::Mat* out); | ||
|
||
void calc_optical_flow_dis(cv::Mat* from, cv::Mat* to, cv::Mat* out, unsigned int preset); | ||
} | ||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.