1 | initial version |
rectangle draws from the first point, to the second point. The first point should be the top left, and the second is the bottom right. Assuming the points are always in order, your last line should look like this.
rectangle(image, new Point(cornerpoints[0].x, cornerpoints[0].y), new Point(cornerpoints[1].x, cornerpoints[1].y), new Scalar(255, 255, 0));