Loop-and-Edges-Detector is a fast and simple python library to detect loops, outer boundary and edges in binary images. Also available on PyPi.
import DetectLoopsEdges as detect
import cv2
Im = cv2.imread(your_filename)
Loops, Edges, Boundary = detect.DetectLoopsEdges(Im)
https://pypi.org/project/pyedgeloop/
Usage: pip install pyedgeloop
Example:
import pyedgeloop as detect
import cv2
Im = cv2.imread(your_filename)
Loops, Edges, Boundary = detect.DetectLoopsEdges(Im)
Aditya Dutt