CubeSats have become a meaningful option for deep-space exploration, but their autonomy must be increased to maximize the science return while limiting the complexity in operations. We present here a solution for an autonomous orbit determination in the context of a CubeSat cruising in deep space. The study case is a journey from Earth to Mars. An optical sensor at CubeSat standard is considered. The image processing is added to extract the direction of distant celestial bodies with 0.2 " accuracy: it consists of a Multiple Cross-Correlation (MCC) algorithm that uses bright stars in the background of the images. Then, an Unscented Kalman Filter (UKF) is built to perform an asynchronous triangulation from the successive directions of the celestial bodies. The UKF meets the expected performance in contexts where linear approximations are not possible. The orbit reconstruction reaches a 3 σ accuracy of 30 km in the middle of the Earth-Mars cruise. Additionally, the Central Processing Unit (CPU) cost of the filter is assessed at less than 1 second per iteration with a typical CubeSat hardware. It is ready for further improvements in terms of new observables associated with data fusion, quicker convergence and attitude control savings.