Accurate tracking of organ motion during treatment is needed to improve the efficacy of radiation therapy. This work investigates the feasibility of tracking an uncontoured target using the motion detected within a moving treatment aperture. Tracking was achieved with a weighted optical flow algorithm, and three different techniques for updating the reference image were evaluated. The accuracy and susceptibility of each approach to the accumulation of position errors were verified using a 3D-printed tumor (mounted on an actuator) and a virtual treatment aperture. Tumor motion up to 15.8 mm (peak-to-peak) taken from the breathing patterns of seven lung cancer patients was acquired using an amorphous silicon portal imager at ~ 7.5 frames/s. The first approach (INI) used the initial image detected, as a fixed reference, to determine the target motion for each new incoming image, and performed the best with the smallest errors. This method was also the most robust against the accumulation of position errors. Mean absolute errors of 0.16, 0.32, and 0.38 mm were obtained for the three methods, respectively. Although the errors are comparable to other tracking methods, the proposed method does not require prior knowledge of the tumor shape and does not need a tumor template or contour for tracking. Graphical abstract.