This paper presents a method for accurately segmenting moving container trucks in image sequences. This task allows to increase the performance of a recognition system that must identify the container code in order to check the entrance of containers through a port gate. To achieve good tolerance to non uniform backgrounds and the presence of multiple moving containers, an optical flow-based strategy is proposed. The algorithm introduces a voting strategy to detect the largest planar surface that shows a uniform motion of advance. Then, the top and rear limits of this surface are detected by a fast and effective method that searches for the limit that maximizes some object / non-object ratios. The method has been tested offline with a set of prerecorded sequences, achieving satisfactory results.