A modern, web-based tool for camera calibration built with Next.js and OpenCV.
- Web-Based Interface: Clean, responsive UI built with Next.js and Tailwind CSS.
- Robust Detection: Utilizes a Python backend (FastAPI + OpenCV) for reliable chessboard detection and calibration.
- Real-time Feedback: Visualizes detected corners and reprojection errors.
- Frontend Deployment: Next.js (React) and Tailwind CSS on Vercel.
- Backend Deployment: Python, FastAPI, and OpenCV on Hugging Face Spaces.
- Fallbacks: Robust error handling with fallback to specific backend endpoints.
This project uses a split architecture to combine the interactivity of a modern web app with the computational power of Python's OpenCV libraries.
- Frontend (
/app): Handles image upload, UI interaction, and result visualization. - Backend (
/hf_space): A FastAPI service running inside a Docker container. It processes images, detects chessboard corners, and performs the camera calibration math.
- Node.js (v18 or higher)
- Python (v3.9 or higher) - for local backend development
# Install dependencies
npm install
# Start the development server
npm run devThe frontend will be available at http://localhost:3000.
To run the backend locally:
cd hf_space
# Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
# Install dependencies
pip install -r requirements.txt
# Run the server
uvicorn app:app --reload --port 7860Create a .env.local file in the root of the project to tell the frontend where the backend is running:
# For local development
NEXT_PUBLIC_BACKEND_API_URL=http://localhost:7860Deploy the Next.js app with Vercel Git integration, and use GitHub Actions only for CI checks.
- Connect this repository to a Vercel project.
- In Vercel project settings, add these environment variables:
NEXT_PUBLIC_BACKEND_API_URL=https://your-space-name.hf.spaceNEXT_PUBLIC_SITE_URL=https://your-production-domain
- Vercel will automatically deploy pushes to
mainand create preview deployments for pull requests. - GitHub Actions runs
.github/workflows/deploy-vercel.ymlas a CI workflow to verify the project still builds. - No Vercel deployment secrets are required in GitHub unless you later choose to move deployment back into Actions.
The backend is designed to run on Hugging Face Spaces (Docker SDK).
- Create a new Space on Hugging Face.
- Select Docker as the SDK.
- Push the contents of the
hf_space/directory to the Space (or connect it to this repo).- Note: You can use the included
deploy_to_hf.shscript if you have the Hugging Face CLI configured.
- Note: You can use the included
This project is licensed under the MIT License - see the LICENSE file for details.
