Calculate rope’s length

Given a image which has a rope inside.
How to calculate the rope’s length from scala?
Thanks