2649
|
1 |
diff --git a/src/mouseTrap/ocvfw.py b/src/mouseTrap/ocvfw.py
|
|
2 |
--- a/src/mouseTrap/ocvfw.py
|
|
3 |
+++ b/src/mouseTrap/ocvfw.py
|
|
4 |
@@ -185,13 +185,18 @@
|
|
5 |
"""
|
|
6 |
|
|
7 |
# calculate the optical flow
|
|
8 |
- self.imgLKPoints["current"], status = cv.cvCalcOpticalFlowPyrLK (
|
|
9 |
+ optical_flow = cv.cvCalcOpticalFlowPyrLK (
|
|
10 |
self.prevGrey, self.grey, self.prevPyramid, self.pyramid,
|
|
11 |
self.imgLKPoints["last"], len( self.imgLKPoints["last"] ),
|
|
12 |
cv.cvSize (20, 20), 3, len( self.imgLKPoints["last"] ), None,
|
|
13 |
cv.cvTermCriteria (cv.CV_TERMCRIT_ITER|cv.CV_TERMCRIT_EPS,
|
|
14 |
20, 0.03), 0)
|
|
15 |
|
|
16 |
+ if isinstance(optical_flow[0], tuple):
|
|
17 |
+ self.imgLKPoints["current"], status = optical_flow[0]
|
|
18 |
+ else:
|
|
19 |
+ self.imgLKPoints["current"], status = optical_flow
|
|
20 |
+
|
|
21 |
# initializations
|
|
22 |
counter = 0
|
|
23 |
new_points = []
|
|
24 |
@@ -202,14 +207,13 @@
|
|
25 |
if not status or not status[counter]:
|
|
26 |
# we will disable this point
|
|
27 |
continue
|
|
28 |
-
|
|
29 |
|
|
30 |
# this point is a correct point
|
|
31 |
new_points.append( point )
|
|
32 |
setattr(self, self.imgLKPoints["labels"][counter], cv.cvPoint(int(point.x), int(point.y)))
|
|
33 |
|
|
34 |
# draw the current point
|
|
35 |
- cv.cvCircle (self.img, [point.x, point.y], 3, cv.cvScalar (0, 255, 0, 0), -1, 8, 0)
|
|
36 |
+ cv.cvCircle (self.img, (int(point.x), int(point.y)), 3, cv.cvScalar (0, 255, 0, 0), -1, 8, 0)
|
|
37 |
|
|
38 |
# increment the counter
|
|
39 |
counter += 1
|