Using positron emission markers for the localization of a robotic capsule endoscope is promising because it does not require onboard space or built-in battery for operation. Further, its compatibility with magnetic actuation is another significant advantage compared with conventional magnetic localization methods reported in the literature. In this paper, we propose a new tracking algorithm based on rigid-body transformation and gamma rays emitted from three positron emission markers onboard to localize an endoscopic capsule operating within the gastrointestinal tract of the human body. Different from traditional rigid-body transformation based on datasets of 3-D points, our method estimates the transformation parameters (e.g., translation vector and rotation angle) from several groups of 3-D lines in order to determine the locations of the markers emitting the gamma rays. Validated by both simulation data using a voxelized phantom in the Geant4 Application for Emission Tomography toolkit and the experimental data collected from a positron emission tomography scanner, the new localization method shows a significant improvement in the tracking accuracy (an average position error of 0.4 mm and orientation error of 1.9 & #x00B0;) and the failure rate (18/9600 localization runs), compared to the localization results reported in the literature.