mtcnn icon indicating copy to clipboard operation
mtcnn copied to clipboard

Why flip dx1, dy1, dx2, dy2 in generateBoundingBox when y.shape[0]==1? Please help me~

Open KLH1472 opened this issue 7 years ago • 1 comments

    def __generate_bounding_box(imap, reg, scale, t):

        # use heatmap to generate bounding boxes
        stride = 2
        cellsize = 12

        imap = np.transpose(imap)
        dx1 = np.transpose(reg[:, :, 0])
        dy1 = np.transpose(reg[:, :, 1])
        dx2 = np.transpose(reg[:, :, 2])
        dy2 = np.transpose(reg[:, :, 3])

        y, x = np.where(imap >= t)

        if y.shape[0] == 1:
            dx1 = np.flipud(dx1)
            dy1 = np.flipud(dy1)
            dx2 = np.flipud(dx2)
            dy2 = np.flipud(dy2)

        score = imap[(y, x)]
        reg = np.transpose(np.vstack([dx1[(y, x)], dy1[(y, x)], dx2[(y, x)], dy2[(y, x)]]))

        if reg.size == 0:
            reg = np.empty(shape=(0, 3))

        bb = np.transpose(np.vstack([y, x]))

        q1 = np.fix((stride * bb + 1)/scale)
        q2 = np.fix((stride * bb + cellsize)/scale)
        boundingbox = np.hstack([q1, q2, np.expand_dims(score, 1), reg])

        return boundingbox, reg

KLH1472 avatar Oct 07 '18 10:10 KLH1472

I am also wondering for the same thing. @KLH1472 did you manage to find out the answer to this?

oliviawindsir avatar Jan 01 '20 13:01 oliviawindsir