Implement the mastering opencv book code