diff --git a/assets/sins.jpg b/assets/sins.jpg new file mode 100644 index 0000000..eec730b Binary files /dev/null and b/assets/sins.jpg differ diff --git a/image_drawer.py b/image_drawer.py deleted file mode 100644 index 9fbe787..0000000 --- a/image_drawer.py +++ /dev/null @@ -1,43 +0,0 @@ -import matplotlib.pyplot as plt -import dobot -import time - -DRAW_MODE = 1 -DRAW_SPEED = 1 -DRAW_SIZE = 40 -DRAW_DEPTH = -69 -DRAW_RES = 2 - -INIT_POSITION = [240, -10] - -dobot.setQueuedCmdClear() -dobot.setQueuedCmdStartExec() - -dobot.setPTPJumpParams(5, 3, 1) - -matrix = [] -for x in range(INIT_POSITION[0], INIT_POSITION[0]+DRAW_SIZE, DRAW_RES): - for y in range(INIT_POSITION[1], INIT_POSITION[1]+DRAW_SIZE, DRAW_RES): - matrix.append((x,y)) - -for point in matrix: - dobot.setPTPCmd(1, point[0], point[1], DRAW_DEPTH+5, 0, 1) - dobot.setPTPCmd(1, point[0], point[1], DRAW_DEPTH, 0, 1) - dobot.setPTPCmd(1, point[0], point[1], DRAW_DEPTH+5, 0, 1) - - dobot.setWaitCmd(3) - time.sleep(0.8) - -def pixel_draw(resolution): - pass - -def vector_draw(array): - for vector in array: - dobot.setCPCmd(DRAW_MODE, array.x, array.y, array.z, DRAW_SPEED, 1) - -# Stop the current execution -if input("Appuyez sur Entrer pour arrĂȘter.") == "": - dobot.setQueuedCmdForceStopExec() - dobot.setQueuedCmdClear() - -# Define current workspace \ No newline at end of file diff --git a/demo_jump.py b/src/demo_jump.py similarity index 100% rename from demo_jump.py rename to src/demo_jump.py diff --git a/dobot.py b/src/dobot.py similarity index 100% rename from dobot.py rename to src/dobot.py diff --git a/src/image_drawer.py b/src/image_drawer.py new file mode 100644 index 0000000..c6f8340 --- /dev/null +++ b/src/image_drawer.py @@ -0,0 +1,69 @@ +import matplotlib.pyplot as plt +import dobot +import time +import cv2 as cv + +# Drawing parameters +DRAW_MODE = 1 +DRAW_SPEED = 1 # Drawing speed for +DRAW_DEPTH = -67.8 # Initial height (null) +DRAW_RES = 1 # Space between pixels +THRESHOLD = 70 # Min. intensityfrom which a pixel must be drawn + +INIT_POSITION = [210, -60] + +dobot.setQueuedCmdClear() +dobot.setQueuedCmdStartExec() + +def pixel_draw(imagepath): + + # Load Image + im = cv.imread(imagepath) + if im is None: + print("Error: Image not found at", imagepath) + exit() + + # Resize Image + im = cv.resize(im, (0, 0), fx = 0.05, fy = 0.05, interpolation=cv.INTER_LINEAR) + + # Convert to Grayscale + im = cv.cvtColor(im, cv.COLOR_BGR2GRAY) + + # Window name in which image is displayed + window_name = 'Display' + + # Using cv2.imshow() method + # Displaying the image + im_display = cv.resize(im, (0, 0), fx = 10, fy = 10, interpolation=cv.INTER_LINEAR) + print(im) + print(im.shape[0], im.shape[1]) + cv.imshow(window_name, im_display) + # waits for user to press any key + # (this is necessary to avoid Python kernel form crashing) + cv.waitKey(0) + + for x in range(0, im.shape[0]-1): + for y in range(0, im.shape[1]-1): + value = im[x][y] + print(value) + + if value >= THRESHOLD: + dobot.setPTPCmd(1, INIT_POSITION[0]+x*DRAW_RES, INIT_POSITION[1]+y*DRAW_RES, DRAW_DEPTH+2.5, 0, 1) + dobot.setPTPCmd(1, INIT_POSITION[0]+x*DRAW_RES, INIT_POSITION[1]+y*DRAW_RES, DRAW_DEPTH-(value/255), 0, 1) + dobot.setPTPCmd(1, INIT_POSITION[0]+x*DRAW_RES, INIT_POSITION[1]+y*DRAW_RES, DRAW_DEPTH+2.5, 0, 1) + + #dobot.setWaitCmd(5) + time.sleep(0.8) + +def vector_draw(array): + for vector in array: + dobot.setCPCmd(DRAW_MODE, array.x, array.y, array.z, DRAW_SPEED, 1) + +pixel_draw("C:/Users/alexl/Documents/Cours/S7/IT and Robotics/GrpC_Identikit/assets/sins.jpg") + +# Stop the current execution +"""if input("Appuyez sur Entrer pour arrĂȘter.") == "": + dobot.setQueuedCmdForceStopExec() + dobot.setQueuedCmdClear() +""" +# Define current workspace \ No newline at end of file diff --git a/vitesse.py b/src/vitesse.py similarity index 100% rename from vitesse.py rename to src/vitesse.py