Skip to content

Commit

Permalink
add padding to contact detection
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborpelesz committed Feb 1, 2021
1 parent ae1f180 commit bc4b2ca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cubenect/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def __init__(self, flip=None, debug=False):
self.kernel_3 = np.ones((3,3), np.uint8)
self.kernel_5 = np.ones((5,5), np.uint8)
self.flip = flip
self.kinect_width = 640
self.kinect_height = 480
self.detection_padding = 10

def detect(self, frame):
# desaturate if necessary
Expand Down Expand Up @@ -73,6 +76,8 @@ def detect(self, frame):
M = cv2.moments(contact_contour)
cX = int(M["m10"] / M["m00"])
cY = int(M["m01"] / M["m00"])
contact_centers.append((cX,cY))
if cX > self.detection_padding and cX < self.kinect_width - self.detection_padding:
if cY > self.detection_padding and cY < self.kinect_height - self.detection_padding:
contact_centers.append((cX,cY))

return contact_centers

0 comments on commit bc4b2ca

Please sign in to comment.