mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-19 02:16:34 +08:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -28,13 +28,6 @@ template<class T> std::string toString(const T& p_arg)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
printf("usage: cvv_demo [-r WxH]\n");
|
||||
printf("-h print this help\n");
|
||||
printf("-r WxH change resolution to width W and height H\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
@@ -45,34 +38,28 @@ main(int argc, char** argv)
|
||||
// parser keys
|
||||
const char *keys =
|
||||
"{ help h usage ? | | show this message }"
|
||||
"{ resolution r |0x0| resolution to width and height in the format WxH }";
|
||||
"{ width W | 0| camera resolution width. leave at 0 to use defaults }"
|
||||
"{ height H | 0| camera resolution height. leave at 0 to use defaults }";
|
||||
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
string res(parser.get<string>("resolution"));
|
||||
if (parser.has("help")) {
|
||||
usage();
|
||||
parser.printMessage();
|
||||
return 0;
|
||||
}
|
||||
if (res != "0x0") {
|
||||
char dummych;
|
||||
resolution = new cv::Size();
|
||||
if (sscanf(res.c_str(), "%d%c%d", &resolution->width, &dummych, &resolution->height) != 3) {
|
||||
cout << res << " not a valid resolution" << endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
int res_w = parser.get<int>("width");
|
||||
int res_h = parser.get<int>("height");
|
||||
|
||||
// setup video capture
|
||||
cv::VideoCapture capture(0);
|
||||
if (!capture.isOpened()) {
|
||||
std::cout << "Could not open VideoCapture" << std::endl;
|
||||
return 3;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (resolution) {
|
||||
printf("Setting resolution to %dx%d\n", resolution->width, resolution->height);
|
||||
capture.set(CV_CAP_PROP_FRAME_WIDTH, resolution->width);
|
||||
capture.set(CV_CAP_PROP_FRAME_HEIGHT, resolution->height);
|
||||
delete resolution;
|
||||
if (res_w>0 && res_h>0) {
|
||||
printf("Setting resolution to %dx%d\n", res_w, res_h);
|
||||
capture.set(CV_CAP_PROP_FRAME_WIDTH, res_w);
|
||||
capture.set(CV_CAP_PROP_FRAME_HEIGHT, res_h);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -18,3 +18,8 @@ if(WITH_MATLAB AND NOT DEFINED MATLAB_FOUND)
|
||||
set(MATLAB_FOUND "${MATLAB_FOUND}" PARENT_SCOPE)
|
||||
set(MATLAB_MEX_SCRIPT "${MATLAB_MEX_SCRIPT}" PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
if(NOT OPENCV_DOCS_INCLUDE_MATLAB)
|
||||
list(APPEND DOXYGEN_BLACKLIST "matlab")
|
||||
set(DOXYGEN_BLACKLIST "${DOXYGEN_BLACKLIST}" PARENT_SCOPE)
|
||||
endif()
|
||||
|
@@ -107,3 +107,10 @@ author={Bolme, David S. and Beveridge, J. Ross and Draper, Bruce A. and Lui Yui,
|
||||
booktitle = {Conference on Computer Vision and Pattern Recognition (CVPR)},
|
||||
year = {2010}
|
||||
}
|
||||
|
||||
@Article{Lukezic_IJCV2018,
|
||||
author={Luke{\v{z}}i{\v{c}}, Alan and Voj{'i}{\v{r}}, Tom{'a}{\v{s}} and {\v{C}}ehovin Zajc, Luka and Matas, Ji{\v{r}}{'i} and Kristan, Matej},
|
||||
title={Discriminative Correlation Filter Tracker with Channel and Spatial Reliability},
|
||||
journal={International Journal of Computer Vision},
|
||||
year={2018},
|
||||
}
|
||||
|
@@ -1513,6 +1513,8 @@ public:
|
||||
float scale_model_max_area;
|
||||
float scale_lr;
|
||||
float scale_step;
|
||||
|
||||
float psr_threshold; //!< we lost the target, if the psr is lower than this.
|
||||
};
|
||||
|
||||
/** @brief Constructor
|
||||
|
@@ -429,8 +429,12 @@ Point2f TrackerCSRTImpl::estimate_new_position(const Mat &image)
|
||||
|
||||
Mat resp = calculate_response(image, csr_filter);
|
||||
|
||||
double max_val;
|
||||
Point max_loc;
|
||||
minMaxLoc(resp, NULL, NULL, NULL, &max_loc);
|
||||
minMaxLoc(resp, NULL, &max_val, NULL, &max_loc);
|
||||
if (max_val < params.psr_threshold)
|
||||
return Point2f(-1,-1); // target "lost"
|
||||
|
||||
// take into account also subpixel accuracy
|
||||
float col = ((float) max_loc.x) + subpixel_peak(resp, "horizontal", max_loc);
|
||||
float row = ((float) max_loc.y) + subpixel_peak(resp, "vertical", max_loc);
|
||||
@@ -472,6 +476,8 @@ bool TrackerCSRTImpl::updateImpl(const Mat& image_, Rect2d& boundingBox)
|
||||
}
|
||||
|
||||
object_center = estimate_new_position(image);
|
||||
if (object_center.x < 0 && object_center.y < 0)
|
||||
return false;
|
||||
|
||||
current_scale_factor = dsst.getScale(image, object_center);
|
||||
//update bouding_box according to new scale and location
|
||||
@@ -651,6 +657,7 @@ TrackerCSRT::Params::Params()
|
||||
histogram_bins = 16;
|
||||
background_ratio = 2;
|
||||
histogram_lr = 0.04f;
|
||||
psr_threshold = 0.035f;
|
||||
}
|
||||
|
||||
void TrackerCSRT::Params::read(const FileNode& fn)
|
||||
@@ -708,6 +715,8 @@ void TrackerCSRT::Params::read(const FileNode& fn)
|
||||
fn["background_ratio"] >> background_ratio;
|
||||
if(!fn["histogram_lr"].empty())
|
||||
fn["histogram_lr"] >> histogram_lr;
|
||||
if(!fn["psr_threshold"].empty())
|
||||
fn["psr_threshold"] >> psr_threshold;
|
||||
CV_Assert(number_of_scales % 2 == 1);
|
||||
CV_Assert(use_gray || use_color_names || use_hog || use_rgb);
|
||||
}
|
||||
@@ -739,5 +748,6 @@ void TrackerCSRT::Params::write(FileStorage& fs) const
|
||||
fs << "histogram_bins" << histogram_bins;
|
||||
fs << "background_ratio" << background_ratio;
|
||||
fs << "histogram_lr" << histogram_lr;
|
||||
fs << "psr_threshold" << psr_threshold;
|
||||
}
|
||||
} /* namespace cv */
|
||||
|
Reference in New Issue
Block a user