OneOneLiu / ggcnn_cornell_dataset

cornell grasp dataset analyses and process
49 stars 12 forks source link

Question about the definition of axis X and Y in the code #5

Closed PPatrickGU closed 3 years ago

PPatrickGU commented 3 years ago

Hello, I am confused by the aixs X and Y in the function as_gr.

def as_gr(self):
    """
    Convert to GraspRectangle
    :return: GraspRectangle representation of grasp.
    """
    xo = np.cos(self.angle)
    yo = np.sin(self.angle)

    y1 = self.center[0] + self.length / 2 * yo
    x1 = self.center[1] - self.length / 2 * xo
    y2 = self.center[0] - self.length / 2 * yo
    x2 = self.center[1] + self.length / 2 * xo

    return GraspRectangle(np.array(
        [
         [y1 - self.width/2 * xo, x1 - self.width/2 * yo],
         [y2 - self.width/2 * xo, x2 - self.width/2 * yo],
         [y2 + self.width/2 * xo, x2 + self.width/2 * yo],
         [y1 + self.width/2 * xo, x1 + self.width/2 * yo],
         ]
    ).astype(np.float))

The definition of axis X and Y is different for images and in mathsmatics. Does the code use the definition in mathsmatics instead of in imgae in the code above?

OneOneLiu commented 3 years ago

Hello, I am confused by the aixs X and Y in the function as_gr.

def as_gr(self):
    """
    Convert to GraspRectangle
    :return: GraspRectangle representation of grasp.
    """
    xo = np.cos(self.angle)
    yo = np.sin(self.angle)

    y1 = self.center[0] + self.length / 2 * yo
    x1 = self.center[1] - self.length / 2 * xo
    y2 = self.center[0] - self.length / 2 * yo
    x2 = self.center[1] + self.length / 2 * xo

    return GraspRectangle(np.array(
        [
         [y1 - self.width/2 * xo, x1 - self.width/2 * yo],
         [y2 - self.width/2 * xo, x2 - self.width/2 * yo],
         [y2 + self.width/2 * xo, x2 + self.width/2 * yo],
         [y1 + self.width/2 * xo, x1 + self.width/2 * yo],
         ]
    ).astype(np.float))

The definition of axis X and Y is different for images and in mathsmatics. Does the code use the definition in mathsmatics instead of in imgae in the code above?

I believe it is as same as the definition used in the image processing, in which the y-axis is looking down and the x-axis is looking right. You can draw a simple graph to figure it out.

When use image coordination, you can determine the position of the four corner points and their order.

But when use mathematic coordination, I just cannot find the proper position of the points through the formula of the code.

check this file simple illustration.pdf

PPatrickGU commented 3 years ago

Thanks a lot !!!! Your explanation is very clear. I mix up the direction of axis X and Y in the image, that's why I can't find the proper formular. : )