def process(self, inframe, outframe):
        jevois.LINFO("process with usb")

        # Get the next camera image (may block until it is captured):
        inimg = inframe.get()
        jevois.LINFO("Input image is {} {}x{}".format(jevois.fccstr(inimg.fmt), inimg.width, inimg.height))

        # Get the next available USB output image:
        outimg = outframe.get()
        jevois.LINFO("Output image is {} {}x{}".format(jevois.fccstr(outimg.fmt), outimg.width, outimg.height))

        # Example of getting pixel data from the input and copying to the output:
        jevois.paste(inimg, outimg, 0, 0)

        # We are done with the input image:
        inframe.done()

        # Example of in-place processing:
        jevois.hFlipYUYV(outimg)

        # Example of simple drawings:
        jevois.drawCircle(outimg, int(outimg.width/2), int(outimg.height/2), int(outimg.height/4),
                          2, jevois.YUYV.White)
        jevois.writeText(outimg, "Hi from Python - @MODULE@", 20, 20, jevois.YUYV.White, jevois.Font.Font10x20)
        
        # We are done with the output, ready to send it to host over USB:
        outframe.send()

        # Send a string over serial (e.g., to an Arduino). Remember to tell the JeVois Engine to display those messages,
        # as they are turned off by default. For example: 'setpar serout All' in the JeVois console:
        jevois.sendSerial("DONE frame {}".format(self.frame));
        self.frame += 1
示例#2
0
    def __init__(self):
        jevois.LINFO("Preseason2019 Constructor")
        # Instantiate a JeVois Timer to measure our processing framerate:
        self.timer = jevois.Timer("sandbox", 100, jevois.LOG_INFO)
        """initializes all values to presets or None if need to be set
        """
        self.__hsl_threshold_hue = [0, 255.0]
        self.__hsl_threshold_saturation = [0, 255.0]
        self.__hsl_threshold_luminance = [0, 255.0]

        self.hsl_threshold_output = None

        self.__find_contours_input = self.hsl_threshold_output
        self.__find_contours_external_only = False

        self.find_contours_output = None

        self.__filter_contours_contours = self.find_contours_output
        self.__filter_contours_min_area = 0.0
        self.__filter_contours_min_perimeter = 0
        self.__filter_contours_min_width = 0
        self.__filter_contours_max_width = 1000
        self.__filter_contours_min_height = 0
        self.__filter_contours_max_height = 1000
        self.__filter_contours_solidity = [0, 100]
        self.__filter_contours_max_vertices = 1000000
        self.__filter_contours_min_vertices = 0
        self.__filter_contours_min_ratio = 0
        self.__filter_contours_max_ratio = 1000

        self.filter_contours_output = None
        
        try:
            fInit = open("modules/Lightning/Template/vals.txt", "r")
            if(fInit.mode == "r"):
                valsInit = fInit.read().split('[')[1].split(',')
                self.__hsl_threshold_hue[0] = float(valsInit[0])
                self.__hsl_threshold_hue[1] = float(valsInit[1])
                self.__hsl_threshold_saturation[0] = float(valsInit[2])
                self.__hsl_threshold_saturation[1] = float(valsInit[3])
                self.__hsl_threshold_luminance[0] = float(valsInit[4])
                self.__hsl_threshold_luminance[1] = float(valsInit[5])
                self.__filter_contours_min_area = float(valsInit[6])
            fInit.close()
        except:
            jevois.LINFO("Error loading parameters from file")
            
            
        self.sendFrames = True

        jevois.LINFO("END CONSTRUCTOR")
示例#3
0
 def parseSerial(self, str):
     jevois.LINFO("parseserial received command [{}]".format(str))
     cmd, args = str.split(" ", maxsplit=1)
     if cmd == "armothy_pos":
         pass
         return self.parsePosMsg(args)
     return "ERR Unsupported command: {}".format(str)
示例#4
0
 def parseSerial(self, input):
     jevois.LINFO('parseserial received command [{}]'.format(input))
     command = input.split(' ', 1)[0]
     if command == 'getVals':
         return self.getVals()
     if command == 'setHMin':
         return self.setHMin(input)
     if command == 'setHMax':
         return self.setHMax(input)
     if command == 'setSMin':
         return self.setSMin(input)
     if command == 'setSMax':
         return self.setSMax(input)
     if command == 'setLMin':
         return self.setLMin(input)
     if command == 'setLMax':
         return self.setLMax(input)
     if command == 'setMinArea':
         return self.setMinArea(input)
     if command == 'saveParams':
         return self.saveParams(input)
     if command == 'stopSendFrames':
         return self.stopPrintFrames()
     if command == 'sendFrames':
         return self.printFrames()
     if command == 'showHSL':
         self.displayHSLOutput = True;
         return 'Showing HSL output'
     if command == 'showContour':
         self.displayHSLOutput = False;
         return 'Showing contour output'
     return 'ERR: Unknown command'
示例#5
0
 def parseSerial(self, str):
     jevois.LINFO("parseserial received command [{}]".format(str))
     if str == "hello":
         return self.hello()
     elif str == "Geevoooice":
         return self.hi()
     return "ERR: Unsupported command"
示例#6
0
 def loadCameraCalibration(self, w, h):
     cpf = "/jevois/share/camera/calibration{}x{}.yaml".format(w, h)
     fs = cv2.FileStorage(cpf, cv2.FILE_STORAGE_READ)
     if (fs.isOpened()):
         self.camMatrix = fs.getNode("camera_matrix").mat()
         self.distCoeffs = fs.getNode("distortion_coefficients").mat()
         jevois.LINFO("Loaded camera calibration from {}".format(cpf))
     else:
         jevois.LFATAL("Failed to read camera parameters from file [{}]".format(cpf))
 def parseSerial(self, str):
     jevois.LINFO("parseserial received command [{}]".format(str))
     
     #Command to reset previous target
     if str == "latch":
         self.prevlcent=0
         self.prevrcent=0
         self.resetcounter+=1
         return "Reset Completed"
     return "ERR Unsupported command"
    def parseSerial(self, command):
        if command.strip() == "":
            # For some reason, the jevois engine sometimes sends empty strings.
            # Just do nothing in this case.
            return ""

        jevois.LINFO("parseserial received command [{}]".format(command))
        if command == "target":
            return self.target()
        return "ERR: Unsupported command."
示例#9
0
    def processNoUSB(self, inframe):
        # Get the next camera image (may block until it is captured) and here convert it to OpenCV BGR. If you need a
        # grayscale image, just use getCvGRAY() instead of getCvBGR(). Also supported are getCvRGB() and getCvRGBA():
        inimg = inframe.getCvBGR()

        # Start measuring image processing time (NOTE: does not account for input conversion time):
        self.timer.start()

        pucks_circles = self.find_pucks(inimg)
        jevois.LINFO("FUUUUCK")
        jevois.sendSerial("{}".format(self.serialize_puck_list(pucks_circles)))
示例#10
0
 def parseSerial(self, str):
     global x #the threshold pixels to trigger a change
     jevois.LINFO("parseserial received command [{}]".format(str))
     if str == "hello":
         return self.hello()
     elif "setthresh" in str:
        inputline=str.split(" ")
        x=int(inputline[1])
        return self.setthresh()
     else:
        return "ERR Unsupported command"
示例#11
0
 def loadCameraCalibration(self, w, h):
     """Loads the camera calibration from disk for the given width and height of the image"""
     calibFile = '/jevois/share/camera/calibration{}x{}.yaml'.format(w, h)
     fs = cv2.FileStorage(calibFile, cv2.FILE_STORAGE_READ)
     if fs.isOpened():
         self.camMatrix = fs.getNode("camera_matrix").mat()
         self.distCoeffs = fs.getNode("distortion_coefficients").mat()
         jevois.LINFO(f"Loaded camera calibration from {calibFile}")
     else:
         jevois.LFATAL(
             f"Failed to read camera calibration parameters from {calibFile}"
         )
示例#12
0
 def parseSerial(self, str):
     jevois.LINFO("parseSerial received command [{}]".format(str))
     parts = str.split()
     try:
         if parts[0] == "setHSVMin":
             self.HSVmin, response = self.parseHSVValues(parts)
             return response
         if parts[0] == "setHSVMax":
             self.HSVmax, response = self.parseHSVValues(parts)
             return response
     except Exception as e:
         return "ERR {}".format(e)
     return "ERR Unsupported command {}".format(parts[0])
示例#13
0
    def parseSerial(self, str):

        if (str.strip() == ""):
            #For some reason, the jevois engine sometimes sends empty strings.
            # Just do nothing in this case.
            return ""

        jevois.LINFO("parseserial received command [{}]".format(str))
        if str == "hello":
            return self.hello()
        elif str == "Geevoooice":
            return self.hi()
        return "ERR: Unsupported command. "
示例#14
0
    def __init__(self):
        jevois.LINFO("CasseroleVision Constructor...")

        #Frame Index
        self.frame = 0

        #USB send frame decimation
        #Reduces send rate by this factor to limit USB bandwidth at high process rates
        self.frame_dec_factor = 6  #At 60FPS, this still delivers 10FPS to the driver

        #Processing tune constants
        #TODO - Pick better constants
        self.hsv_thres_lower = np.array([0, 0, 220])
        self.hsv_thres_upper = np.array([255, 255, 255])

        #Target Information
        self.tgtAngle = "0.0"
        self.tgtRange = "0.0"
        self.tgtAvailable = "f"

        #Timer and Variables to track statistics we care about
        self.timer = jevois.Timer("CasseroleVisionStats", 25, jevois.LOG_DEBUG)

        #regex for parsing info out of the status returned from the jevois Timer class
        self.pattern = re.compile(
            '([0-9]*\.[0-9]+|[0-9]+) fps, ([0-9]*\.[0-9]+|[0-9]+)% CPU, ([0-9]*\.[0-9]+|[0-9]+)C,'
        )

        #Tracked stats
        self.framerate_fps = "0"
        self.CPULoad_pct = "0"
        self.CPUTemp_C = "0"
        self.pipelineDelay_us = "0"

        #data structure object to hold info about the present data processed from the image fram
        self.curTargets = []

        jevois.LINFO("CasseroleVision construction Finished")
示例#15
0
    def process(self, inframe, outframe):

        #jevois.drawRect(inframe,50,50,50,50,5,0)

        inimg = inframe.getCvBGR()

        self.frame += 1

        # Send processed data
        jevois.LINFO("{-35,20,105,234}")
        jevois.sendSerial("DONE frame {} \n".format(self.frame))

        # We are done with the output, ready to send it to host over USB:
        outframe.sendCvBGR(inimg)
示例#16
0
    def __init__(self):
        jevois.LINFO("LancerVision Constructor...")

        # Frame Index
        self.frame = 0

        # USB send frame decimation
        # Reduces send rate by this factor to limit USB bandwidth at high process rates
        self.frame_dec_factor = 6  # At 60FPS, this still delivers 10FPS to the driver

        # Tuning constants
        self.hsv_thresh_lower = np.array([65, 195, 96])
        self.hsv_thresh_upper = np.array([92, 255, 255])

        # Target Information
        self.tgtAngle = "0.0"
        self.tgtRange = "0.0"
        self.tgtAvailable = "f"

        # Data structure object to hold info about the present data processed from the image frame
        self.curTargets = []
        self.sortedArray = []

        jevois.LINFO("LancerVision construction Finished")
示例#17
0
    def process(self, inframe, outframe):
        jevois.LINFO("process with usb")

        # Get the next camera image (may block until it is captured):
        source0 = inimg = inframe.getCvBGR()
        outimg = inimg = inframe.getCvBGR()

        # Example of getting pixel data from the input and copying to the output:
        outimg = inimg

        # Example of simple drawings:
        #jevois.drawCircle(outimg, int(outimg.width/2), int(outimg.height/2), int(outimg.height/2.2), 2, jevois.YUYV.White)
        #jevois.writeText(outimg, "Hi from Python!", 20, 20, jevois.YUYV.White, jevois.Font.Font10x20)

        # We are done with the output, ready to send it to host over USB:
        outframe.sendCvBGR(outimg)
示例#18
0
    def processNoUSB(self, inframe):
        # Get the next camera image (may block until it is captured) and here convert it to OpenCV BGR. If you need a
        # grayscale image, just use getCvGRAY() instead of getCvBGR(). Also supported are getCvRGB() and getCvRGBA():
        inimg = inframe.getCvBGR()

        # Start measuring image processing time (NOTE: does not account for input conversion time):
        self.timer.start()
        
        jevois.LINFO("Processing video frame {} now...".format(self.frame))

        # TODO: you should implement some processing.
        # Once you have some results, send serial output messages:

        # Get frames/s info from our timer:
        fps = self.timer.stop()

        # Send a serial output message:
        jevois.sendSerial("DONE frame {} - {}".format(self.frame, fps));
        self.frame += 1
示例#19
0
    def processImage(self, img):
        '''
        process a single image
        return a dict with detected featured
        '''
        if self.save is not None:
            cv2.imwrite(self.save, img)
            jevois.LINFO(self.save)
            self.save = None

        detect = {}  # dict of detected objects

        size_factor = None
        if self.alt > 1000:
            size_factor = self.focal[0] * self.focal[1] / (self.alt * self.alt)

        # red
        ret = self.mailbox_red.detect(img, size_factor)
        if ret is not None:
            detect[MARK_RED] = ret
            self.send_message(MARK_RED, ret)

        # blue
        ret = self.mailbox_blue.detect(img, size_factor)
        if ret is not None:
            detect[MARK_BLUE] = ret
            self.send_message(MARK_BLUE, ret)

        # yellow
        ret = self.mailbox_yellow.detect(img, size_factor)
        if ret is not None:
            detect[MARK_YELLOW] = ret
            self.send_message(MARK_YELLOW, ret)

        # orange (assuming only one in image)
        ret = self.mailbox_orange.detect(img, size_factor)
        if ret is not None:
            detect[MARK_ORANGE] = ret
            self.send_message(MARK_ORANGE, ret)

        return detect
 def findDistBetweenCenters(median, thresh):
         #creates a circle at the center of the image
         cv2.circle(median,(int(getWidth(median)/2), int(getHeight(median)/2)), 5, (255,255,255), -1)
         #finds the moments of the threshold image
         M = cv2.moments(thresh)
         #if statement prevents a divide by zero error
         try:
             if(M["m00"] !=0):
                 #Finds the x and y cordinates of the center of the two vision targets
                 cX = int(M["m10"]/M["m00"])
                 cY = int(M["m01"]/M["m00"])
                 #creates a circle at the center of the vision targets
                 #cv2.circle(median,(cX, cY), 5, (255,255,255), -1)
                 #draws a line between the center of the screen and the center of the targets
                 #cv2.line(median, (cX,cY),(int(getWidth(median)/2), int(getHeight(median)/2)), (255,0,0),5)
                 #finds the distance between the center of the screen and the center of the targets (pixels)
                 dist = math.sqrt(math.pow((cX-(getWidth(median)/2)),2)+math.pow((cY-(getHeight(median)/2)),2))
                 #puts text on the screen regarding distance between the center of the screen and the vision targets (pixels)
                 #cv2.putText(median,'Distance: ' + str(int(dist))+ ' (pixels)' ,(0,int(getHeight(median))-35), font, .5,(255,255,255),1,cv2.LINE_AA)
         except:
             jevois.LINFO("Failed to get X,Y coordinates of the vision targets")
示例#21
0
    def parseSerial(self, str):
        global errode
        global dilate
        global approx
        global area
        global solidity
        global ratio

        jevois.LINFO("parseserial received command [{}]".format(str))

        if str == "hello":
            return self.hello()

        cal = str.split("=")

        if cal[0] == "errode":
            errode = int(cal[1])
            return cal[1]

        if cal[0] == "dilate":
            dilate = int(cal[1])
            return cal[1]

        if cal[0] == "approx":
            approx = int(cal[1])
            return cal[1]

        if cal[0] == "area":
            area = int(cal[1])
            return cal[1]

        if cal[0] == "solidity":
            solidity = int(cal[1]) / 100
            return cal[1]

        if cal[0] == "ratio":
            ratio = float(cal[1])
            return cal[1]

        return "ERR: Fat Fingered that command"
示例#22
0
 def __init__(self):
     jevois.LINFO("PythonTest Constructor")
     jevois.LINFO(dir(jevois))
     self.frame = 0  # a simple frame counter used to demonstrate sendSerial()
示例#23
0
 def __init__(self):
     jevois.LINFO("PythonTest Constructor")
示例#24
0
 def __init__(self):
     self.framecount = 0
     jv.LINFO("VulcanVoit ctor, sendTargets {}".format(
         VulcanVoit.sendTargets))
     jv.LINFO("VulcanVoit ctor, curDir {}".format(os.getcwd()))
示例#25
0
    def detect(self, imggray, outimg=None):
        h, w = imggray.shape
        hlist = []

        # Create a keypoint detector if needed:
        if not hasattr(self, 'detector'):
            self.detector = cv2.ORB_create()

        # Load training image and detect keypoints on it if needed:
        if not hasattr(self, 'refkp'):
            refimg = cv2.imread(self.fname, 0)
            self.refkp, self.refdes = self.detector.detectAndCompute(
                refimg, None)

            # Also store corners of reference image and of window for homography mapping:
            refh, refw = refimg.shape
            self.refcorners = np.float32([[0.0, 0.0], [0.0,
                                                       refh], [refw, refh],
                                          [refw, 0.0]]).reshape(-1, 1, 2)
            self.wincorners = np.float32(
                [[
                    self.winleft * refw / self.owm,
                    self.wintop * refh / self.ohm
                ],
                 [
                     self.winleft * refw / self.owm,
                     (self.wintop + self.winh) * refh / self.ohm
                 ],
                 [(self.winleft + self.winw) * refw / self.owm,
                  (self.wintop + self.winh) * refh / self.ohm],
                 [(self.winleft + self.winw) * refw / self.owm,
                  self.wintop * refh / self.ohm]]).reshape(-1, 1, 2)
            jevois.LINFO(
                "Extracted {} keypoints and descriptors from {}".format(
                    len(self.refkp), self.fname))

        # Compute keypoints and descriptors:
        kp, des = self.detector.detectAndCompute(imggray, None)
        str = "{} keypoints".format(len(kp))

        # Create a matcher if needed:
        if not hasattr(self, 'matcher'):
            self.matcher = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)

        # Compute matches between reference image and camera image, then sort them by distance:
        matches = self.matcher.match(des, self.refdes)
        matches = sorted(matches, key=lambda x: x.distance)
        str += ", {} matches".format(len(matches))

        # Keep only good matches:
        lastidx = 0
        for m in matches:
            if m.distance < self.distth: lastidx += 1
            else: break
        matches = matches[0:lastidx]
        str += ", {} good".format(len(matches))

        # If we have enough matches, compute homography:
        corners = []
        wincorners = []
        if len(matches) >= 10:
            obj = []
            scene = []

            # Localize the object (see JeVois C++ class ObjectMatcher for details):
            for m in matches:
                obj.append(self.refkp[m.trainIdx].pt)
                scene.append(kp[m.queryIdx].pt)

            # compute the homography
            hmg, mask = cv2.findHomography(np.array(obj), np.array(scene),
                                           cv2.RANSAC, 5.0)

            # Check homography conditioning using SVD:
            u, s, v = np.linalg.svd(hmg, full_matrices=False)

            # We need the smallest eigenvalue to not be too small, and the ratio of largest to smallest eigenvalue to be
            # quite large for our homography to be declared good here. Note that linalg.svd returns the eigenvalues in
            # descending order already:
            if s[-1] > 0.001 and s[0] / s[-1] > 100:
                # Project the reference image corners to the camera image:
                corners = cv2.perspectiveTransform(self.refcorners, hmg)
                wincorners = cv2.perspectiveTransform(self.wincorners, hmg)

        # Display any results requested by the users:
        if outimg is not None and outimg.valid():
            if len(corners) == 4:
                jevois.drawLine(outimg, int(corners[0][0, 0] + 0.5),
                                int(corners[0][0, 1] + 0.5),
                                int(corners[1][0, 0] + 0.5),
                                int(corners[1][0, 1] + 0.5), 2,
                                jevois.YUYV.LightPink)
                jevois.drawLine(outimg, int(corners[1][0, 0] + 0.5),
                                int(corners[1][0, 1] + 0.5),
                                int(corners[2][0, 0] + 0.5),
                                int(corners[2][0, 1] + 0.5), 2,
                                jevois.YUYV.LightPink)
                jevois.drawLine(outimg, int(corners[2][0, 0] + 0.5),
                                int(corners[2][0, 1] + 0.5),
                                int(corners[3][0, 0] + 0.5),
                                int(corners[3][0, 1] + 0.5), 2,
                                jevois.YUYV.LightPink)
                jevois.drawLine(outimg, int(corners[3][0, 0] + 0.5),
                                int(corners[3][0, 1] + 0.5),
                                int(corners[0][0, 0] + 0.5),
                                int(corners[0][0, 1] + 0.5), 2,
                                jevois.YUYV.LightPink)
            jevois.writeText(outimg, str, 3, h + 4, jevois.YUYV.White,
                             jevois.Font.Font6x10)

        # Return window corners if we did indeed detect the object:
        hlist = []
        if len(wincorners) == 4: hlist.append(wincorners)

        return hlist
 def parseSerial(self, str):
     jevois.LINFO("parseserial received command [{}]".format(str))
     if str =="GRATERTTT":
         self.GraterActivation=1
     else:
         return "ERR: Unsupported command"
 def __init__(self):
     jevois.LINFO("@MODULE@ Constructor")
     self.frame = 0 # a simple frame counter used to demonstrate sendSerial()
示例#28
0
 def process(self, inframe):
     jevois.LINFO("{-35,20,105,234}")
     jevois.sendSerial("test3\n")
示例#29
0
    def __init__(self):
        jevois.LINFO("PythonTest Constructor")
        # Instantiate a JeVois Timer to measure our processing framerate:
        self.timer = jevois.Timer("sandbox", 100, jevois.LOG_INFO)
        """initializes all values to presets or None if need to be set
        """

        self.__blur_input = None
        self.__blur_type = BlurType.Gaussian_Blur
        self.__blur_radius = 1.8867924528301883

        self.blur_output = None

        self.__hsl_threshold_input = self.blur_output

        #Original values
        self.__hsl_threshold_input = self.blur_output
        self.__hsl_threshold_hue = [32.203389830508456, 45.240641711229955]
        self.__hsl_threshold_saturation = [60.02824858757062, 255.0]
        self.__hsl_threshold_luminance = [
            14.406779661016945, 243.63636363636363
        ]

        self.hsl_threshold_output = None

        self.__cv_erode_0_src = self.hsl_threshold_output
        self.__cv_erode_0_kernel = None
        self.__cv_erode_0_anchor = (-1, -1)
        self.__cv_erode_0_iterations = 3.0
        self.__cv_erode_0_bordertype = cv2.BORDER_CONSTANT
        self.__cv_erode_0_bordervalue = (-1)

        self.cv_erode_0_output = None

        self.__cv_dilate_src = self.cv_erode_0_output
        self.__cv_dilate_kernel = None
        self.__cv_dilate_anchor = (-1, -1)
        self.__cv_dilate_iterations = 5.0
        self.__cv_dilate_bordertype = cv2.BORDER_CONSTANT
        self.__cv_dilate_bordervalue = (-1)

        self.cv_dilate_output = None

        self.__cv_erode_1_src = self.cv_dilate_output
        self.__cv_erode_1_kernel = None
        self.__cv_erode_1_anchor = (-1, -1)
        self.__cv_erode_1_iterations = 2.0
        self.__cv_erode_1_bordertype = cv2.BORDER_CONSTANT
        self.__cv_erode_1_bordervalue = (-1)

        self.cv_erode_1_output = None

        self.__find_contours_input = self.cv_erode_1_output
        self.__find_contours_external_only = False

        self.find_contours_output = None

        self.__filter_contours_contours = self.find_contours_output
        self.__filter_contours_min_area = 500.0
        self.__filter_contours_min_perimeter = 0.0
        self.__filter_contours_min_width = 0.0
        self.__filter_contours_max_width = 1.0E16
        self.__filter_contours_min_height = 0.0
        self.__filter_contours_max_height = 1.0E21
        self.__filter_contours_solidity = [84.74576271186443, 100]
        self.__filter_contours_max_vertices = 1000000.0
        self.__filter_contours_min_vertices = 0.0
        self.__filter_contours_min_ratio = 0.0
        self.__filter_contours_max_ratio = 1000.0

        #Attempt to load above values from file
        try:
            fInit = open("vals.txt", "r")
            if (fInit.mode == "r"):
                valsInit = fInit.read().split('[')[1].split(',')
                self.__hsl_threshold_hue[0] = float(valsInit[0])
                self.__hsl_threshold_hue[1] = float(valsInit[1])
                self.__hsl_threshold_saturation[0] = float(valsInit[2])
                self.__hsl_threshold_saturation[1] = float(valsInit[3])
                self.__hsl_threshold_luminance[0] = float(valsInit[4])
                self.__hsl_threshold_luminance[1] = float(valsInit[5])
                self.__filter_contours_min_area = float(valsInit[6])
            fInit.close()
        except:
            jevois.LINFO("Error loading parameters from file")

        self.filter_contours_output = None

        self.__convex_hulls_contours = self.filter_contours_output

        self.convex_hulls_output = None
        self.convex_hulls_filled = None
        self.frame = 0
        self.sendFrames = True

        self.displayHSLOutput = False

        self.momentAvg = [
            0.171877167, 0.002900258788, 3.97E-05, 2.71E-06, 3.38E-10,
            2.16E-07, 3.79E-11
        ]
        self.stdv = [
            0.01501932812, 0.006138597897, 0.0001147442133, 0.00001223416618,
            0.000000003403410003, 0.000001767205694, 0.0000000009515363047
        ]

        self.covarianceMtrx = [[self.stdv[0] * self.stdv[0], 0, 0, 0, 0, 0, 0],
                               [0, self.stdv[1] * self.stdv[1], 0, 0, 0, 0, 0],
                               [0, 0, self.stdv[2] * self.stdv[2], 0, 0, 0, 0],
                               [0, 0, 0, self.stdv[3] * self.stdv[3], 0, 0, 0],
                               [0, 0, 0, 0, self.stdv[4] * self.stdv[4], 0, 0],
                               [0, 0, 0, 0, 0, self.stdv[5] * self.stdv[5], 0],
                               [0, 0, 0, 0, 0, 0, self.stdv[6] * self.stdv[6]]]

        #self.covarMtrx = []
        #self.invCovarMtrx = cv2.invert(cv2.calcCovarMatrix(self.stdv), DECOMP_SVD)

        self.invCovarMtrx = np.linalg.inv(self.covarianceMtrx)

        self.recordVideo = False
        self.videoWriter = None
        self.rawVideoWriter = None
        self.hslVideoWriter = None

        jevois.LINFO("END CONSTRUCTOR")
示例#30
0
    def __init__(self):
        jevois.LINFO("PythonTest Constructor...")

        self.frame = 0  # a simple frame counter used to demonstrate sendSerial()

        jevois.LINFO("PythonTest construction Finished")