示例#1
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()
示例#2
0
    def pmfrnd(self):

        x = np.arange(self.num_p)

        dist = np.cumsum(self.prob)
        rndnum = np.random.rand()
        k = np.sum(rndnum > dist)

        return x[k]
示例#3
0
    def pmfrnd(self):

        x = np.arange(self.num_p)

        dist = np.cumsum(self.prob)
        rndnum = np.random.rand()
        k = np.sum(rndnum > dist)

        return x[k]
示例#4
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()
示例#5
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()
示例#6
0
    def resample(self):

        if np.sum(self.prob) > 0:

            p = self.p
            y, x = p.shape
            new_p = np.zeros((y, x))

            for ii in range(len(self.p)):
                idx = self.pmfrnd()
                new_p[ii, :] = p[idx, :]

            self.p = new_p
示例#7
0
    def resample(self):

        if np.sum(self.prob) > 0:

            p = self.p
            y, x = p.shape
            new_p = np.zeros((y, x))

            for ii in range(len(self.p)):
                idx = self.pmfrnd()
                new_p[ii, :] = p[idx, :]

            self.p = new_p
示例#8
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()
示例#9
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()
示例#10
0
    def calculatepstar(self):

        if np.sum(self.prob) != 0:
            self.p_star = np.average(self.p, axis = 0, weights = self.prob)
        else:
            self.p_star = np.average(self.p, axis = 0)
示例#11
0
    def calculatepstar(self):

        if np.sum(self.prob) != 0:
            self.p_star = np.average(self.p, axis=0, weights=self.prob)
        else:
            self.p_star = np.average(self.p, axis=0)