From 6b3a1c809207ef68b193bff7120878d2eaf24c6e Mon Sep 17 00:00:00 2001 From: Gorkem Date: Mon, 30 Nov 2020 14:22:06 +0300 Subject: [PATCH] SuperCollider Prototyping stage --- data.csv | 220 +++++++++++++++++-------------------------------------- test.py | 52 ++++++------- 2 files changed, 93 insertions(+), 179 deletions(-) diff --git a/data.csv b/data.csv index 30bb161..25a9f84 100644 --- a/data.csv +++ b/data.csv @@ -1,168 +1,80 @@ -3.495255115032627486e+02,2.329999417090298834e+02 +3.495320154929491423e+02,2.330079425878373058e+02 1.900000000000000000e+02,4.500000000000000000e+00 -8.950000000000000000e+01,9.500000000000000000e+00 -1.666666666666666785e+01,1.066666666666666607e+01 +1.700000000000000000e+01,1.100000000000000000e+01 5.335000000000000000e+02,1.150000000000000000e+01 -1.900000000000000000e+02,1.850000000000000000e+01 -1.770000000000000000e+02,2.200000000000000000e+01 -5.350000000000000000e+02,2.300000000000000000e+01 -5.605000000000000000e+02,2.250000000000000000e+01 -4.950000000000000000e+02,2.400000000000000000e+01 -2.880000000000000000e+02,2.700000000000000000e+01 -4.210000000000000000e+02,2.900000000000000000e+01 -2.071666666666666572e+02,3.116666666666666785e+01 -3.887500000000000000e+02,3.300000000000000000e+01 -1.040000000000000000e+02,3.900000000000000000e+01 -6.630000000000000000e+02,4.100000000000000000e+01 +5.605000000000000000e+02,2.300000000000000000e+01 +2.070000000000000000e+02,3.100000000000000000e+01 +3.886666666666666856e+02,3.266666666666666430e+01 6.400000000000000000e+01,4.750000000000000000e+01 -1.590000000000000000e+02,4.800000000000000000e+01 -2.645000000000000000e+02,5.600000000000000000e+01 -2.034000000000000057e+02,5.979999999999999716e+01 -6.195000000000000000e+02,6.950000000000000000e+01 -4.145000000000000000e+02,7.500000000000000000e+01 -6.985000000000000000e+02,7.450000000000000000e+01 +2.645000000000000000e+02,5.650000000000000000e+01 +2.035000000000000000e+02,5.950000000000000000e+01 +6.980000000000000000e+02,7.450000000000000000e+01 1.800000000000000000e+01,7.800000000000000000e+01 -6.583333333333333712e+02,7.766666666666667140e+01 -3.285000000000000000e+02,7.800000000000000000e+01 -4.840000000000000000e+02,7.800000000000000000e+01 2.860000000000000000e+02,8.350000000000000000e+01 -4.926000000000000227e+02,8.620000000000000284e+01 -1.441250000000000000e+02,9.987500000000000000e+01 -1.660000000000000000e+02,1.030000000000000000e+02 -2.050000000000000000e+02,1.030000000000000000e+02 -4.065000000000000000e+02,1.040000000000000000e+02 -4.550000000000000000e+02,1.070000000000000000e+02 -2.200000000000000000e+01,1.125000000000000000e+02 -4.475000000000000000e+02,1.140000000000000000e+02 -4.756666666666666856e+02,1.126666666666666714e+02 -5.705000000000000000e+02,1.165000000000000000e+02 -2.520000000000000000e+02,1.190000000000000000e+02 -6.513333333333333712e+02,1.183333333333333286e+02 -4.700000000000000000e+01,1.230000000000000000e+02 -2.860000000000000000e+02,1.220000000000000000e+02 -3.015000000000000000e+02,1.235000000000000000e+02 -5.665000000000000000e+02,1.255000000000000000e+02 -6.275000000000000000e+02,1.265000000000000000e+02 -6.620000000000000000e+02,1.287142857142857224e+02 -3.205000000000000000e+02,1.345000000000000000e+02 -3.770000000000000000e+02,1.395000000000000000e+02 -3.875000000000000000e+02,1.450000000000000000e+02 -2.435000000000000000e+02,1.470000000000000000e+02 -2.190000000000000000e+02,1.530000000000000000e+02 -4.340000000000000000e+02,1.520000000000000000e+02 -1.217142857142857082e+02,1.550000000000000000e+02 -4.595000000000000000e+02,1.555000000000000000e+02 -5.050000000000000000e+02,1.540000000000000000e+02 +4.925000000000000000e+02,8.600000000000000000e+01 +1.440000000000000000e+02,1.000000000000000000e+02 +4.070000000000000000e+02,1.040000000000000000e+02 +2.200000000000000000e+01,1.120000000000000000e+02 +4.475000000000000000e+02,1.135000000000000000e+02 +4.760000000000000000e+02,1.130000000000000000e+02 +5.700000000000000000e+02,1.160000000000000000e+02 +6.510000000000000000e+02,1.185000000000000000e+02 +3.015000000000000000e+02,1.240000000000000000e+02 +5.663333333333333712e+02,1.253333333333333286e+02 +6.275000000000000000e+02,1.270000000000000000e+02 +6.620000000000000000e+02,1.285000000000000000e+02 +3.210000000000000000e+02,1.345000000000000000e+02 +3.770000000000000000e+02,1.400000000000000000e+02 +2.430000000000000000e+02,1.470000000000000000e+02 +1.217500000000000000e+02,1.550000000000000000e+02 1.760000000000000000e+02,1.560000000000000000e+02 -4.385000000000000000e+02,1.600000000000000000e+02 -1.096666666666666714e+02,1.636666666666666572e+02 -4.787500000000000000e+01,1.731250000000000000e+02 -5.736666666666666288e+02,1.726666666666666572e+02 -4.230000000000000000e+02,1.750000000000000000e+02 -4.355000000000000000e+02,1.745000000000000000e+02 -4.900000000000000000e+02,1.772857142857142776e+02 -2.000000000000000000e+01,1.840000000000000000e+02 -1.646666666666666572e+02,1.926666666666666572e+02 -5.050000000000000000e+02,1.940000000000000000e+02 -2.740000000000000000e+02,2.010000000000000000e+02 -5.935000000000000000e+02,2.055000000000000000e+02 -3.287103004291845423e+02,2.241523605150214564e+02 -6.633333333333333712e+02,2.143333333333333428e+02 -4.060000000000000000e+02,2.195000000000000000e+02 -5.620000000000000000e+02,2.200000000000000000e+02 -6.800000000000000000e+02,2.280000000000000000e+02 -1.165000000000000000e+02,2.325000000000000000e+02 -1.350000000000000000e+02,2.340000000000000000e+02 -4.145000000000000000e+02,2.360000000000000000e+02 -2.985000000000000000e+02,2.395000000000000000e+02 -2.845000000000000000e+02,2.400000000000000000e+02 -6.080000000000000000e+02,2.400000000000000000e+02 -2.740000000000000000e+02,2.420000000000000000e+02 -2.576000000000000227e+02,2.448000000000000114e+02 -1.745000000000000000e+02,2.515000000000000000e+02 -2.810000000000000000e+02,2.550000000000000000e+02 +4.595000000000000000e+02,1.560000000000000000e+02 +4.380000000000000000e+02,1.600000000000000000e+02 +1.100000000000000000e+02,1.635000000000000000e+02 +4.783333333333333570e+01,1.731666666666666572e+02 +4.353333333333333144e+02,1.743333333333333428e+02 +4.905000000000000000e+02,1.775000000000000000e+02 +1.645000000000000000e+02,1.930000000000000000e+02 +5.940000000000000000e+02,2.055000000000000000e+02 +3.287189349112426271e+02,2.242278106508875624e+02 +6.635000000000000000e+02,2.140000000000000000e+02 +1.170000000000000000e+02,2.325000000000000000e+02 +4.150000000000000000e+02,2.360000000000000000e+02 +2.980000000000000000e+02,2.395000000000000000e+02 +2.575000000000000000e+02,2.445000000000000000e+02 3.715000000000000000e+02,2.560000000000000000e+02 -3.896666666666666856e+02,2.566666666666666856e+02 -5.150000000000000000e+02,2.670000000000000000e+02 -6.900000000000000000e+01,2.700000000000000000e+02 -2.650000000000000000e+02,2.685000000000000000e+02 -4.216666666666666856e+02,2.693333333333333144e+02 -4.925000000000000000e+02,2.715000000000000000e+02 -2.560000000000000000e+02,2.850000000000000000e+02 -3.920000000000000000e+02,2.870000000000000000e+02 -2.645000000000000000e+02,2.885000000000000000e+02 -4.706666666666666856e+02,2.893333333333333144e+02 -2.250000000000000000e+02,2.932857142857142776e+02 -3.766666666666666856e+02,2.956666666666666856e+02 -6.120000000000000000e+02,2.945000000000000000e+02 -1.130000000000000000e+02,2.960000000000000000e+02 -2.377500000000000000e+02,2.992500000000000000e+02 -4.310000000000000000e+02,3.015000000000000000e+02 -2.460000000000000000e+02,3.025000000000000000e+02 -6.660000000000000000e+02,3.020000000000000000e+02 -5.733333333333333712e+02,3.053333333333333144e+02 -4.768333333333333144e+02,3.088333333333333144e+02 +3.900000000000000000e+02,2.565000000000000000e+02 +6.928571428571429180e+01,2.700000000000000000e+02 +4.220000000000000000e+02,2.690000000000000000e+02 +4.920000000000000000e+02,2.715000000000000000e+02 +2.643333333333333144e+02,2.886666666666666856e+02 +4.710000000000000000e+02,2.890000000000000000e+02 +2.245000000000000000e+02,2.935000000000000000e+02 +2.378750000000000000e+02,2.993125000000000000e+02 +3.770000000000000000e+02,2.960000000000000000e+02 +4.766666666666666856e+02,3.086666666666666856e+02 3.445000000000000000e+02,3.105000000000000000e+02 -3.320000000000000000e+02,3.120000000000000000e+02 -1.101666666666666714e+02,3.168333333333333144e+02 +1.100000000000000000e+02,3.170000000000000000e+02 2.110000000000000000e+02,3.165000000000000000e+02 -6.400000000000000000e+02,3.225000000000000000e+02 -6.580000000000000000e+02,3.225000000000000000e+02 -2.355000000000000000e+02,3.275000000000000000e+02 -3.495000000000000000e+02,3.285000000000000000e+02 -4.007142857142857224e+02,3.305000000000000000e+02 -1.920000000000000000e+02,3.320000000000000000e+02 -3.230000000000000000e+02,3.330000000000000000e+02 -1.135000000000000000e+02,3.350000000000000000e+02 -1.920000000000000000e+02,3.360000000000000000e+02 -5.612857142857143344e+02,3.420000000000000000e+02 -3.905000000000000000e+02,3.420000000000000000e+02 -4.405000000000000000e+02,3.440000000000000000e+02 -3.200000000000000000e+02,3.500000000000000000e+02 -4.520000000000000000e+02,3.552857142857142776e+02 -4.910000000000000000e+02,3.560000000000000000e+02 +3.495000000000000000e+02,3.290000000000000000e+02 +4.008888888888889142e+02,3.303333333333333144e+02 +5.615000000000000000e+02,3.415000000000000000e+02 +4.515000000000000000e+02,3.555000000000000000e+02 1.450000000000000000e+02,3.585000000000000000e+02 -5.500000000000000000e+01,3.610000000000000000e+02 4.460000000000000000e+02,3.615000000000000000e+02 -6.390000000000000000e+02,3.600000000000000000e+02 -4.240000000000000000e+02,3.635000000000000000e+02 -5.416666666666666288e+02,3.646666666666666856e+02 -4.178750000000000000e+02,3.671250000000000000e+02 -4.150000000000000000e+02,3.705000000000000000e+02 -5.330000000000000000e+02,3.710000000000000000e+02 -2.450000000000000000e+02,3.755000000000000000e+02 -9.500000000000000000e+00,3.770000000000000000e+02 -6.860000000000000000e+02,3.780000000000000000e+02 -6.750000000000000000e+02,3.880000000000000000e+02 -3.150000000000000000e+02,3.910000000000000000e+02 -2.380000000000000000e+02,3.945000000000000000e+02 -3.375000000000000000e+02,3.950000000000000000e+02 -4.960000000000000000e+02,3.940000000000000000e+02 +4.178333333333333144e+02,3.671666666666666856e+02 +1.000000000000000000e+01,3.770000000000000000e+02 +2.450000000000000000e+02,3.760000000000000000e+02 5.375000000000000000e+02,3.950000000000000000e+02 -1.130000000000000000e+02,3.970000000000000000e+02 -4.840000000000000000e+02,4.010000000000000000e+02 -2.580000000000000000e+02,4.030000000000000000e+02 -4.506666666666666856e+02,4.026666666666666856e+02 -6.460000000000000000e+02,4.025000000000000000e+02 -4.550000000000000000e+02,4.050000000000000000e+02 -4.260000000000000000e+02,4.065000000000000000e+02 -2.650000000000000000e+02,4.120000000000000000e+02 -3.095000000000000000e+02,4.135000000000000000e+02 -2.450000000000000000e+02,4.190000000000000000e+02 -2.175000000000000000e+02,4.250000000000000000e+02 -4.250000000000000000e+02,4.260000000000000000e+02 -6.270000000000000000e+02,4.280000000000000000e+02 -1.385000000000000000e+02,4.310000000000000000e+02 -3.568333333333333144e+02,4.341666666666666856e+02 -3.776000000000000227e+02,4.341999999999999886e+02 -3.195000000000000000e+02,4.425000000000000000e+02 +4.510000000000000000e+02,4.030000000000000000e+02 +4.260000000000000000e+02,4.070000000000000000e+02 +3.096666666666666856e+02,4.133333333333333144e+02 +2.170000000000000000e+02,4.250000000000000000e+02 +3.566666666666666856e+02,4.343333333333333144e+02 +3.776666666666666856e+02,4.343333333333333144e+02 +3.190000000000000000e+02,4.420000000000000000e+02 3.230000000000000000e+02,4.435000000000000000e+02 -3.600000000000000000e+02,4.442857142857142776e+02 -4.450000000000000000e+02,4.430000000000000000e+02 -4.380000000000000000e+02,4.480000000000000000e+02 -2.020000000000000000e+02,4.545000000000000000e+02 -2.080000000000000000e+02,4.600000000000000000e+02 -3.500000000000000000e+01,4.620000000000000000e+02 -2.797500000000000000e+02,4.630000000000000000e+02 +3.596666666666666856e+02,4.443333333333333144e+02 +2.020000000000000000e+02,4.540000000000000000e+02 +2.800000000000000000e+02,4.630000000000000000e+02 4.625000000000000000e+02,4.640000000000000000e+02 -6.755000000000000000e+02,4.650000000000000000e+02 diff --git a/test.py b/test.py index 8f8efd7..c6161d1 100644 --- a/test.py +++ b/test.py @@ -9,18 +9,20 @@ from osc4py3 import oscbuildparse #github test osc_startup() osc_udp_client("127.0.0.1", 57120, "local") -note_C = oscbuildparse.OSCMessage("/note_C", None, ["C",440]) -note_Db = oscbuildparse.OSCMessage("/note_Db", None, ["text"]) -note_D = oscbuildparse.OSCMessage("/note_D", None, ["text"]) -note_Eb = oscbuildparse.OSCMessage("/note_Eb", None, ["text"]) -note_E = oscbuildparse.OSCMessage("/note_E", None, ["text"]) -note_F = oscbuildparse.OSCMessage("/note_F", None, ["text"]) -note_Gb = oscbuildparse.OSCMessage("/note_Gb", None, ["text"]) -note_G = oscbuildparse.OSCMessage("/note_G", None, ["text"]) -note_Ab = oscbuildparse.OSCMessage("/note_Ab", None, ["text"]) -note_A = oscbuildparse.OSCMessage("/note_A", None, ["text"]) -note_Bb = oscbuildparse.OSCMessage("/note_Bb", None, ["text"]) -note_B = oscbuildparse.OSCMessage("/note_B", None, ["text"]) + +note_C = oscbuildparse.OSCMessage("/notes", None, ["C",440]) + +# note_Db = oscbuildparse.OSCMessage("/note_Db", None, ["text"]) +# note_D = oscbuildparse.OSCMessage("/note_D", None, ["text"]) +# note_Eb = oscbuildparse.OSCMessage("/note_Eb", None, ["text"]) +# note_E = oscbuildparse.OSCMessage("/note_E", None, ["text"]) +# note_F = oscbuildparse.OSCMessage("/note_F", None, ["text"]) +# note_Gb = oscbuildparse.OSCMessage("/note_Gb", None, ["text"]) +# note_G = oscbuildparse.OSCMessage("/note_G", None, ["text"]) +# note_Ab = oscbuildparse.OSCMessage("/note_Ab", None, ["text"]) +# note_A = oscbuildparse.OSCMessage("/note_A", None, ["text"]) +# note_Bb = oscbuildparse.OSCMessage("/note_Bb", None, ["text"]) +# note_B = oscbuildparse.OSCMessage("/note_B", None, ["text"]) #import imutils CONNECTIVITY = 4 @@ -28,7 +30,7 @@ DRAW_CIRCLE_RADIUS = 5 imageorg = cv2.imread('testimage.jpg') imageorginal = cv2.imread('testimage.jpg') gray = cv2.cvtColor(imageorg, cv2.COLOR_BGR2GRAY) -thresh = cv2.threshold(gray, 80, 255, cv2.THRESH_BINARY)[1] +thresh = cv2.threshold(gray, 120, 255, cv2.THRESH_BINARY)[1] height, width, channels = imageorg.shape # perform a series of erosions and dilations to remove @@ -119,8 +121,8 @@ for x in range(int(height / 2)): # distance[3] = 1 elif (distance[3]==0) and (distance[2] <= x) and inArea(int(distance[0]),int(distance[1]),int(width/2),int(height/2),int((width / 2) + numpy.sqrt(3)*int(height / 2)/2), int(height / 2 - int(height / 2) / 2),int(width/2 + height / 2), int(height / 2)): cv2.circle(imageorg, (int(distance[0]),int(distance[1])), DRAW_CIRCLE_RADIUS, (50, 150, 20), thickness=1) - osc_send(note_D, "local") - osc_process() + #osc_send(note_D, "local") + #osc_process() distance[3] = 1 # elif (distance[3]==0) and (distance[2] <= x) and inArea(int(distance[0]),int(distance[1]),int(width/2),int(height/2),int(width/2 + height / 2), int(height / 2),int((width / 2) + numpy.sqrt(3)*int(height / 2)/2), int(height / 2 + int(height / 2) / 2)): # cv2.circle(imageorg, (int(distance[0]),int(distance[1])), DRAW_CIRCLE_RADIUS, (200, 100, 50), thickness=1) @@ -129,13 +131,13 @@ for x in range(int(height / 2)): # distance[3] = 1 elif (distance[3]==0) and (distance[2] <= x) and inArea(int(distance[0]),int(distance[1]),int(width/2),int(height/2),int((width / 2) + numpy.sqrt(3)*int(height / 2)/2), int(height / 2 + int(height / 2) / 2),int((width / 2) + int(height / 2) / 2), int(height / 2 + numpy.sqrt(3)*int(height / 2)/2)): cv2.circle(imageorg, (int(distance[0]),int(distance[1])), DRAW_CIRCLE_RADIUS, (200, 200, 50), thickness=1) - osc_send(note_E, "local") - osc_process() + #osc_send(note_E, "local") + #osc_process() distance[3] = 1 elif (distance[3]==0) and (distance[2] <= x) and inArea(int(distance[0]),int(distance[1]),int(width/2),int(height/2),int((width / 2) + int(height / 2) / 2), int(height / 2 + numpy.sqrt(3)*int(height / 2)/2),int(width / 2),int(height)): cv2.circle(imageorg, (int(distance[0]),int(distance[1])), DRAW_CIRCLE_RADIUS, (200, 200, 200), thickness=1) - osc_send(note_F, "local") - osc_process() + #osc_send(note_F, "local") + #osc_process() distance[3] = 1 # elif (distance[3]==0) and (distance[2] <= x) and inArea(int(distance[0]),int(distance[1]),int(width/2),int(height/2),int(width / 2),int(height),int((width / 2) - int(height / 2) / 2), int(height / 2 + numpy.sqrt(3)*int(height / 2)/2)): # cv2.circle(imageorg, (int(distance[0]),int(distance[1])), DRAW_CIRCLE_RADIUS, (0, 200, 200), thickness=1) @@ -144,8 +146,8 @@ for x in range(int(height / 2)): # distance[3] = 1 elif (distance[3]==0) and (distance[2] <= x) and inArea(int(distance[0]),int(distance[1]),int(width/2),int(height/2),int((width / 2) - int(height / 2) / 2), int(height / 2 + numpy.sqrt(3)*int(height / 2)/2),int((width / 2) - numpy.sqrt(3)*int(height / 2)/2), int(height / 2 + int(height / 2) / 2)): cv2.circle(imageorg, (int(distance[0]),int(distance[1])), DRAW_CIRCLE_RADIUS, (0, 250, 200), thickness=1) - osc_send(note_G, "local") - osc_process() + #osc_send(note_G, "local") + #osc_process() distance[3] = 1 # elif (distance[3]==0) and (distance[2] <= x) and inArea(int(distance[0]),int(distance[1]),int(width/2),int(height/2),int((width / 2) - numpy.sqrt(3)*int(height / 2)/2), int(height / 2 + int(height / 2) / 2),int((width / 2) - (height / 2)),int(height / 2) ): # cv2.circle(imageorg, (int(distance[0]),int(distance[1])), DRAW_CIRCLE_RADIUS, (0,50, 250), thickness=1) @@ -154,8 +156,8 @@ for x in range(int(height / 2)): # distance[3] = 1 elif (distance[3]==0) and (distance[2] <= x) and inArea(int(distance[0]),int(distance[1]),int(width/2),int(height/2),int((width / 2) - (height / 2)),int(height / 2),int((width / 2) - numpy.sqrt(3)*int(height / 2)/2), int(height / 2 - int(height / 2) / 2) ): cv2.circle(imageorg, (int(distance[0]),int(distance[1])), DRAW_CIRCLE_RADIUS, (0,150, 250), thickness=1) - osc_send(note_A, "local") - osc_process() + #osc_send(note_A, "local") + #osc_process() distance[3] = 1 # elif (distance[3]==0) and (distance[2] <= x) and inArea(int(distance[0]),int(distance[1]),int(width/2),int(height/2),int((width / 2) - numpy.sqrt(3)*int(height / 2)/2), int(height / 2 - int(height / 2) / 2),int((width / 2) - int(height / 2) / 2), int(height / 2 - numpy.sqrt(3)*int(height / 2)/2) ): # cv2.circle(imageorg, (int(distance[0]),int(distance[1])), DRAW_CIRCLE_RADIUS, (0,200, 250), thickness=1) @@ -164,8 +166,8 @@ for x in range(int(height / 2)): # distance[3] = 1 elif (distance[3]==0) and (distance[2] <= x) and inArea(int(distance[0]),int(distance[1]),int(width/2),int(height/2),int((width / 2) - int(height / 2) / 2), int(height / 2 - numpy.sqrt(3)*int(height / 2)/2),int(width / 2),0 ): cv2.circle(imageorg, (int(distance[0]),int(distance[1])), DRAW_CIRCLE_RADIUS, (50,250, 250), thickness=1) - osc_send(note_B, "local") - osc_process() + #osc_send(note_B, "local") + #osc_process() distance[3] = 1 #cv2.circle(imageorg, (389,33), DRAW_CIRCLE_RADIUS, (0, 255, 0), thickness=1)