Teaching contact-rich tasks from visual demonstrations by constraint extraction