We consider a natural extension of the Petitot–Citti–Sarti model of the primary visual cortex. In the extended model, the curvature of contours is taken into account. The occluded contours are completed via sub-Riemannian geodesics in the four-dimensional space M of positions, orientations, and curvatures. Here, M=R2×SO(2)×R models the configuration space of neurons of the visual cortex. We study the problem of sub-Riemannian geodesics on M via methods of geometric control theory. We prove complete controllability of the system and the existence of optimal controls. By application of the Pontryagin maximum principle, we derive a Hamiltonian system that describes the geodesics. We obtain the explicit parametrization of abnormal extremals. In the normal case, we provide three functionally independent first integrals. Numerical simulations indicate the existence of one more first integral that results in Liouville integrability of the system.