]> wolfpit.net Git - hardware/fuck_tomatoes/.git/blame - Tests.py
Added live offset tuning
[hardware/fuck_tomatoes/.git] / Tests.py
CommitLineData
6c4aa5ec 1import Printer, time, cv2
2import numpy as np
fc9f5cd5 3from utils import Gcode, Detector, MaskProcessing
633c9ad0 4from User_Interface import Sliders
6c4aa5ec 5
fc9f5cd5
MR
6cap = cv2.VideoCapture(0)
7detector = Detector.InitializeBlobDetector()
8cv2.namedWindow('image')
9sliders = Sliders.Sliders('image')
10printer = Printer.Printer('COM4', (200, 200))
e09ed30e 11
fc9f5cd5
MR
12while 1:
13 ret, img = cap.read()
e09ed30e 14
fc9f5cd5
MR
15 colorMask = MaskProcessing.GetColorMask(img, sliders)
16 res = MaskProcessing.ProcessImageMask(colorMask, img, sliders)
17
18 keyPoints = detector.detect(res)
19 img = cv2.drawKeypoints(img, keyPoints, np.array([]), (255, 0, 0), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
20
21 if keyPoints:
22 points = [xy.pt for xy in keyPoints]
23 printer.sendPackage(points)
24
25
26 # print('-------PACKAGE COUNT: %d-------'%(len(points)))
27 # print(Gcode.buildGcodePackage(points, printer, False))
28
29 cv2.imshow('image', res)
30 cv2.imshow('color', colorMask)
31 cv2.imshow('cum', img)
32
33 command = cv2.waitKey(10) & 0xFF
34 if command == ord('q'): break