arcLength function (without OpenCv)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



arcLength function (without OpenCv)



I'm trying to avoid CV2 for work porpuses. I'm using skimage.measure.find_contours. But I couldn't find the CV2 arcLength function equivalent anywhere.



How could I calculate a contour perimeter or a curve length without that CV2 function.



It's my code, just in case:


from skimage import measure

hresh = get_threshold(image, 127)
contours = measure.find_contours(thresh, 0.8)

for contour in contours:
approx = aproximate_curve(contour, 0.1 * my_unknown_arc_length_function(contour)) # I have no idea about arc_length_function implementation



Thanks in advance and sorry about my English.




1 Answer
1



In OpenCV the arcLength() function is used to find the perimeter of a contour/shape object. It can be found here


arcLength()



In scikit image the same function can be found in the measure module named perimeter.


measure


perimeter



Usage:


#--- importing the module ---
from skimage.measure import perimeter

print('Perimeter : '.format(perimeter(image)))



Make sure the image is of float data type. The pixels containing the contour/shape object must be of value 1.0 while the other pixels are of 0.0.


float


1.0


0.0



A lot is discussed about this function on this link





Thank you! But, how could apply that function to a single contour instead of all contours in image
– Genarito
Aug 11 at 22:45






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard