Refactor camera management to conditionally import SDK and handle mock mode; update API base URL references to localhost in documentation and code.

This commit is contained in:
salirezav
2025-08-08 13:20:31 -04:00
parent fc2da16728
commit 20907509b1
17 changed files with 404 additions and 121 deletions

View File

@@ -1,10 +1,10 @@
# Environment Configuration for Pecan Experiments Application
# USDA Vision Camera System API Configuration
# Default: http://vision:8000 (current working setup)
# Default: http://localhost:8000 (current working setup)
# For localhost setup, use: http://localhost:8000
# For remote systems, use: http://192.168.1.100:8000 (replace with actual IP)
VITE_VISION_API_URL=http://vision:8000
VITE_VISION_API_URL=http://localhost:8000
# Supabase Configuration (if needed for production)
# VITE_SUPABASE_URL=your_supabase_url

View File

@@ -40,7 +40,7 @@ The Vision System dashboard provides real-time monitoring and control of the USD
## API Integration
The dashboard connects to the Vision System API running on `http://vision:8000` and provides:
The dashboard connects to the Vision System API running on `http://localhost:8000` and provides:
### Endpoints Used
- `GET /system/status` - System overview and status
@@ -103,7 +103,7 @@ The dashboard includes comprehensive error handling:
### Common Issues
1. **"Failed to fetch vision system data"**
- Ensure the vision system API is running on vision:8000
- Ensure the vision system API is running on localhost:8000
- Check network connectivity
- Verify the vision system service is started
@@ -121,7 +121,7 @@ The dashboard includes comprehensive error handling:
The API base URL is configured in `src/lib/visionApi.ts`:
```typescript
const VISION_API_BASE_URL = 'http://vision:8000'
const VISION_API_BASE_URL = 'http://localhost:8000'
```
To change the API endpoint, modify this constant and rebuild the application.

View File

@@ -1,6 +1,6 @@
###############################################################################
# USDA Vision Camera System - Complete API Endpoints Documentation
# Base URL: http://vision:8000
# Base URL: http://localhost:8000
###############################################################################
###############################################################################
@@ -8,7 +8,7 @@
###############################################################################
### Root endpoint - API information
GET http://vision:8000/
GET http://localhost:8000/
# Response: SuccessResponse
# {
# "success": true,
@@ -20,7 +20,7 @@ GET http://vision:8000/
###
### Health check
GET http://vision:8000/health
GET http://localhost:8000/health
# Response: Simple health status
# {
# "status": "healthy",
@@ -30,7 +30,7 @@ GET http://vision:8000/health
###
### Get system status
GET http://vision:8000/system/status
GET http://localhost:8000/system/status
# Response: SystemStatusResponse
# {
# "system_started": true,
@@ -60,7 +60,7 @@ GET http://vision:8000/system/status
###############################################################################
### Get all machines status
GET http://vision:8000/machines
GET http://localhost:8000/machines
# Response: Dict[str, MachineStatusResponse]
# {
# "vibratory_conveyor": {
@@ -84,7 +84,7 @@ GET http://vision:8000/machines
###############################################################################
### Get MQTT status and statistics
GET http://vision:8000/mqtt/status
GET http://localhost:8000/mqtt/status
# Response: MQTTStatusResponse
# {
# "connected": true,
@@ -101,7 +101,7 @@ GET http://vision:8000/mqtt/status
# }
### Get recent MQTT events history
GET http://vision:8000/mqtt/events
GET http://localhost:8000/mqtt/events
# Optional query parameter: limit (default: 5, max: 50)
# Response: MQTTEventsHistoryResponse
# {
@@ -128,14 +128,14 @@ GET http://vision:8000/mqtt/events
# }
### Get recent MQTT events with custom limit
GET http://vision:8000/mqtt/events?limit=10
GET http://localhost:8000/mqtt/events?limit=10
###############################################################################
# CAMERA ENDPOINTS
###############################################################################
### Get all cameras status
GET http://vision:8000/cameras
GET http://localhost:8000/cameras
# Response: Dict[str, CameraStatusResponse]
# {
# "camera1": {
@@ -157,9 +157,9 @@ GET http://vision:8000/cameras
###
### Get specific camera status
GET http://vision:8000/cameras/camera1/status
GET http://localhost:8000/cameras/camera1/status
### Get specific camera status
GET http://vision:8000/cameras/camera2/status
GET http://localhost:8000/cameras/camera2/status
# Response: CameraStatusResponse (same as above for single camera)
###############################################################################
@@ -167,7 +167,7 @@ GET http://vision:8000/cameras/camera2/status
###############################################################################
### Start recording (with all optional parameters)
POST http://vision:8000/cameras/camera1/start-recording
POST http://localhost:8000/cameras/camera1/start-recording
Content-Type: application/json
{
@@ -193,7 +193,7 @@ Content-Type: application/json
###
### Start recording (minimal - only filename)
POST http://vision:8000/cameras/camera1/start-recording
POST http://localhost:8000/cameras/camera1/start-recording
Content-Type: application/json
{
@@ -203,7 +203,7 @@ Content-Type: application/json
###
### Start recording (only camera settings)
POST http://vision:8000/cameras/camera1/start-recording
POST http://localhost:8000/cameras/camera1/start-recording
Content-Type: application/json
{
@@ -215,7 +215,7 @@ Content-Type: application/json
###
### Start recording (empty body - all defaults)
POST http://vision:8000/cameras/camera1/start-recording
POST http://localhost:8000/cameras/camera1/start-recording
Content-Type: application/json
{}
@@ -223,9 +223,9 @@ Content-Type: application/json
###
### Stop recording
POST http://vision:8000/cameras/camera1/stop-recording
POST http://localhost:8000/cameras/camera1/stop-recording
### Stop recording
POST http://vision:8000/cameras/camera2/stop-recording
POST http://localhost:8000/cameras/camera2/stop-recording
# No request body required
# Response: StopRecordingResponse
# {
@@ -239,8 +239,8 @@ POST http://vision:8000/cameras/camera2/stop-recording
###############################################################################
### Test camera connection
POST http://vision:8000/cameras/camera1/test-connection
POST http://vision:8000/cameras/camera2/test-connection
POST http://localhost:8000/cameras/camera1/test-connection
POST http://localhost:8000/cameras/camera2/test-connection
# No request body required
# Response: CameraTestResponse
# {
@@ -253,8 +253,8 @@ POST http://vision:8000/cameras/camera2/test-connection
###
### Reconnect camera (soft recovery)
POST http://vision:8000/cameras/camera1/reconnect
POST http://vision:8000/cameras/camera2/reconnect
POST http://localhost:8000/cameras/camera1/reconnect
POST http://localhost:8000/cameras/camera2/reconnect
# No request body required
# Response: CameraRecoveryResponse
# {
@@ -268,33 +268,33 @@ POST http://vision:8000/cameras/camera2/reconnect
###
### Restart camera grab process
POST http://vision:8000/cameras/camera1/restart-grab
POST http://vision:8000/cameras/camera2/restart-grab
POST http://localhost:8000/cameras/camera1/restart-grab
POST http://localhost:8000/cameras/camera2/restart-grab
# Response: CameraRecoveryResponse (same structure as reconnect)
###
### Reset camera timestamp
POST http://vision:8000/cameras/camera1/reset-timestamp
POST http://vision:8000/cameras/camera2/reset-timestamp
POST http://localhost:8000/cameras/camera1/reset-timestamp
POST http://localhost:8000/cameras/camera2/reset-timestamp
# Response: CameraRecoveryResponse (same structure as reconnect)
###
### Full camera reset (hard recovery)
POST http://vision:8000/cameras/camera1/full-reset
POST http://localhost:8000/cameras/camera1/full-reset
### Full camera reset (hard recovery)
POST http://vision:8000/cameras/camera2/full-reset
POST http://localhost:8000/cameras/camera2/full-reset
# Response: CameraRecoveryResponse (same structure as reconnect)
###
### Reinitialize failed camera
POST http://vision:8000/cameras/camera1/reinitialize
POST http://localhost:8000/cameras/camera1/reinitialize
### Reinitialize failed camera
POST http://vision:8000/cameras/camera2/reinitialize
POST http://localhost:8000/cameras/camera2/reinitialize
# Response: CameraRecoveryResponse (same structure as reconnect)
###############################################################################
@@ -302,7 +302,7 @@ POST http://vision:8000/cameras/camera2/reinitialize
###############################################################################
### Get all recording sessions
GET http://vision:8000/recordings
GET http://localhost:8000/recordings
# Response: Dict[str, RecordingInfoResponse]
# {
# "rec_001": {
@@ -323,7 +323,7 @@ GET http://vision:8000/recordings
###############################################################################
### Get storage statistics
GET http://vision:8000/storage/stats
GET http://localhost:8000/storage/stats
# Response: StorageStatsResponse
# {
# "base_path": "/storage",
@@ -345,7 +345,7 @@ GET http://vision:8000/storage/stats
###
### Get recording files list (with filters)
POST http://vision:8000/storage/files
POST http://localhost:8000/storage/files
Content-Type: application/json
{
@@ -377,7 +377,7 @@ Content-Type: application/json
###
### Get all files (no camera filter)
POST http://vision:8000/storage/files
POST http://localhost:8000/storage/files
Content-Type: application/json
{
@@ -387,7 +387,7 @@ Content-Type: application/json
###
### Cleanup old storage files
POST http://vision:8000/storage/cleanup
POST http://localhost:8000/storage/cleanup
Content-Type: application/json
{

View File

@@ -46,10 +46,10 @@ Create a `.env` file with the following configuration:
```bash
# USDA Vision Camera System API Configuration
# Default: http://vision:8000 (Docker container)
# Default: http://localhost:8000 (Docker container)
# For local development without Docker: http://localhost:8000
# For remote systems: http://192.168.1.100:8000
VITE_VISION_API_URL=http://vision:8000
VITE_VISION_API_URL=http://localhost:8000
```
### API Endpoints Used

View File

@@ -16,8 +16,8 @@ import {
import { performanceMonitor } from '../utils/performanceMonitor';
// Configuration - Use environment variable or default to vision container
// The API is accessible at vision:8000 in the current setup
const API_BASE_URL = import.meta.env.VITE_VISION_API_URL || 'http://vision:8000';
// The API is accessible at localhost:8000 in the current setup
const API_BASE_URL = import.meta.env.VITE_VISION_API_URL || 'http://localhost:8000';
/**
* Custom error class for video API errors

View File

@@ -1,7 +1,7 @@
// Vision System API Client
// Base URL for the vision system API - Use environment variable or default to vision container
// The API is accessible at vision:8000 in the current setup
const VISION_API_BASE_URL = import.meta.env.VITE_VISION_API_URL || 'http://vision:8000'
// The API is accessible at localhost:8000 in the current setup
const VISION_API_BASE_URL = import.meta.env.VITE_VISION_API_URL || 'http://localhost:8000'
// Types based on the API documentation
export interface SystemStatus {

View File

@@ -3,7 +3,7 @@
class TestVisionApiClient {
constructor() {
this.baseUrl = 'http://vision:8000'
this.baseUrl = 'http://localhost:8000'
}
async request(endpoint) {

View File

@@ -81,7 +81,7 @@
<script src="test-api-fix.js"></script>
<script>
const API_BASE = 'http://vision:8000'; // Change to your vision API URL if different
const API_BASE = 'http://localhost:8000'; // Change to your vision API URL if different
async function testCameraList() {
const resultsDiv = document.getElementById('test-results');

View File

@@ -106,7 +106,7 @@
</div>
<script>
const API_BASE = 'http://vision:8000';
const API_BASE = 'http://localhost:8000';
let cameras = {};
// Load cameras on page load