A real-time betting platform where users bet on how close a ball will land to a target, with live odds calculation and automated credit payouts. No wallet required!
- ๐ฏ Real-time Video Analysis: Tracks ball and target positions using computer vision
- ๐ฐ Dynamic Betting System: Live odds calculation based on bet distribution
- ๐ Web Interface: Beautiful, real-time betting interface with WebSocket updates
- ๐ธ Automated Payouts: Instant credit payouts - no blockchain needed!
- ๐ Live Statistics: Real-time pool size, odds, and leaderboard
- ๐ฎ Zero Barrier Entry: Just pick a username and start betting (free credits included!)
- Video Analysis: Camera detects colored target zones and tracks ball position
- Distance Calculation: Measures pixel distance from ball to target center (green zone)
- Betting: Users place bets predicting the final distance (just need a username!)
- Odds Calculation: Dynamic odds based on bet distribution and accuracy ranges
- Winner Selection: Payouts distributed proportionally based on prediction accuracy
- Automated Payouts: Winners receive credits automatically (no wallet needed!)
- Python 3.8+
- Webcam
pip install -r requirements.txtOr manually:
pip install opencv-python numpy flask flask-cors flask-socketioMake sure your camera is connected. Test with:
python video_analysis.pyPress 'q' to quit. Adjust color ranges if needed for your lighting.
python main.pyThen open http://localhost:5000 in your browser.
python main.pyThen open http://localhost:5000 in your browser.
# Use different camera (0 for built-in, 1 for external)
python main.py --camera 0
# Use different port
python main.py --port 8080
# Run without video window (headless)
python main.py --no-video- Start the application
- Open the web interface
- Click "Start Game" to begin a betting round
- Wait for players to place bets
- Click "End Game" when the ball lands
- System automatically calculates winners and can process payouts
- Open the web interface (http://localhost:5000)
- Enter any username you want
- Choose bet amount in credits (new users automatically get 10 free credits!)
- Predict the distance (in pixels)
- Click "Place Bet"
- Watch live odds and distance updates
- Wait for game to end and see if you won!
UTRA2026/
โโโ main.py # Main application entry point
โโโ video_analysis.py # Computer vision for ball/target tracking
โโโ betting_system.py # Betting logic and odds calculation
โโโ solana.py # Payment/credit tracking system (renamed but no blockchain)
โโโ web_server.py # Flask web server with WebSocket
โโโ templates/
โ โโโ index.html # Web interface
โโโ requirements.txt # Python dependencies
โโโ README.md
The platform uses dynamic odds based on distance ranges:
| Range | Distance | Base Multiplier |
|---|---|---|
| Bullseye | 0-50px | 5.0x |
| Very Close | 51-100px | 3.0x |
| Close | 101-200px | 2.0x |
| Medium | 201-300px | 1.5x |
| Far | 301-500px | 1.2x |
| Very Far | 501+px | 1.0x |
Actual odds adjust dynamically based on:
- Total pool size
- Distribution of bets across ranges
- 5% house edge
Note: All amounts are in credits, not real money. Perfect for demos and testing!
Winners are determined by prediction accuracy:
- Calculate error:
|predicted_distance - actual_distance| - Calculate accuracy:
1 / (1 + error) - Distribute pool proportionally to accuracy
- Bonus: Very close predictions (< 50px error) guaranteed minimum 10% profit
- Try different camera index:
python main.py --camera 0 - Check camera permissions in System Preferences
- Test with:
python video_analysis.py
- Adjust HSV color ranges in
video_analysis.py - Ensure good lighting conditions
- Use solid colored objects (green target, black ball)
- Verify private key format (should be ~88 characters, base58)
- Check wallet has sufficient balance
- Ensure using devnet RPC:
https://api.devnet.solana.com
- Check if port 5000 is already in use
- Try different port:
python main.py --port 8080 - Check firewall settings
python betting_system.pypython video_analysis.pypython solana.pyNote: This file has been repurposed as a simple credit tracking system - no actual blockchain integration.
- No real money involved - all credits are for demo/testing purposes
- User data stored in memory only (cleared on restart)
- Optional: Save state to JSON file for persistence
- Perfect for hackathons, demos, and prototypes
This version uses a simple credit system instead of Solana because:
- โ Zero barrier to entry - no wallet setup required
- โ Instant onboarding - pick a username and start playing
- โ Perfect for demos - no funding or transaction delays
- โ Easy testing - unlimited free credits for development
- โ Hackathon friendly - focus on the core game mechanics
Want to add real payments later? The architecture is modular - just swap the PaymentManager with a real payment provider!
- User authentication system
- Historical game statistics
- Multiple game modes
- Mobile app integration
- Tournament system
- Live streaming integration
- Advanced analytics dashboard
MIT License - Feel free to use for your hackathon project!
Built for UTRA 2026 Hackathon