The OPERA experiment, designed to perform the first observation of $\nu_\mu \rightarrow \nu_\tau$ oscillations in appearance mode through the detection of the $\tau$ leptons produced in $\nu_\tau$ charged current interactions, has collected data from 2008 to 2012. In the present paper, the procedure developed to detect $\tau$ particle decays, occurring over distances of the order of 1 mm from the neutrino interaction point, is described in detail. The results of its application to the search for charmed hadrons are then presented as a validation of the methods for $\nu_\tau$ appearance detection.