vision-agent 0.2.42__tar.gz → 0.2.43__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vision_agent-0.2.42 → vision_agent-0.2.43}/PKG-INFO +1 -1
- {vision_agent-0.2.42 → vision_agent-0.2.43}/pyproject.toml +1 -1
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/tools/tools.py +34 -5
- {vision_agent-0.2.42 → vision_agent-0.2.43}/LICENSE +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/README.md +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/__init__.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/__init__.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/agent.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/agent_coder.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/agent_coder_prompts.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/data_interpreter.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/data_interpreter_prompts.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/easytool.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/easytool_prompts.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/easytool_v2.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/easytool_v2_prompts.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/reflexion.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/reflexion_prompts.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/vision_agent.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/agent/vision_agent_prompts.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/fonts/__init__.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/fonts/default_font_ch_en.ttf +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/llm/__init__.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/llm/llm.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/lmm/__init__.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/lmm/lmm.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/tools/__init__.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/tools/easytool_tools.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/tools/prompts.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/tools/tool_utils.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/utils/__init__.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/utils/execute.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/utils/image_utils.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/utils/sim.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/utils/type_defs.py +0 -0
- {vision_agent-0.2.42 → vision_agent-0.2.43}/vision_agent/utils/video.py +0 -0
@@ -7,11 +7,11 @@ from importlib import resources
|
|
7
7
|
from pathlib import Path
|
8
8
|
from typing import Any, Callable, Dict, List, Tuple, Union, cast
|
9
9
|
|
10
|
+
import cv2
|
10
11
|
import numpy as np
|
11
12
|
import pandas as pd
|
12
13
|
import requests
|
13
14
|
from PIL import Image, ImageDraw, ImageFont
|
14
|
-
from scipy.spatial import distance # type: ignore
|
15
15
|
|
16
16
|
from vision_agent.tools.tool_utils import _send_inference_request
|
17
17
|
from vision_agent.utils import extract_frames_from_video
|
@@ -421,10 +421,39 @@ def closest_mask_distance(mask1: np.ndarray, mask2: np.ndarray) -> float:
|
|
421
421
|
|
422
422
|
mask1 = np.clip(mask1, 0, 1)
|
423
423
|
mask2 = np.clip(mask2, 0, 1)
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
424
|
+
contours1, _ = cv2.findContours(mask1, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
425
|
+
contours2, _ = cv2.findContours(mask2, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
426
|
+
largest_contour1 = max(contours1, key=cv2.contourArea)
|
427
|
+
largest_contour2 = max(contours2, key=cv2.contourArea)
|
428
|
+
polygon1 = cv2.approxPolyDP(largest_contour1, 1.0, True)
|
429
|
+
polygon2 = cv2.approxPolyDP(largest_contour2, 1.0, True)
|
430
|
+
min_distance = np.inf
|
431
|
+
|
432
|
+
small_polygon, larger_contour = (
|
433
|
+
(polygon1, largest_contour2)
|
434
|
+
if len(largest_contour1) < len(largest_contour2)
|
435
|
+
else (polygon2, largest_contour1)
|
436
|
+
)
|
437
|
+
|
438
|
+
# For each point in the first polygon
|
439
|
+
for point in small_polygon:
|
440
|
+
# Calculate the distance to the second polygon, -1 is to invert result as point inside the polygon is positive
|
441
|
+
|
442
|
+
distance = (
|
443
|
+
cv2.pointPolygonTest(
|
444
|
+
larger_contour, (point[0, 0].item(), point[0, 1].item()), True
|
445
|
+
)
|
446
|
+
* -1
|
447
|
+
)
|
448
|
+
|
449
|
+
# If the distance is negative, the point is inside the polygon, so the distance is 0
|
450
|
+
if distance < 0:
|
451
|
+
continue
|
452
|
+
else:
|
453
|
+
# Update the minimum distance if the point is outside the polygon
|
454
|
+
min_distance = min(min_distance, distance)
|
455
|
+
|
456
|
+
return min_distance if min_distance != np.inf else 0.0
|
428
457
|
|
429
458
|
|
430
459
|
def closest_box_distance(
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|