Example #1
0
    def setdefault(self, det):

        self.p = np.array([])
        self.cov = np.eye(4) * 1
        self.num_p = 30
        self.prob = np.array([])
        self.det = det

        # Init particles
        self.init_p()
Example #2
0
    def setdefault(self, subject):

        self.p = np.array([])
        #self.cov = np.eye(5) * 1
        self.cov = np.eye(6) * 1
        self.num_p = 30
        self.prob = np.array([])
        self.det = subject
        self.circle = subject.circle
        self.rb = subject.rot_box
        # Init particles
        self.init_p()
Example #3
0
    def setdefault(self, subject):

        self.p = np.array([])
        #self.cov = np.eye(5) * 1
        self.cov = np.eye(6) * 1
        self.num_p = 30
        self.prob = np.array([])
        self.det = subject
        self.circle = subject.circle
        self.rb = subject.rot_box
        # Init particles
        self.init_p()
Example #4
0
def alternativeAssociation(loss, distance, threshold, tr, res):

    print '-----'
    print 'Alfre2 association'
    print '-----'

    debug_flag = 0

    if debug_flag: print loss

    # get best detection for each tracker
    y, x = loss.shape

    new_res = np.array([[]])

    for jj in range(y):
        best_detection = loss[jj, :].argmin(axis=0)
        s = loss[jj, best_detection]
        # -- TOMA DE DECISIONES --
        # 1) anomalia del score
        mx = tr[jj].score_mu + 3 * tr[jj].score_sigma
        mn = tr[jj].score_mu - 3 * tr[jj].score_sigma
        if tr[jj].mature:
            if s > mn and s < mx:
                if not new_res.any():
                    new_res = np.array([[jj, best_detection]])
                else:
                    new_res = np.vstack(
                        (new_res, np.array([jj, best_detection])))
        else:
            if not new_res.any():
                new_res = np.array([[jj, best_detection]])
            else:
                new_res = np.vstack((new_res, np.array([jj, best_detection])))

        if debug_flag:
            #print 'loss: %s' \
            #      %  loss[jj, best_detection]
            print '[%s , %s] <-- %s' \
                  % (mn, mx, loss)
            #print 'mu: %s, sigma: %s' \
            #      % (tr[jj].score_mu, tr[jj].score_sigma)
            print tr[jj].score
            print
            print 'res'
            print res
            print 'new_res'
            print new_res

    return new_res
Example #5
0
def alternativeAssociation(loss, distance, threshold, tr, res):

    print '-----'
    print 'Alfre2 association'
    print '-----'

    debug_flag=0

    if debug_flag: print loss

    # get best detection for each tracker
    y, x = loss.shape

    new_res = np.array([[]])

    for jj in range(y):
        best_detection = loss[jj, :].argmin(axis = 0)
        s = loss[jj, best_detection]
        # -- TOMA DE DECISIONES --
        # 1) anomalia del score
        mx = tr[jj].score_mu + 3*tr[jj].score_sigma
        mn = tr[jj].score_mu - 3*tr[jj].score_sigma
        if tr[jj].mature:
            if s > mn and s < mx:
                if not new_res.any():
                    new_res = np.array([[jj, best_detection]])
                else:
                    new_res = np.vstack((new_res,np.array([jj, best_detection])))
        else:
            if not new_res.any():
                new_res = np.array([[jj, best_detection]])
            else:
                new_res = np.vstack((new_res, np.array([jj, best_detection])))

        if debug_flag:
            #print 'loss: %s' \
            #      %  loss[jj, best_detection]
            print '[%s , %s] <-- %s' \
                  % (mn, mx, loss)
            #print 'mu: %s, sigma: %s' \
            #      % (tr[jj].score_mu, tr[jj].score_sigma)
            print tr[jj].score
            print
            print 'res'
            print res
            print 'new_res'
            print new_res

    return new_res
Example #6
0
def getnotassociatedindex(len_sub, len_tr, del_tr, del_sub):

    non_tr = []
    non_sub = []

    non_sub = np.array(range(len_sub))
    non_tr = np.array(range(len_tr))

    non_sub = np.delete(non_sub, del_sub)
    non_tr = np.delete(non_tr, del_tr)

    non_sub = non_sub.tolist()
    non_tr = non_tr.tolist()

    return non_sub, non_tr
Example #7
0
def getnotassociatedindex(len_sub, len_tr, del_tr, del_sub):

    non_tr = []
    non_sub = []

    non_sub = np.array(range(len_sub))
    non_tr = np.array(range(len_tr))

    non_sub = np.delete(non_sub, del_sub)
    non_tr = np.delete(non_tr, del_tr)

    non_sub = non_sub.tolist()
    non_tr = non_tr.tolist()

    return non_sub, non_tr
Example #8
0
    def plikelihood(self):

        (x, y), (h, w), a = self.det
        det = np.floor(np.array([[x, y, h, w]]))
        yrep = np.ones((self.num_p, 4)) * det

        R2 = np.sum(np.power(self.p - yrep, 2), 1)
        width = 2 * (np.amax(np.sqrt(R2)) - np.amin(np.sqrt(R2)))
        prob = np.exp(-R2 / width)

        prob = prob / np.sum(prob)
        self.prob = prob

        self.sortprob()
Example #9
0
    def plikelihood(self):

        if self.update:
            (x, y), (h, w), a = self.rb

            det = np.floor(np.array([[x, y, h, w, x - self.p_star[0], y - self.p_star[1]]]))
            yrep = np.ones((self.num_p, 6)) * det

            R2 = np.sum(np.power(self.p[:, 0:6] - yrep, 2), 1)
            width = 2 * (np.amax(np.sqrt(R2)) - np.amin(np.sqrt(R2)))
            prob = np.exp(- R2 / width)

            a = np.sum(prob)
            if a != 0.0:
                prob = prob / np.sum(prob)
            self.prob = prob

            self.sortprob()
        self.calculatepstar()
Example #10
0
    def plikelihood(self):

        if self.update:
            (x, y), (h, w), a = self.rb

            det = np.floor(
                np.array([[x, y, h, w, x - self.p_star[0],
                           y - self.p_star[1]]]))
            yrep = np.ones((self.num_p, 6)) * det

            R2 = np.sum(np.power(self.p[:, 0:6] - yrep, 2), 1)
            width = 2 * (np.amax(np.sqrt(R2)) - np.amin(np.sqrt(R2)))
            prob = np.exp(-R2 / width)

            a = np.sum(prob)
            if a != 0.0:
                prob = prob / np.sum(prob)
            self.prob = prob

            self.sortprob()
        self.calculatepstar()
Example #11
0
    def plikelihood_new(self):

        if self.update:
            (x, y), (h, w), a = self.rb


            detectionExtended = np.floor(np.array([[x, y, h, w, x - self.p_star[0], y - self.p_star[1]]]))
            yrep = np.ones((self.num_p, 6)) * detectionExtended
            prob = gaussMixModelPDF(oneParticle,detectionExtended,p_star)


            R2 = np.sum(np.power(self.p[:, 0:6] - yrep, 2), 1)
            width = 2 * (np.amax(np.sqrt(R2)) - np.amin(np.sqrt(R2)))
            prob = np.exp(- R2 / width)

            a = np.sum(prob)

            if a != 0.0:
                prob = prob / np.sum(prob)
            self.prob = prob

            self.sortprob()
            self.calculatepstar()
Example #12
0
    def plikelihood_new(self):

        if self.update:
            (x, y), (h, w), a = self.rb

            detectionExtended = np.floor(
                np.array([[x, y, h, w, x - self.p_star[0],
                           y - self.p_star[1]]]))
            yrep = np.ones((self.num_p, 6)) * detectionExtended
            prob = gaussMixModelPDF(oneParticle, detectionExtended, p_star)

            R2 = np.sum(np.power(self.p[:, 0:6] - yrep, 2), 1)
            width = 2 * (np.amax(np.sqrt(R2)) - np.amin(np.sqrt(R2)))
            prob = np.exp(-R2 / width)

            a = np.sum(prob)

            if a != 0.0:
                prob = prob / np.sum(prob)
            self.prob = prob

            self.sortprob()
            self.calculatepstar()