Skip to content

Commit

Permalink
Merge pull request #1199 from mikel-brostrom/cmc_abc
Browse files Browse the repository at this point in the history
move preprocess to cmc interface class
  • Loading branch information
mikel-brostrom authored Nov 22, 2023
2 parents e4b02a1 + 7f65222 commit f964fe4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 72 deletions.
19 changes: 19 additions & 0 deletions boxmot/motion/cmc/cmc_interface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Mikel Broström 🔥 Yolo Tracking 🧾 AGPL-3.0 license

import cv2
import numpy as np
from abc import ABC, abstractmethod

Expand All @@ -21,3 +22,21 @@ def generate_mask(self, img, dets, scale):
mask[tlbr[1]:tlbr[3], tlbr[0]:tlbr[2]] = 0

return mask

def preprocess(self, img):

# bgr2gray
if self.grayscale:
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# resize
if self.scale is not None:
img = cv2.resize(
img,
(0, 0),
fx=self.scale,
fy=self.scale,
interpolation=cv2.INTER_LINEAR
)

return img
18 changes: 0 additions & 18 deletions boxmot/motion/cmc/ecc.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,6 @@ def __init__(
self.termination_criteria = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, max_iter, eps)
self.prev_img = None

def preprocess(self, img):

# bgr2gray
if self.grayscale:
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# resize
if self.scale is not None:
img = cv2.resize(
img,
(0, 0),
fx=self.scale,
fy=self.scale,
interpolation=cv2.INTER_LINEAR
)

return img

def apply(self, curr_img, dets):

if self.warp_mode == cv2.MOTION_HOMOGRAPHY:
Expand Down
18 changes: 0 additions & 18 deletions boxmot/motion/cmc/orb.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,6 @@ def __init__(
self.draw_keypoint_matches = draw_keypoint_matches
self.align = align

def preprocess(self, img):

# bgr2gray
if self.grayscale:
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# resize
if self.scale is not None:
img = cv2.resize(
img,
(0, 0),
fx=self.scale,
fy=self.scale,
interpolation=cv2.INTER_LINEAR
)

return img

def apply(self, img, dets):

H = np.eye(2, 3)
Expand Down
18 changes: 0 additions & 18 deletions boxmot/motion/cmc/sift.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,6 @@ def __init__(
self.draw_keypoint_matches = draw_keypoint_matches
self.align = align

def preprocess(self, img):

# bgr2gray
if self.grayscale:
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# resize
if self.scale is not None:
img = cv2.resize(
img,
(0, 0),
fx=self.scale,
fy=self.scale,
interpolation=cv2.INTER_LINEAR
)

return img

def apply(self, img, dets):

H = np.eye(2, 3)
Expand Down
18 changes: 0 additions & 18 deletions boxmot/motion/cmc/sof.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,6 @@ def __init__(
self.extractor = cv2.ORB_create(nfeatures=5)
self.matcher = cv2.BFMatcher(cv2.NORM_HAMMING)

def preprocess(self, img):

# bgr2gray
if self.grayscale:
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# resize
if self.scale is not None:
img = cv2.resize(
img,
(0, 0),
fx=self.scale,
fy=self.scale,
interpolation=cv2.INTER_LINEAR
)

return img

def apply(self, img, dets):

H = np.eye(2, 3)
Expand Down

0 comments on commit f964fe4

Please sign in to comment.