Since tangents from a vertex to an inscribed circle are equal in length, we have AE = AF, BE = BD, and CD = CF. From the image, we are given BE = 5, AE = x-1, BD = 2x-1, and CF = x+1. Therefore, AE = AF = x-1, BE = BD = 5, and CF = CD = x+1. Equating the two expressions for BD, we get 5 = 2x-1, which gives 2x = 6, so x = 3. The side lengths of the triangle are AB = AE + EB = (x-1) + 5 = (3-1) + 5 = 2 + 5 = 7, BC = BD + DC = 5 + (x+1) = 5 + (3+1) = 5 + 4 = 9, and AC = AF + FC = (x-1) + (x+1) = (3-1) + (3+1) = 2 + 4 = 6. The perimeter of triangle ABC is AB + BC + AC = 7 + 9 + 6 = 22.