In semiconductors and insulators, the presence of an electron or hole breaks the symmetry of the atomic lattice due to electron-phonon coupling. The subsequent self-localization is driven either by dielectric or atomic polarization, leading to the formation of a large or small polaron, respectively. If bound to a defect, the large (small) polaron creates a shallow (deep) defect level inside the band gap. For materials applications, it is desirable to have a direct description of the atomic and electronic structure of polarons in a first principles electronic structure framework, in addition to models (Fröhlich, Holstein) and perturbative approaches. Since, due to the symmetry breaking, large supercells are needed, a density functional theory (DFT) based approach is preferable over post-DFT approaches, but this requires overcoming the so-called delocalization error of DFT. One such approach utilizes on-site potentials akin to the DFT+U formalism, where the potential strength is defined by the quasiparticle energy condition (aka Koopmans correction). This presentation reviews this approach and its application to numerous materials, including wide-gap semiconductors (ZnO, GaN) and transition metal oxides (TiO2, Fe2O3, MnO).