Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
43925b60
Commit
43925b60
authored
Mar 04, 2017
by
berak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tracking: make opencv_dnn dependancy optional
parent
ab63d35d
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
46 additions
and
15 deletions
+46
-15
CMakeLists.txt
modules/tracking/CMakeLists.txt
+1
-1
goturnTracker.cpp
modules/tracking/samples/goturnTracker.cpp
+19
-3
multiTracker_dataset.cpp
modules/tracking/samples/multiTracker_dataset.cpp
+1
-0
tracker_dataset.cpp
modules/tracking/samples/tracker_dataset.cpp
+1
-0
gtrTracker.cpp
modules/tracking/src/gtrTracker.cpp
+10
-1
gtrTracker.hpp
modules/tracking/src/gtrTracker.hpp
+8
-4
gtrUtils.cpp
modules/tracking/src/gtrUtils.cpp
+3
-3
gtrUtils.hpp
modules/tracking/src/gtrUtils.hpp
+2
-3
tracker.cpp
modules/tracking/src/tracker.cpp
+1
-0
No files found.
modules/tracking/CMakeLists.txt
View file @
43925b60
set
(
the_description
"Tracking API"
)
ocv_define_module
(
tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_
dnn opencv_plot OPTIONAL
opencv_datasets WRAP java python
)
ocv_define_module
(
tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_
plot OPTIONAL opencv_dnn
opencv_datasets WRAP java python
)
modules/tracking/samples/goturnTracker.cpp
View file @
43925b60
...
...
@@ -45,6 +45,9 @@
//1 - Train you own GOTURN model using <https://github.com/Auron-X/GOTURN_Training_Toolkit>
//2 - Download pretrained caffemodel from <https://github.com/opencv/opencv_extra>
#include "opencv2/opencv_modules.hpp"
#if defined(HAVE_OPENCV_DNN) && defined(HAVE_OPENCV_DATASETS)
#include "opencv2/datasets/track_alov.hpp"
#include <opencv2/core/utility.hpp>
#include <opencv2/tracking.hpp>
...
...
@@ -65,8 +68,8 @@ static bool startSelection = false;
Rect2d
boundingBox
;
static
const
char
*
keys
=
{
"{@dataset_path |
true| Dataset path
}"
"{@dataset_id
|1| Dataset ID }"
{
"{@dataset_path |
| Dataset path
}"
"{@dataset_id
|1| Dataset ID }"
};
static
void
onMouse
(
int
event
,
int
x
,
int
y
,
int
,
void
*
)
...
...
@@ -144,9 +147,14 @@ int main(int argc, char *argv[])
Ptr
<
cv
::
datasets
::
TRACK_alov
>
dataset
=
TRACK_alov
::
create
();
dataset
->
load
(
datasetRootPath
);
dataset
->
initDataset
(
datasetID
);
//Read first frame
dataset
->
getNextFrame
(
frame
);
if
(
frame
.
empty
())
{
cout
<<
"invalid dataset: "
<<
datasetRootPath
<<
endl
;
return
-
2
;
}
frame
.
copyTo
(
image
);
rectangle
(
image
,
boundingBox
,
Scalar
(
255
,
0
,
0
),
2
,
1
);
imshow
(
"GOTURN Tracking"
,
image
);
...
...
@@ -215,3 +223,11 @@ int main(int argc, char *argv[])
return
0
;
}
#else // ! HAVE_OPENCV_DNN && HAVE_OPENCV_DATASETS
#include <opencv2/core.hpp>
int
main
()
{
CV_Error
(
cv
::
Error
::
StsNotImplemented
,
"this sample needs to be built with opencv_datasets and opencv_dnn !"
);
return
-
1
;
}
#endif
modules/tracking/samples/multiTracker_dataset.cpp
View file @
43925b60
...
...
@@ -234,6 +234,7 @@ int main(int argc, char *argv[])
}
#else // ! HAVE_OPENCV_DATASETS
#include <opencv2/core.hpp>
int
main
()
{
CV_Error
(
cv
::
Error
::
StsNotImplemented
,
"this sample needs to be built with opencv_datasets !"
);
return
-
1
;
...
...
modules/tracking/samples/tracker_dataset.cpp
View file @
43925b60
...
...
@@ -234,6 +234,7 @@ int main(int argc, char *argv[])
#else // ! HAVE_OPENCV_DATASETS
#include <opencv2/core.hpp>
int
main
()
{
CV_Error
(
cv
::
Error
::
StsNotImplemented
,
"this sample needs to be built with opencv_datasets !"
);
return
-
1
;
...
...
modules/tracking/src/gtrTracker.cpp
View file @
43925b60
...
...
@@ -38,7 +38,7 @@
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "opencv2/opencv_modules.hpp"
#include "gtrTracker.hpp"
...
...
@@ -54,9 +54,16 @@ void TrackerGOTURN::Params::write(cv::FileStorage& /*fs*/) const {}
Ptr
<
TrackerGOTURN
>
TrackerGOTURN
::
createTracker
(
const
TrackerGOTURN
::
Params
&
parameters
)
{
#ifdef HAVE_OPENCV_DNN
return
Ptr
<
gtr
::
TrackerGOTURNImpl
>
(
new
gtr
::
TrackerGOTURNImpl
(
parameters
));
#else
(
void
)(
parameters
);
CV_ErrorNoReturn
(
cv
::
Error
::
StsNotImplemented
,
"to use GOTURN, the tracking module needs to be built with opencv_dnn !"
);
#endif
}
#ifdef HAVE_OPENCV_DNN
namespace
gtr
{
...
...
@@ -183,9 +190,11 @@ bool TrackerGOTURNImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
//Set new model image and BB from current frame
((
TrackerGOTURNModel
*
)
static_cast
<
TrackerModel
*>
(
model
))
->
setImage
(
curFrame
);
((
TrackerGOTURNModel
*
)
static_cast
<
TrackerModel
*>
(
model
))
->
setBoudingBox
(
curBB
);
return
true
;
}
}
#endif // OPENCV_HAVE_DNN
}
modules/tracking/src/gtrTracker.hpp
View file @
43925b60
...
...
@@ -45,11 +45,15 @@
#include "precomp.hpp"
#include "opencv2/video/tracking.hpp"
#include "opencv2/dnn.hpp"
#include "gtrUtils.hpp"
#include "opencv2/imgproc.hpp"
#include<algorithm>
#include<limits.h>
#include <algorithm>
#include <limits.h>
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_DNN
#include "opencv2/dnn.hpp"
namespace
cv
{
...
...
@@ -72,5 +76,5 @@ public:
}
}
#endif
#endif
modules/tracking/src/gtrUtils.cpp
View file @
43925b60
...
...
@@ -58,7 +58,7 @@ double generateRandomLaplacian(double b, double m)
return
m
-
b
*
log
(
n
);
}
Rect2f
anno2rect
(
vector
<
Point2f
>
annoBB
)
Rect2f
anno2rect
(
std
::
vector
<
Point2f
>
annoBB
)
{
Rect2f
rectBB
;
rectBB
.
x
=
min
(
annoBB
[
0
].
x
,
annoBB
[
1
].
x
);
...
...
@@ -69,9 +69,9 @@ Rect2f anno2rect(vector<Point2f> annoBB)
return
rectBB
;
}
vector
<
TrainingSample
>
gatherFrameSamples
(
Mat
prevFrame
,
Mat
currFrame
,
Rect2f
prevBB
,
Rect2f
currBB
)
std
::
vector
<
TrainingSample
>
gatherFrameSamples
(
Mat
prevFrame
,
Mat
currFrame
,
Rect2f
prevBB
,
Rect2f
currBB
)
{
vector
<
TrainingSample
>
trainingSamples
;
std
::
vector
<
TrainingSample
>
trainingSamples
;
Point2f
currCenter
,
prevCenter
;
Rect2f
targetPatchRect
,
searchPatchRect
;
Mat
targetPatch
,
searchPatch
;
...
...
modules/tracking/src/gtrUtils.hpp
View file @
43925b60
...
...
@@ -4,7 +4,6 @@
#include "precomp.hpp"
#include <vector>
#include "opencv2/highgui.hpp"
#include <opencv2/datasets/track_alov.hpp>
namespace
cv
{
...
...
@@ -50,10 +49,10 @@ struct TrainingSample
double
generateRandomLaplacian
(
double
b
,
double
m
);
//Convert ALOV300++ anno coordinates to Rectangle BB
Rect2f
anno2rect
(
vector
<
Point2f
>
annoBB
);
Rect2f
anno2rect
(
std
::
vector
<
Point2f
>
annoBB
);
//Gather samples from random video frame
vector
<
TrainingSample
>
gatherFrameSamples
(
Mat
prevFrame
,
Mat
currFrame
,
Rect2f
prevBB
,
Rect2f
currBB
);
std
::
vector
<
TrainingSample
>
gatherFrameSamples
(
Mat
prevFrame
,
Mat
currFrame
,
Rect2f
prevBB
,
Rect2f
currBB
);
}
}
...
...
modules/tracking/src/tracker.cpp
View file @
43925b60
...
...
@@ -112,6 +112,7 @@ Ptr<Tracker> Tracker::create( const String& trackerType )
BOILERPLATE_CODE
(
"TLD"
,
TrackerTLD
);
BOILERPLATE_CODE
(
"KCF"
,
TrackerKCF
);
BOILERPLATE_CODE
(
"GOTURN"
,
TrackerGOTURN
);
return
Ptr
<
Tracker
>
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment