Skip to content

Commit

Permalink
OpenCV and python fixed for version 3
Browse files Browse the repository at this point in the history
Signed-off-by: George Litos <[email protected]>
  • Loading branch information
glls committed Mar 1, 2017
1 parent fdefe64 commit 2ce879b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions capturemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 15,7 @@ def __init__(self, capture, preview_window_manager=None):
self._frame = None
self._image_filename = None
self._start_time = None
self._frames_elapsed = long(0)
self._frames_elapsed = int(0)
self._fps_estimate = None

@property
Expand All @@ -31,7 31,7 @@ def channel(self, value):
@property
def frame(self):
if self._entered_frame and self._frame is None:
_, self._frame = self._capture.retrieve(channel=self.channel)
_, self._frame = self._capture.retrieve()
return self._frame

@property
Expand All @@ -47,19 47,19 @@ def frames_elapsed(self, value):

@property
def fps(self):
fps = self._capture.get(cv2.cv.CV_CAP_PROP_FPS)
fps = self._capture.get(cv2.CAP_PROP_FPS)
if math.isnan(fps):
fps = self._fps_estimate
return fps

@property
def total_frames(self):
return long(self._capture.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT))
return int(self._capture.get(cv2.CAP_PROP_FRAME_COUNT))

@property
def video_size(self):
return (int(self._capture.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)),
int(self._capture.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)))
return (int(self._capture.get(cv2.CAP_PROP_FRAME_WIDTH)),
int(self._capture.get(cv2.CAP_PROP_FRAME_HEIGHT)))

@property
def is_writing_image(self):
Expand Down Expand Up @@ -114,6 114,6 @@ def write_image(self, filename):
self._image_filename = filename

def goto_frame(self, frame_number):
self._capture.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, frame_number)
if self._capture.get(cv2.cv.CV_CAP_PROP_POS_FRAMES) == frame_number:
self._capture.set(cv2.CAP_PROP_POS_FRAMES, frame_number)
if self._capture.get(cv2.CAP_PROP_POS_FRAMES) == frame_number:
return True
4 changes: 2 additions & 2 deletions typhon.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 136,8 @@ def rotate_image(self, image, angle):
return cv2.warpAffine(image, rot_mat, image.shape[0:2], flags=cv2.INTER_LINEAR)

def draw_text(self, frame, text, pos, color):
cv2.putText(frame, text, pos, cv2.FONT_HERSHEY_SIMPLEX, .5, (0,) * 3, 2, cv2.CV_AA)
cv2.putText(frame, text, pos, cv2.FONT_HERSHEY_SIMPLEX, .5, color, 1, cv2.CV_AA)
cv2.putText(frame, text, pos, cv2.FONT_HERSHEY_SIMPLEX, .5, (0,) * 3, 2, cv2.LINE_AA)
cv2.putText(frame, text, pos, cv2.FONT_HERSHEY_SIMPLEX, .5, color, 1, cv2.LINE_AA)

def image_to_text(self, img):
a = np.asarray(img)
Expand Down

0 comments on commit 2ce879b

Please sign in to comment.