Due to the dangerous working environment and high working intensity of electrolytic aluminum workshop, aluminum ingot transfer robot is used to assist workers to sample and transport aluminum ingot, among which, accurate positioning of aluminum ingot is an important link. In the process of robot grasping aluminum ingot, there are some problems, such as uneven brightness, low contrast and small target to be detected, which affect the accuracy of identification and positioning. In order to solve the above problems, an optical correction method of aluminum ingot image based on adaptive gamma rays is proposed in this paper to improve the accuracy of target detection under extreme illumination conditions. After the YOLOX network detects the target, the space motion function is proposed to realize the conversion from two-dimensional(2D) plane coordinates to three-dimensional(3D) space coordinates. This algorithm can effectively solve the problem of low recognition accuracy caused by illumination. Through the calculation of space motion function, the positioning accuracy error of the manipulator is less than 5mm.