A method for recovering the star formation history of resolved stellar populations