When the robot grasps the U-shaped snap on the automatic production line, the pose detection and the positioning of the gripping point of the snap should be solved. To solve this problem, we propose the improved algorithm of YOLOv5, which can obtain the rotation angle and gripping point coordinates of the U-shaped snap. Firstly, the training sample angle information is obtained by roLabellmg. Secondly, in order to obtain the predicted angle, the algorithm adds a new angle prediction dimension and replaces the original positive box IOU with the minimum external rectangle IOU of the rotating box containing the angle information when calculating the IOU. Finally, the gripping point coordinates are determined on different poses of the U-shaped snap according to the robotic gripping rules, respectively. On the homemade U-shaped snap data set, the mAP value reaches 91.2%, which proves the effectiveness of the proposed method.