# what is the most effective way to measure middle width of trapezoid? C++

I need to measure the middle width of trapezoid using opencv c++ as below.

I have an good suggestion from stackoverflow (https://stackoverflow.com/questions/5...) but it is only for Python. I've learnt that it is not easy to convert the followings python codes to c++ especially the following bits.

```
#Calclate the higest and lowest point
top = tuple(cnt[cnt[:, :, 1].argmin()][0])
bottom = tuple(cnt[cnt[:, :, 1].argmax()][0])
```

Therefore I am looking for another way to measure the width. Is there any good suggestion?

could you give more c++ code?

@jsxyhelu, thanks for your reply. the code is in the following link: https://stackoverflow.com/questions/5...