Start by passing the input image to Grounding Dino to identify the dollar bill and generate a bounding box over it.
Use the center point of the bounding box as a prompt for SAM to generate a segmentation mask of the dollar.
Use OpenCV to extract contours from the mask and approximate them as a polygon.
If the resulting polygon is a rectangle, save its center point.
Identify the bottom-left vertex of the polygon and construct two vectors using its two nearest neighbors.
Compute the orientation of the dollar bill as the angle between the shorter vector and the x-axis.
Perform calibration to establish the ground level.
Locate dollar bill, if it is not fully in frame, move towards the dollar bill.
Lower end effector and orient gripper with long axis.
Pick up dollar bill and place on green square.