예제 #1
0
    def __init__(self,
                 name=None,
                 params={},
                 color='white',
                 bEqualizeHist=False):
        self.name = name
        self.bEqualizeHist = bEqualizeHist

        self.bValidMask = False

        self.color = color
        self.bgra = ui.bgra_dict[color]
        self.bgra_dim = tuple(0.5 * np.array(ui.bgra_dict[color]))
        self.bgra_state = ui.bgra_dict[color]  #ui.bgra_dict['red']
        self.pixelmax = 255.0

        self.shape = (np.inf, np.inf)
        self.ptHinge_i = np.array([0, 0])
        self.roi = None

        self.mask = Struct()
        self.mask.img = None
        self.mask.sum = 1.0
        self.mask.xMin = None
        self.mask.yMin = None
        self.mask.xMax = None
        self.mask.yMax = None

        self.dt = np.inf

        self.params = {}
        self.handles = {
            'hinge':
            ui.Handle(np.array([0, 0]), self.bgra, name='hinge'),
            'angle_hi':
            ui.Handle(np.array([0, 0]), self.bgra, name='angle_hi'),
            'angle_lo':
            ui.Handle(np.array([0, 0]), self.bgra, name='angle_lo'),
            'radius_inner':
            ui.Handle(np.array([0, 0]), self.bgra, name='radius_inner')
        }

        self.lockBackground = threading.Lock()

        # Region of interest images.
        self.imgFullBackground = None
        self.imgRoiBackground = None
        self.imgRoi = None  # Untouched roi image.
        self.imgRoiFg = None  # Background subtracted.
        self.imgRoiFgMasked = None
        self.imgFinal = None  # The image to use for tracking.
        self.imgHeadroom = None

        # Extra windows.
        self.windowBG = ImageWindow(False, self.name + 'BG')
        self.windowFG = ImageWindow(False, self.name + 'FG')
        self.windowMask = ImageWindow(gbShowMasks, self.name + 'Mask')
예제 #2
0
    def __init__(self, name=None, params={}, color='white', bEqualizeHist=False):
        MotionTrackedBodypartPolar.__init__(self, name, params, color, bEqualizeHist)
        
        self.phasecorr          = imageprocessing.PhaseCorrelation()
        self.state              = MsgState() # In the bodypart frame.
        self.stateOrigin_p      = MsgState() # In the bodypart frame.
        self.stateLo_p          = MsgState() # In the bodypart frame.
        self.stateHi_p          = MsgState() # In the bodypart frame.

        self.imgComparison      = None
        
        self.windowStabilized   = ImageWindow(False, self.name+'Stable')
        self.windowComparison   = ImageWindow(True, self.name+'Comparison')
        self.set_params(params)
예제 #3
0
    def __init__(self,
                 name=None,
                 params={},
                 color='white',
                 bEqualizeHist=False):
        self.name = name
        self.bEqualizeHist = bEqualizeHist

        self.bValidMask = False

        self.bgra = ui.bgra_dict[color]
        self.bgra_dim = tuple(0.5 * np.array(ui.bgra_dict[color]))
        self.bgra_state = ui.bgra_dict[color]  #ui.bgra_dict['red']
        self.pixelmax = 255.0

        self.shape = (np.inf, np.inf)
        self.ptCenter_i = np.array([0, 0])
        self.roi = None

        self.mask = Struct()
        self.mask.img = None
        self.mask.sum = 1.0

        self.dt = np.inf

        self.params = {}
        self.handles = {
            'center': ui.Handle(np.array([0, 0]), self.bgra, name='center'),
            'radius1': ui.Handle(np.array([0, 0]), self.bgra, name='radius1'),
            'radius2': ui.Handle(np.array([0, 0]), self.bgra, name='radius2')
        }

        # Region of interest images.
        self.imgFullBackground = None
        self.imgRoiBackground = None
        self.imgRoi = None  # Untouched roi image.
        self.imgRoiFg = None  # Background subtracted.
        self.imgRoiFgMasked = None

        # Extra windows.
        self.windowBG = ImageWindow(False, self.name + 'BG')
        self.windowFG = ImageWindow(False, self.name + 'FG')
        self.windowMask = ImageWindow(gbShowMasks, self.name + 'Mask')
예제 #4
0
    def __init__(self, name=None, params={}, color='white', bEqualizeHist=False):
        MotionTrackedBodypart.__init__(self, name, params, color, bEqualizeHist)
        
        self.name       = name
        self.detector   = EdgeDetectorByHoughTransform(self.name, params)
        self.state      = MsgState()
        self.windowEdges = ImageWindow(False, self.name+'Edges')
        self.set_params(params)

        # Services, for live intensities plots via live_wing_histograms.py
        self.service_trackerdata    = rospy.Service('trackerdata_'+self.name, SrvTrackerdata, self.serve_trackerdata_callback)
예제 #5
0
    def __init__(self, name=None, params={}, color='white', bEqualizeHist=False):
        MotionTrackedBodypartPolar.__init__(self, name, params, color, bEqualizeHist)
        
        self.name     = name
        self.detector = TipDetector()
        self.state    = MsgState()
        self.set_params(params)
        self.windowTip = ImageWindow(False, self.name+'Tip')
        self.iAngle = 0
        self.iRadius = 0

        # Services, for live intensities plots via live_wing_histograms.py
        self.service_trackerdata    = rospy.Service('trackerdata_'+self.name, SrvTrackerdata, self.serve_trackerdata_callback)
예제 #6
0
    def __init__(self,
                 name=None,
                 params={},
                 color='white',
                 bEqualizeHist=False):
        MotionTrackedBodypart.__init__(self, name, params, color,
                                       bEqualizeHist)

        self.name = name
        self.detector = EdgeDetectorByHoughTransform(self.name, params)
        self.state = MsgState()
        self.windowEdges = ImageWindow(False, self.name + 'Edges')
        self.set_params(params)
예제 #7
0
 def openFile(self):
     """Slot for the openFile action."""
     from SXM import FileIO,Data
     fname = str(QFileDialog.getOpenFileName(self.widget,self.tr("Open File"), \
             ".",FileIO.getFilterString(types=(Data.Image,))))
     if len(fname) > 0:
         root, ext = os.path.splitext(fname)
         self.statusBar().showMessage(self.tr("Loading data: %1").arg(fname),2000)
         image = FileIO.fromFile(fname)
         image.load()
         imwin = ImageWindow(self,image)
         self.Images.append(imwin)
         self.updateImageList()
         imwin.windowModality = False
         imwin.show()
예제 #8
0
    def __init__(self,
                 name=None,
                 params={},
                 color='white',
                 bEqualizeHist=False):
        MotionTrackedBodypartPolar.__init__(self, name, params, color,
                                            bEqualizeHist)

        self.name = name
        self.detector = TipDetector()
        self.state = MsgState()
        self.set_params(params)
        self.windowTip = ImageWindow(False, self.name + 'Tip')
        self.iAngle = 0
        self.iRadius = 0
예제 #9
0
    def __init__(self,
                 name=None,
                 params={},
                 color='white',
                 bEqualizeHist=False):
        MotionTrackedBodypart.__init__(self, name, params, color,
                                       bEqualizeHist)

        self.polartransforms = imageprocessing.PolarTransforms()
        self.create_wfn = imageprocessing.WindowFunctions().create_tukey
        self.wfnRoiMaskedPolarCropped = None

        self.imgRoiFgMaskedPolar = None
        self.imgRoiFgMaskedPolarCropped = None
        self.imgRoiFgMaskedPolarCroppedWindowed = None
        self.imgFinal = None  # The image to use for tracking.
        self.imgHeadroomPolar = None

        self.windowPolar = ImageWindow(False, self.name + 'Polar')
예제 #10
0
    def __init__(self, params={}):
        self.nodename = rospy.get_name().rstrip('/')
        EdgeTracker = EdgeTrackerByIntensityProfile
        #EdgeTracker = EdgeTrackerByHoughTransform

        # Create the body axis tracker.
        self.axis = AxisTracker(name='axis', params=params, color='yellow')

        # Create the head tracker.
        if (params['head']['tracker'] == 'area'):
            self.head = AreaTracker(name='head',
                                    params=params,
                                    color='cyan',
                                    bEqualizeHist=False)
        elif (params['head']['tracker'] == 'edge'):
            self.head = EdgeTracker(name='head',
                                    params=params,
                                    color='cyan',
                                    bEqualizeHist=False)
        elif (params['head']['tracker'] == 'tip'):
            self.head = TipTracker(name='head',
                                   params=params,
                                   color='cyan',
                                   bEqualizeHist=False)
        elif (params['head']['tracker'] == 'intensity'):
            self.head = IntensityTracker(name='head',
                                         params=params,
                                         color='cyan',
                                         bEqualizeHist=False)
        else:
            rospy.logwarn('Head tracker parameter must be one of ['
                          'area'
                          ', '
                          'edge'
                          ', '
                          'tip'
                          ', '
                          'intensity'
                          ']')

        # Create the abdomen tracker.
        if (params['abdomen']['tracker'] == 'area'):
            self.abdomen = AreaTracker(name='abdomen',
                                       params=params,
                                       color='magenta',
                                       bEqualizeHist=False)
        elif (params['abdomen']['tracker'] == 'edge'):
            self.abdomen = EdgeTracker(name='abdomen',
                                       params=params,
                                       color='magenta',
                                       bEqualizeHist=False)
        elif (params['abdomen']['tracker'] == 'tip'):
            self.abdomen = TipTracker(name='abdomen',
                                      params=params,
                                      color='magenta',
                                      bEqualizeHist=False)
        elif (params['abdomen']['tracker'] == 'intensity'):
            self.abdomen = IntensityTracker(name='abdomen',
                                            params=params,
                                            color='magenta',
                                            bEqualizeHist=False)
        else:
            rospy.logwarn('Abdomen tracker parameter must be one of ['
                          'area'
                          ', '
                          'edge'
                          ', '
                          'tip'
                          ', '
                          'intensity'
                          ']')

        # Create the right wing tracker.
        if (params['right']['tracker'] == 'area'):
            self.right = AreaTracker(name='right',
                                     params=params,
                                     color='red',
                                     bEqualizeHist=False)
        elif (params['right']['tracker'] == 'edge'):
            self.right = EdgeTracker(name='right',
                                     params=params,
                                     color='red',
                                     bEqualizeHist=False)
        elif (params['right']['tracker'] == 'tip'):
            self.right = TipTracker(name='right',
                                    params=params,
                                    color='red',
                                    bEqualizeHist=False)
        elif (params['right']['tracker'] == 'intensity'):
            self.right = IntensityTracker(name='right',
                                          params=params,
                                          color='red',
                                          bEqualizeHist=False)
        else:
            rospy.logwarn('Right wing tracker parameter must be one of ['
                          'area'
                          ', '
                          'edge'
                          ', '
                          'tip'
                          ', '
                          'intensity'
                          ']')

        # Create the left wing tracker.
        if (params['left']['tracker'] == 'area'):
            self.left = AreaTracker(name='left',
                                    params=params,
                                    color='green',
                                    bEqualizeHist=False)
        elif (params['left']['tracker'] == 'edge'):
            self.left = EdgeTracker(name='left',
                                    params=params,
                                    color='green',
                                    bEqualizeHist=False)
        elif (params['left']['tracker'] == 'tip'):
            self.left = TipTracker(name='left',
                                   params=params,
                                   color='green',
                                   bEqualizeHist=False)
        elif (params['left']['tracker'] == 'intensity'):
            self.left = IntensityTracker(name='left',
                                         params=params,
                                         color='green',
                                         bEqualizeHist=False)
        else:
            rospy.logwarn('Left wing tracker parameter must be one of ['
                          'area'
                          ', '
                          'edge'
                          ', '
                          'tip'
                          ', '
                          'intensity'
                          ']')

        # Create the aux tracker.
        self.aux = IntensityTracker(name='aux',
                                    params=params,
                                    color='yellow',
                                    bEqualizeHist=False)

        self.windowInvertColorArea = ImageWindow(False, 'InvertColorArea')

        self.bgra_body = ui.bgra_dict['light_gray']
        self.ptBodyIndicator1 = None
        self.ptBodyIndicator2 = None
        self.bInvertColor = False
        self.bInvertColorAuto = True
        self.iCount = 0
        self.stampPrev = None
        self.stampPrevAlt = None
        self.stamp = rospy.Time(0)

        self.pubFlystate = rospy.Publisher(self.nodename + '/flystate',
                                           MsgFlystate,
                                           queue_size=100)