fine tuning

pull/3471/head
kallaballa 3 years ago
parent deb0a01a24
commit 3ee09827a8
  1. 8
      src/optflow/optflow-demo.cpp
  2. 8
      src/optflow_mt/optflow_mt-demo.cpp

@ -66,6 +66,7 @@ int main(int argc, char **argv) {
vector<cv::Point2f> allPoints, prevPoints, nextPoints, newPoints;
vector<vector<cv::Point> > contours;
vector<cv::Vec4i> hierarchy;
double avgLength = 1;
uint64_t cnt = 1;
int64 start = cv::getTickCount();
@ -116,13 +117,14 @@ int main(int argc, char **argv) {
using kb::nvg::vg;
nvgBeginPath(vg);
nvgStrokeWidth(vg, std::fmax(2.0, WIDTH/960.0));
nvgStrokeColor(vg, nvgHSLA(0.1, 1, 0.5, 32));
nvgStrokeWidth(vg, std::fmax(3.0, WIDTH/960.0));
nvgStrokeColor(vg, nvgHSLA(0.1, 1, 0.5, 64));
for (size_t i = 0; i < prevPoints.size(); i++) {
if (status[i] == 1 && nextPoints[i].y >= 0 && nextPoints[i].x >= 0 && nextPoints[i].y < foregroundMaskGrey.rows && nextPoints[i].x < foregroundMaskGrey.cols) {
double len = hypot(fabs(nextPoints[i].x - prevPoints[i].x), fabs(nextPoints[i].y - prevPoints[i].y));
if (len > 0) {
avgLength = ((avgLength * 0.95) + (len * 0.05));
if (len > 0 && len < avgLength) {
newPoints.push_back(nextPoints[i]);
nvgMoveTo(vg, nextPoints[i].x, nextPoints[i].y);

@ -99,6 +99,7 @@ int main(int argc, char **argv) {
cv::UMat foreground(HEIGHT, WIDTH, CV_8UC4, cv::Scalar::all(0));
cv::UMat videoFrame2, nextVideoFrameGray, prevVideoFrameGray;
vector<cv::Point2f> fgPoints2, prevPoints, nextPoints, newPoints;
double avgLength = 1;
uint64_t cnt = 1;
int64 start = cv::getTickCount();
@ -132,13 +133,14 @@ int main(int argc, char **argv) {
newPoints.clear();
using kb::nvg::vg;
nvgBeginPath(vg);
nvgStrokeWidth(vg, std::fmax(2.0, WIDTH/960.0));
nvgStrokeColor(vg, nvgHSLA(0.1, 1, 0.5, 32));
nvgStrokeWidth(vg, std::fmax(3.0, WIDTH/960.0));
nvgStrokeColor(vg, nvgHSLA(0.1, 1, 0.5, 64));
for (size_t i = 0; i < prevPoints.size(); i++) {
if (status[i] == 1 && nextPoints[i].y >= 0 && nextPoints[i].x >= 0 && nextPoints[i].y < nextVideoFrameGray.rows && nextPoints[i].x < nextVideoFrameGray.cols) {
double len = hypot(fabs(nextPoints[i].x - prevPoints[i].x), fabs(nextPoints[i].y - prevPoints[i].y));
if (len > 0) {
avgLength = ((avgLength * 0.95) + (len * 0.05));
if (len > 0 && len < avgLength) {
newPoints.push_back(nextPoints[i]);
nvgMoveTo(vg, nextPoints[i].x, nextPoints[i].y);

Loading…
Cancel
Save