- Changed camera1 references to camera2 in API endpoint documentation for start and stop recording. - Added debug and verbose logging options in the USDA Vision System to improve debugging capabilities. - Updated TopNavbar component for improved user experience with cursor pointer styling.
213 lines
5.7 KiB
Markdown
Executable File
213 lines
5.7 KiB
Markdown
Executable File
# 🎥 Camera Route Implementation Guide
|
||
|
||
This document explains the implementation of the new public camera live view routes (`/camera#/live`) that don't require authentication.
|
||
|
||
## 🚀 What Was Implemented
|
||
|
||
### 1. **LiveCameraView Component** (`src/components/LiveCameraView.tsx`)
|
||
- Displays live camera feed without authentication requirements
|
||
- Handles streaming start/stop automatically
|
||
- Provides error handling and loading states
|
||
- Full-screen live view with camera label and status indicator
|
||
|
||
### 2. **CameraRoute Component** (`src/components/CameraRoute.tsx`)
|
||
- Validates camera route parameters
|
||
- Ensures only valid camera numbers (camera1, camera2, etc.) are accepted
|
||
- Renders the LiveCameraView for valid routes
|
||
|
||
### 3. **Updated App.tsx**
|
||
- Added route pattern matching for `/camera#/live`
|
||
- Integrated camera routes into existing authentication flow
|
||
- Maintains backward compatibility with existing functionality
|
||
|
||
### 4. **Test Page** (`public/camera-test.html`)
|
||
- Simple HTML page to test camera routes
|
||
- Provides links to test different camera numbers
|
||
- Explains expected behavior
|
||
|
||
## 📋 Required Dependencies
|
||
|
||
The following packages need to be installed to complete the implementation:
|
||
|
||
```bash
|
||
# Install React Router
|
||
npm install react-router-dom
|
||
|
||
# Install TypeScript types
|
||
npm install --save-dev @types/react-router-dom
|
||
```
|
||
|
||
**Note:** Due to permission issues, these packages couldn't be installed automatically. You'll need to resolve the permissions or install them manually.
|
||
|
||
## 🔧 How to Complete the Setup
|
||
|
||
### Option 1: Fix Permissions and Install
|
||
```bash
|
||
# Fix node_modules permissions
|
||
sudo chown -R $USER:$USER node_modules
|
||
sudo chmod -R 755 node_modules
|
||
|
||
# Install dependencies
|
||
npm install
|
||
```
|
||
|
||
### Option 2: Manual Installation
|
||
```bash
|
||
# Remove problematic node_modules
|
||
rm -rf node_modules
|
||
|
||
# Reinstall everything
|
||
npm install
|
||
```
|
||
|
||
### Option 3: Use Yarn Instead
|
||
```bash
|
||
# Install yarn if not available
|
||
npm install -g yarn
|
||
|
||
# Install dependencies with yarn
|
||
yarn install
|
||
```
|
||
|
||
## 🧪 Testing the Implementation
|
||
|
||
### 1. **Start the Development Server**
|
||
```bash
|
||
npm run dev
|
||
```
|
||
|
||
### 2. **Test Camera Routes**
|
||
Open these URLs in your browser:
|
||
- `http://localhost:5173/camera1/live` - Live view of camera1
|
||
- `http://localhost:5173/camera2/live` - Live view of camera2
|
||
- `http://localhost:5173/camera3/live` - Live view of camera3
|
||
|
||
### 3. **Use the Test Page**
|
||
Open `http://localhost:5173/camera-test.html` to access the test interface.
|
||
|
||
### 4. **Expected Behavior**
|
||
- ✅ **Valid routes** should show live camera feed
|
||
- ❌ **Invalid routes** should show error message
|
||
- 🔒 **Protected routes** should redirect to login
|
||
|
||
## 🏗️ Architecture Details
|
||
|
||
### Route Pattern
|
||
```
|
||
/camera{number}/live
|
||
```
|
||
- `{number}` must be a positive integer
|
||
- Examples: `/camera1/live`, `/camera2/live`, `/camera10/live`
|
||
- Invalid: `/camera/live`, `/camera0/live`, `/camera-1/live`
|
||
|
||
### Component Flow
|
||
```
|
||
App.tsx → Route Detection → CameraRoute → LiveCameraView
|
||
```
|
||
|
||
### API Integration
|
||
The LiveCameraView component integrates with existing camera API endpoints:
|
||
- `POST /cameras/{camera_name}/start-stream` - Start streaming
|
||
- `GET /cameras/{camera_name}/stream` - Get MJPEG stream
|
||
- `POST /cameras/{camera_name}/stop-stream` - Stop streaming
|
||
|
||
## 🎯 Key Features
|
||
|
||
### ✅ **Public Access**
|
||
- No authentication required
|
||
- Anyone can view live camera feeds
|
||
- Perfect for monitoring displays
|
||
|
||
### ✅ **Non-Blocking Streaming**
|
||
- Uses existing CameraStreamer infrastructure
|
||
- Separate camera connections for streaming vs. recording
|
||
- Doesn't interfere with recording operations
|
||
|
||
### ✅ **Real-time Video**
|
||
- MJPEG format for low latency
|
||
- Automatic stream management
|
||
- Error handling and retry functionality
|
||
|
||
### ✅ **Responsive Design**
|
||
- Full-screen live view
|
||
- Camera identification labels
|
||
- Live status indicators
|
||
|
||
## 🔍 Troubleshooting
|
||
|
||
### Common Issues
|
||
|
||
#### 1. **Permission Errors During Installation**
|
||
```bash
|
||
# Fix ownership
|
||
sudo chown -R $USER:$USER .
|
||
|
||
# Fix permissions
|
||
sudo chmod -R 755 .
|
||
```
|
||
|
||
#### 2. **Camera Stream Not Loading**
|
||
- Check if camera API is running (`http://localhost:8000`)
|
||
- Verify camera configuration in `config.compose.json`
|
||
- Check browser console for errors
|
||
|
||
#### 3. **Route Not Working**
|
||
- Ensure React app is running
|
||
- Check browser console for routing errors
|
||
- Verify component imports are correct
|
||
|
||
#### 4. **TypeScript Errors**
|
||
- Install missing type definitions
|
||
- Check import paths
|
||
- Verify component interfaces
|
||
|
||
### Debug Steps
|
||
1. Check browser console for errors
|
||
2. Verify API endpoints are accessible
|
||
3. Test camera streaming directly via API
|
||
4. Check component rendering in React DevTools
|
||
|
||
## 🚀 Next Steps
|
||
|
||
### Immediate
|
||
1. Install required dependencies
|
||
2. Test basic functionality
|
||
3. Verify camera streaming works
|
||
|
||
### Future Enhancements
|
||
1. **Add React Router** for better routing
|
||
2. **Implement URL-based navigation** between cameras
|
||
3. **Add camera selection interface**
|
||
4. **Implement stream quality controls**
|
||
5. **Add recording controls** (if needed)
|
||
|
||
### Production Considerations
|
||
1. **Security**: Consider adding rate limiting
|
||
2. **Performance**: Optimize for multiple concurrent viewers
|
||
3. **Monitoring**: Add analytics and usage tracking
|
||
4. **Access Control**: Implement optional authentication if needed
|
||
|
||
## 📚 Related Documentation
|
||
|
||
- [Camera API Documentation](../camera-management-api/docs/API_DOCUMENTATION.md)
|
||
- [Streaming Guide](../camera-management-api/docs/guides/STREAMING_GUIDE.md)
|
||
- [Vision System README](VISION_SYSTEM_README.md)
|
||
|
||
## 🤝 Support
|
||
|
||
If you encounter issues:
|
||
1. Check the troubleshooting section above
|
||
2. Review browser console for error messages
|
||
3. Verify camera API is running and accessible
|
||
4. Test API endpoints directly with curl or Postman
|
||
|
||
---
|
||
|
||
**Implementation Status**: ✅ Components Created | ⚠️ Dependencies Pending | <20><> Ready for Testing
|
||
|
||
|
||
|
||
|
||
|
||
|