Created
February 20, 2023 17:28
-
-
Save arnaldorusso/f26a537d216096aa3163ec5cfd1b0386 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
cap = cv2.VideoCapture(0) | |
while True: | |
_, frame = cap.read() | |
hsvMin = (20,120,120) | |
hsvMax = (49,255,255) | |
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) | |
mask = cv2.inRange(hsv, hsvMin, hsvMax) | |
# Erode and dilate | |
mask = cv2.erode(mask, None, iterations=3) | |
mask = cv2.dilate(mask, None, iterations=3) | |
params = cv2.SimpleBlobDetector_Params() | |
params.minThreshold = 0; | |
params.maxThreshold = 100; | |
# Filter by Area. | |
params.filterByArea = True | |
params.minArea = 400 | |
params.maxArea = 20000 | |
# Filter by Circularity | |
params.filterByCircularity = False | |
params.minCircularity = 0.1 | |
detector = cv2.SimpleBlobDetector(params) | |
reversemask = 255-mask | |
keypoints = detector.detect(reversemask) | |
x = keypoints[0]pt[0] | |
y = keypoints[0].pt[1] | |
@swim | |
def baba(): | |
#here I want to use ‘x’ and ‘y’ values | |
Pa >> d('bip:0~50' if x > 0.5 else 'jupbass:1~20', | |
midinote='<Do|Sol3|Sol4, Mib|Mib5, Sol|Sol6, Lab>^(-3~-1)', | |
amp=0.3, orbit=2, room='0.7', dry=0.2, size=0.8, # cut='1|0|0|0', | |
cut=1, shape=0.5, speed='1~3, 1, 0.5', | |
p='(0.25/2)!2,0.25,0.25!2', span=2) | |
Pc >> d('bip:0~50', midinote='Do3', amp=0.3, orbit=2, room='0.7', | |
dry=0.2, size=0.8, cut='1|0|0|0', shape=0.5, speed='1~3, 1, 0.5', | |
p='(0.25/2)!2,0.25,0.25!2', span=2) | |
Pe >> d('b!3, b:2', span=1, shape=0.5, amp=0.6, | |
delay=0.45, delaytime=1/3, delayfeedback=0.25) | |
Pf >> d('b:3~10, c:1~20', span=0.5, legato=0.125, room=0.8, | |
shape=0.5, amp=0.2, orbit=3, cut=1,) | |
again(baba) | |
key = cv2.waitKey(1) | |
if key == 27: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment