import
cv2
import
numpy as np
img
=
cv2.imread(r
"C:\Users\siddh\Downloads\star2.png"
)
grayScaleImg
=
cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret, thresh
=
cv2.threshold(grayScaleImg,
40
,
255
,
0
)
contours, hierarchy
=
cv2.findContours(thresh,
cv2.RETR_TREE,
cv2.CHAIN_APPROX_SIMPLE)
print
(f
"{len(contours)} objects detected"
)
count
=
contours[
0
]
Solidity
=
find_solidity(count)
Solidity
=
round
(Solidity,
2
)
equi_diameter
=
find_equi_diameter(count)
equi_diameter
=
round
(equi_diameter,
2
)
print
(
"Solidity - "
, Solidity)
print
(
"Equivalent Diameter - "
, equi_diameter)