I've a simple idea, may this can help you:)
- Do some morphology to eliminate the noise.
- Straighten the line, correct its angle to make it horizontal: use radon_transformation or houghline to get the rotating angle then warpaffine it.
- Finally get the number of white pixels on one column which is just the width (or you can get the averge of thoses on the whole line or part of it to make the result more stable).