text stringlengths 0 93.6k |
|---|
return self.x2 - self.x1 |
def height(self): |
return self.y2 - self.y1 |
def overlap(self, box): |
return not (self.x2 < box.x1 or self.x1 > box.x2 or self.y2 < box.y1 or self.y1 > box.y2) |
def distance(self, box): |
from math import sqrt |
return sqrt((self.center()[0] - box.center()[0]) ** 2 + (self.center()[1] - box.center()[1]) ** 2) |
def overlap_percentage(self, box): |
if not self.overlap(box): |
return 0 |
intersection_area = max(0, min(self.x2, box.x2) - max(self.x1, box.x1)) * max(0, min(self.y2, box.y2) - max(self.y1, box.y1)) |
return intersection_area / max(self.area(), 1) |
def contains_point(self, point): |
x, y = point |
return x >= self.x1 and x <= self.x2 and y >= self.y1 and y <= self.y2 |
def iou(self, box): |
if not self.overlap(box): |
return 0 |
intersection_area = max(0, min(self.x2, box.x2) - max(self.x1, box.x1)) * max(0, min(self.y2, box.y2) - max(self.y1, box.y1)) |
union_area = self.area() + box.area() - intersection_area |
return intersection_area / union_area |
class Frame(BaseModel): |
number: int = Field(description="Frame number") |
width: int = Field(description="Width of the frame") |
height: int = Field(description="Height of the frame") |
boxes: List[Box] = Field(description="List of bounding boxes in the frame") |
def boxes_by_class(self, class_name): |
return [box for box in self.boxes if box.name == class_name] |
def area(self): |
return self.width * self.height |
def supervision_detection(self): |
import supervision as sv |
import numpy as np |
box_list = [[box.x1, box.y1, box.x2, box.y2] for box in self.boxes] |
confidence_list = [box.confidence for box in self.boxes] |
class_id_list = [box.class_id for box in self.boxes] |
if len(box_list) == 0: |
box_list = np.empty((0, 4)) |
confidence_list = np.empty(0) |
class_id_list = np.empty(0) |
return sv.Detections( |
xyxy=np.array(box_list), |
confidence=np.array(confidence_list), |
class_id=np.array(class_id_list), |
) |
# <FILESEP> |
import requests |
from lxml import html |
import os |
import configparser |
config = configparser.ConfigParser() |
config.sections() |
config.read('config.ini') |
global email |
global password |
global API_key |
email = config['HikingProject.com']['email'] |
password = config['HikingProject.com']['password'] |
API_key = config['HikingProject.com']['API_key'] |
class HikingProject(): |
def __init__(self, lat=40.0274, lon=-105.2519, maxdistance=50): |
self.session_requests = None |
self.trails = None |
self.get_trail_list(key = API_key, lat=lat, lon=lon, maxdistance=maxdistance) |
self.login(email, password) |
@classmethod |
def get_gps_from_location(cls, location): |
pass |
""" |
Use google API or something else to get latitude and longitude from |
a place name |
""" |
def get_trail_list(self, key, lat, lon, maxdistance): |
payload = { "key":key, |
"lat":lat, |
"lon":lon, |
"maxResults":500, |
"maxDistance":maxdistance} |
r = requests.get('https://www.hikingproject.com/data/get-trails', params = payload) |
self.trails = r.json()["trails"] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.