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
bcbbb63b
Commit
bcbbb63b
authored
Nov 10, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #425 from berak:python_tracking
parents
c8053da4
59e9a9ae
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
6 deletions
+72
-6
CMakeLists.txt
modules/tracking/CMakeLists.txt
+1
-1
onlineMIL.hpp
modules/tracking/include/opencv2/tracking/onlineMIL.hpp
+1
-1
tracker.hpp
modules/tracking/include/opencv2/tracking/tracker.hpp
+0
-0
multitracker.py
modules/tracking/samples/multitracker.py
+35
-0
tracker.py
modules/tracking/samples/tracker.py
+31
-0
roiSelector.cpp
modules/tracking/src/roiSelector.cpp
+4
-4
No files found.
modules/tracking/CMakeLists.txt
View file @
bcbbb63b
set
(
the_description
"Tracking API"
)
ocv_define_module
(
tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_datasets
)
ocv_define_module
(
tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_datasets
WRAP python
)
modules/tracking/include/opencv2/tracking/onlineMIL.hpp
View file @
bcbbb63b
...
...
@@ -58,7 +58,7 @@ namespace cv
class
ClfOnlineStump
;
class
ClfMilBoost
class
C
V_EXPORTS
C
lfMilBoost
{
public
:
struct
CV_EXPORTS
Params
...
...
modules/tracking/include/opencv2/tracking/tracker.hpp
View file @
bcbbb63b
This diff is collapsed.
Click to expand it.
modules/tracking/samples/multitracker.py
0 → 100644
View file @
bcbbb63b
import
numpy
as
np
import
cv2
cv2
.
namedWindow
(
"tracking"
)
camera
=
cv2
.
VideoCapture
(
"E:/code/opencv/samples/data/768x576.avi"
)
tracker
=
cv2
.
MultiTracker
(
"MIL"
)
bbox1
=
(
638.0
,
230.0
,
56.0
,
101.0
)
bbox2
=
(
240.0
,
210.0
,
60.0
,
104.0
)
bbox3
=
(
486.0
,
149.0
,
54.0
,
83.0
)
init_once
=
False
while
camera
.
isOpened
():
ok
,
image
=
camera
.
read
()
if
not
ok
:
print
'no image read'
break
if
not
init_once
:
# add a list of boxes:
ok
=
tracker
.
add
(
image
,
(
bbox1
,
bbox2
))
# or add single box:
ok
=
tracker
.
add
(
image
,
bbox3
)
init_once
=
True
ok
,
boxes
=
tracker
.
update
(
image
)
print
ok
,
boxes
for
newbox
in
boxes
:
p1
=
(
int
(
newbox
[
0
]),
int
(
newbox
[
1
]))
p2
=
(
int
(
newbox
[
0
]
+
newbox
[
2
]),
int
(
newbox
[
1
]
+
newbox
[
3
]))
cv2
.
rectangle
(
image
,
p1
,
p2
,
(
200
,
0
,
0
))
cv2
.
imshow
(
"tracking"
,
image
)
k
=
cv2
.
waitKey
(
1
)
&
0xff
if
k
==
27
:
break
# esc pressed
modules/tracking/samples/tracker.py
0 → 100644
View file @
bcbbb63b
import
numpy
as
np
import
cv2
cv2
.
namedWindow
(
"tracking"
)
camera
=
cv2
.
VideoCapture
(
"E:/code/opencv/samples/data/768x576.avi"
)
bbox
=
(
638.0
,
230.0
,
56.0
,
101.0
)
tracker
=
cv2
.
Tracker_create
(
"MIL"
)
init_once
=
False
while
camera
.
isOpened
():
ok
,
image
=
camera
.
read
()
if
not
ok
:
print
'no image read'
break
if
not
init_once
:
ok
=
tracker
.
init
(
image
,
bbox
)
init_once
=
True
ok
,
newbox
=
tracker
.
update
(
image
)
print
ok
,
newbox
if
ok
:
p1
=
(
int
(
newbox
[
0
]),
int
(
newbox
[
1
]))
p2
=
(
int
(
newbox
[
0
]
+
newbox
[
2
]),
int
(
newbox
[
1
]
+
newbox
[
3
]))
cv2
.
rectangle
(
image
,
p1
,
p2
,
(
200
,
0
,
0
))
cv2
.
imshow
(
"tracking"
,
image
)
k
=
cv2
.
waitKey
(
1
)
&
0xff
if
k
==
27
:
break
# esc pressed
\ No newline at end of file
modules/tracking/src/roiSelector.cpp
View file @
bcbbb63b
...
...
@@ -91,7 +91,7 @@ namespace cv {
return
select
(
"ROI selector"
,
img
,
fromCenter
);
}
Rect2d
ROISelector
::
select
(
const
std
::
s
tring
&
windowName
,
Mat
img
,
bool
showCrossair
,
bool
fromCenter
){
Rect2d
ROISelector
::
select
(
const
cv
::
S
tring
&
windowName
,
Mat
img
,
bool
showCrossair
,
bool
fromCenter
){
key
=
0
;
...
...
@@ -149,7 +149,7 @@ namespace cv {
return
selectorParams
.
box
;
}
void
ROISelector
::
select
(
const
std
::
s
tring
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
){
void
ROISelector
::
select
(
const
cv
::
S
tring
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
){
std
::
vector
<
Rect2d
>
box
;
Rect2d
temp
;
key
=
0
;
...
...
@@ -172,12 +172,12 @@ namespace cv {
return
_selector
.
select
(
"ROI selector"
,
img
,
true
,
fromCenter
);
};
Rect2d
selectROI
(
const
std
::
s
tring
&
windowName
,
Mat
img
,
bool
showCrossair
,
bool
fromCenter
){
Rect2d
selectROI
(
const
cv
::
S
tring
&
windowName
,
Mat
img
,
bool
showCrossair
,
bool
fromCenter
){
printf
(
"Select an object to track and then press SPACE or ENTER button!
\n
"
);
return
_selector
.
select
(
windowName
,
img
,
showCrossair
,
fromCenter
);
};
void
selectROI
(
const
std
::
s
tring
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
){
void
selectROI
(
const
cv
::
S
tring
&
windowName
,
Mat
img
,
std
::
vector
<
Rect2d
>
&
boundingBox
,
bool
fromCenter
){
return
_selector
.
select
(
windowName
,
img
,
boundingBox
,
fromCenter
);
}
...
...
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