Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions car1
29 changes: 19 additions & 10 deletions medianflow++.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@

from os.path import abspath, exists

import os, sys, time
from glob import glob

import numpy as np

import cv, cv2

from rect_selector import RectSelector

from scipy.misc import imread, imresize

class MedianFlowTracker(object):
def __init__(self):
Expand Down Expand Up @@ -104,7 +107,8 @@ def track(self, target, prev, curr):

class API(object):
def __init__(self, win, source):
self._device = cv2.VideoCapture(source)
self._source = source
#self._device = cv2.VideoCapture(source)
if isinstance(source, str):
self.paused = True
else:
Expand All @@ -127,17 +131,20 @@ def on_rect(self, rect):
def run(self):
prev, curr = None, None

ret, frame = self._device.read()
if not ret:
raise IOError('can\'t reade frame')
data_files = []
read_path = os.path.join(self._source, "*.jpg")
data_files = glob(read_path)
data_files.sort()

frame = imread(data_files[0], mode='RGB') # test data in github

count = 0
while True:
if not self.rect_selector.dragging and not self.paused:
ret, grabbed_frame = self._device.read()
if not ret:
break

frame = grabbed_frame.copy()
print (data_files[count])
if not self.rect_selector.dragging and not self.paused:
count += 1
frame = imread(data_files[count], mode='RGB') # test data in github

prev, curr = curr, cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

Expand All @@ -156,6 +163,7 @@ def run(self):
angle = tgt[4] * 180.0 / np.pi
cv.Ellipse(cv.fromarray(frame), center, scale, angle, 0., 360., color, 2)


self.rect_selector.draw(frame)

cv2.imshow(self.win, frame)
Expand All @@ -167,6 +175,7 @@ def run(self):
self.paused = not self.paused



if __name__ == "__main__":
args = docopt(__doc__)

Expand Down
26 changes: 17 additions & 9 deletions medianflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@

from os.path import abspath, exists

import os, sys, time
from glob import glob
import numpy as np

import cv2

from rect_selector import RectSelector
from scipy.misc import imread, imresize


class MedianFlowTracker(object):
Expand Down Expand Up @@ -101,7 +104,8 @@ def track(self, bb, prev, curr):

class API(object):
def __init__(self, win, source):
self._device = cv2.VideoCapture(source)
self._source = source
#self._device = cv2.VideoCapture(source)
if isinstance(source, str):
self.paused = True
else:
Expand All @@ -120,17 +124,20 @@ def on_rect(self, rect):
def run(self):
prev, curr = None, None

ret, frame = self._device.read()
if not ret:
raise IOError('can\'t reade frame')
data_files = []
read_path = os.path.join(self._source, "*.jpg")
data_files = glob(read_path)
data_files.sort()

frame = imread(data_files[0], mode='RGB') # test data in github

count = 0
while True:
if not self.rect_selector.dragging and not self.paused:
ret, grabbed_frame = self._device.read()
if not ret:
break

frame = grabbed_frame.copy()
print (data_files[count])
if not self.rect_selector.dragging and not self.paused:
count += 1
frame = imread(data_files[count], mode='RGB') # test data in github

prev, curr = curr, cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

Expand All @@ -153,6 +160,7 @@ def run(self):
elif ch in (ord('p'), ord('P')):
self.paused = not self.paused


if __name__ == "__main__":
args = docopt(__doc__)

Expand Down