The classical SIR epidemic model is generalized to incorporate a detection process of infectives in the course of time. Our purpose is to determine the exact distribution of the population state at the first detection instant and the following ones. An extension is also discussed that allows the parameters to change with the number of detected cases. The followed approach relies on simple martingale arguments and uses a special family of Abel–Gontcharoff polynomials.