When unmanned underwater vehicle (UUV) uses the binocular camera to search and positioning underwater operation target, its roll and pitch will lead to the pose and depth errors of visual images. As a result, the localization accuracy will be reduced. Therefore, real-time correction and compensation are necessary. To cope with this problem, a virtual image affine transformation method is utilized in this paper. First, we calculate camera's optical center coordinate offsets and the main optical axis angle according to UUV physical size, the installation factors of binocular camera and the information of UUV roll and pitch angles. Then the homogeneous equation of image correction and compensation is established to make the virtual affine transformation. Finally, visual image deviation is compensated caused by the UUV roll and pitch. Tank simulation test is performed to demonstrate the feasibility and effectiveness of the proposed method. Simulation results verify that the developed approach can guarantee high accuracy and meet good real-time performance demand of visual servo control.