Getting closer to get multiple coordinates
Browse files- understand.py +20 -0
understand.py
CHANGED
|
@@ -211,4 +211,24 @@ array([[False, False, False, ..., False, False, False],
|
|
| 211 |
538
|
| 212 |
>>> min(np.where(mask==True)[1])
|
| 213 |
399
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
"""
|
|
|
|
| 211 |
538
|
| 212 |
>>> min(np.where(mask==True)[1])
|
| 213 |
399
|
| 214 |
+
"""
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
"""
|
| 218 |
+
import cv2 as cv
|
| 219 |
+
contours, hierarchy = cv.findContours(visual_mask, cv.RETR_LIST, cv.CHAIN_APPROX_SIMPLE)
|
| 220 |
+
shrunk = contours[0][:, 0, :]
|
| 221 |
+
|
| 222 |
+
>>> shrunk[0, :]
|
| 223 |
+
array([1907, 887], dtype=int32)
|
| 224 |
+
>>> shrunk[:, 0]
|
| 225 |
+
array([1907, 1907, 1908, 1908, 1908], dtype=int32)
|
| 226 |
+
>>> shrunk[:, 1]
|
| 227 |
+
array([887, 888, 889, 890, 888], dtype=int32)
|
| 228 |
+
>>> shrunk
|
| 229 |
+
array([[1907, 887],
|
| 230 |
+
[1907, 888],
|
| 231 |
+
[1908, 889],
|
| 232 |
+
[1908, 890],
|
| 233 |
+
[1908, 888]], dtype=int32)
|
| 234 |
"""
|