| """ |
| Football Field Detection Model - Roboflow Inference Wrapper |
| """ |
|
|
| from inference import get_model |
| import os |
|
|
| class FootballFieldDetector: |
| """Wrapper for Roboflow football field keypoint detection model""" |
| |
| def __init__(self, api_key: str): |
| """ |
| Initialize the field detection model |
| |
| Args: |
| api_key: Your Roboflow API key |
| """ |
| self.model_id = "football-field-detection-f07vi/14" |
| self.model = get_model(model_id=self.model_id, api_key=api_key) |
| |
| def predict(self, image, confidence: float = 0.3): |
| """ |
| Detect field keypoints |
| |
| Args: |
| image: Image as numpy array or path to image |
| confidence: Confidence threshold (0.0-1.0) |
| |
| Returns: |
| Keypoint detection results |
| """ |
| result = self.model.infer(image, confidence=confidence)[0] |
| return result |
|
|
| |
| if __name__ == "__main__": |
| import os |
| |
| |
| api_key = os.getenv("ROBOFLOW_API_KEY") |
| |
| |
| detector = FootballFieldDetector(api_key=api_key) |
| |
| |
| results = detector.predict("path/to/image.jpg", confidence=0.3) |
| print(f"Detected keypoints: {results}") |
|
|