Training method and detection method for object recognition