291 lines
6.9 KiB
Bash
291 lines
6.9 KiB
Bash
#!/bin/bash
|
|
|
|
# NowYouSeeMe Build Script
|
|
# Builds the complete holodeck environment project
|
|
|
|
set -e # Exit on any error
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Configuration
|
|
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
BUILD_DIR="$PROJECT_ROOT/build"
|
|
INSTALL_DIR="$PROJECT_ROOT/install"
|
|
PYTHON_VENV="$PROJECT_ROOT/venv"
|
|
|
|
# Default build type
|
|
BUILD_TYPE="Release"
|
|
CLEAN_BUILD=false
|
|
BUILD_TESTS=false
|
|
INSTALL_DEPENDENCIES=false
|
|
|
|
# Parse command line arguments
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--debug)
|
|
BUILD_TYPE="Debug"
|
|
shift
|
|
;;
|
|
--clean)
|
|
CLEAN_BUILD=true
|
|
shift
|
|
;;
|
|
--tests)
|
|
BUILD_TESTS=true
|
|
shift
|
|
;;
|
|
--deps)
|
|
INSTALL_DEPENDENCIES=true
|
|
shift
|
|
;;
|
|
--help)
|
|
echo "Usage: $0 [options]"
|
|
echo "Options:"
|
|
echo " --debug Build in debug mode"
|
|
echo " --clean Clean build directory"
|
|
echo " --tests Build and run tests"
|
|
echo " --deps Install dependencies"
|
|
echo " --help Show this help message"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Unknown option: $1"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Print header
|
|
echo -e "${BLUE}================================${NC}"
|
|
echo -e "${BLUE} NowYouSeeMe Build Script${NC}"
|
|
echo -e "${BLUE}================================${NC}"
|
|
echo "Project root: $PROJECT_ROOT"
|
|
echo "Build type: $BUILD_TYPE"
|
|
echo ""
|
|
|
|
# Function to print colored output
|
|
print_status() {
|
|
echo -e "${GREEN}[INFO]${NC} $1"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
# Check system requirements
|
|
check_requirements() {
|
|
print_status "Checking system requirements..."
|
|
|
|
# Check for required tools
|
|
local missing_tools=()
|
|
|
|
for tool in python3 pip3 cmake make gcc g++; do
|
|
if ! command -v $tool &> /dev/null; then
|
|
missing_tools+=($tool)
|
|
fi
|
|
done
|
|
|
|
if [ ${#missing_tools[@]} -ne 0 ]; then
|
|
print_error "Missing required tools: ${missing_tools[*]}"
|
|
exit 1
|
|
fi
|
|
|
|
# Check Python version
|
|
python_version=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
|
|
required_version="3.8"
|
|
|
|
if [ "$(printf '%s\n' "$required_version" "$python_version" | sort -V | head -n1)" != "$required_version" ]; then
|
|
print_error "Python $required_version or higher required, found $python_version"
|
|
exit 1
|
|
fi
|
|
|
|
print_status "System requirements satisfied"
|
|
}
|
|
|
|
# Install Python dependencies
|
|
install_python_deps() {
|
|
print_status "Installing Python dependencies..."
|
|
|
|
# Create virtual environment if it doesn't exist
|
|
if [ ! -d "$PYTHON_VENV" ]; then
|
|
print_status "Creating Python virtual environment..."
|
|
python3 -m venv "$PYTHON_VENV"
|
|
fi
|
|
|
|
# Activate virtual environment
|
|
source "$PYTHON_VENV/bin/activate"
|
|
|
|
# Upgrade pip
|
|
pip install --upgrade pip
|
|
|
|
# Install dependencies from requirements.txt
|
|
if [ -f "$PROJECT_ROOT/requirements.txt" ]; then
|
|
pip install -r "$PROJECT_ROOT/requirements.txt"
|
|
else
|
|
# Install core dependencies
|
|
pip install numpy opencv-python scipy matplotlib
|
|
pip install torch torchvision # For neural components
|
|
pip install open3d # For 3D reconstruction
|
|
pip install structlog # For structured logging
|
|
fi
|
|
|
|
print_status "Python dependencies installed"
|
|
}
|
|
|
|
# Build C++ components
|
|
build_cpp() {
|
|
print_status "Building C++ components..."
|
|
|
|
# Create build directory
|
|
mkdir -p "$BUILD_DIR"
|
|
cd "$BUILD_DIR"
|
|
|
|
# Configure with CMake
|
|
cmake "$PROJECT_ROOT" \
|
|
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
|
|
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
|
|
-DBUILD_TESTS="$BUILD_TESTS" \
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
|
|
# Build
|
|
make -j$(nproc)
|
|
|
|
# Install
|
|
make install
|
|
|
|
print_status "C++ components built successfully"
|
|
}
|
|
|
|
# Build Python components
|
|
build_python() {
|
|
print_status "Building Python components..."
|
|
|
|
# Activate virtual environment
|
|
source "$PYTHON_VENV/bin/activate"
|
|
|
|
# Install Python package in development mode
|
|
cd "$PROJECT_ROOT"
|
|
pip install -e .
|
|
|
|
print_status "Python components built successfully"
|
|
}
|
|
|
|
# Run tests
|
|
run_tests() {
|
|
if [ "$BUILD_TESTS" = true ]; then
|
|
print_status "Running tests..."
|
|
|
|
# Activate virtual environment
|
|
source "$PYTHON_VENV/bin/activate"
|
|
|
|
# Run Python tests
|
|
if [ -d "$PROJECT_ROOT/tests" ]; then
|
|
python -m pytest "$PROJECT_ROOT/tests" -v
|
|
fi
|
|
|
|
# Run C++ tests
|
|
if [ -f "$BUILD_DIR/run_tests" ]; then
|
|
cd "$BUILD_DIR"
|
|
./run_tests
|
|
fi
|
|
|
|
print_status "Tests completed"
|
|
fi
|
|
}
|
|
|
|
# Create configuration files
|
|
create_configs() {
|
|
print_status "Creating configuration files..."
|
|
|
|
# Create configs directory
|
|
mkdir -p "$PROJECT_ROOT/configs"
|
|
|
|
# Create default camera config
|
|
cat > "$PROJECT_ROOT/configs/camera_config.json" << EOF
|
|
{
|
|
"device_id": 0,
|
|
"width": 1280,
|
|
"height": 720,
|
|
"fps": 30,
|
|
"backend": "opencv",
|
|
"buffer_size": 3,
|
|
"auto_exposure": true
|
|
}
|
|
EOF
|
|
|
|
# Create default CSI config
|
|
cat > "$PROJECT_ROOT/configs/csi_config.json" << EOF
|
|
{
|
|
"device": "intel_5300",
|
|
"interface": "wlan0",
|
|
"channel": 36,
|
|
"bandwidth": 20,
|
|
"sampling_rate": 100,
|
|
"antenna_mask": 7,
|
|
"enable_phase": true,
|
|
"enable_amplitude": true
|
|
}
|
|
EOF
|
|
|
|
# Create default calibration config
|
|
cat > "$PROJECT_ROOT/configs/calibration_config.json" << EOF
|
|
{
|
|
"pattern_type": "chessboard",
|
|
"pattern_size": [9, 6],
|
|
"square_size": 0.025,
|
|
"image_size": [1280, 720]
|
|
}
|
|
EOF
|
|
|
|
print_status "Configuration files created"
|
|
}
|
|
|
|
# Main build process
|
|
main() {
|
|
# Check requirements
|
|
check_requirements
|
|
|
|
# Clean build if requested
|
|
if [ "$CLEAN_BUILD" = true ]; then
|
|
print_status "Cleaning build directory..."
|
|
rm -rf "$BUILD_DIR"
|
|
rm -rf "$INSTALL_DIR"
|
|
fi
|
|
|
|
# Install dependencies if requested
|
|
if [ "$INSTALL_DEPENDENCIES" = true ]; then
|
|
install_python_deps
|
|
fi
|
|
|
|
# Build C++ components
|
|
build_cpp
|
|
|
|
# Build Python components
|
|
build_python
|
|
|
|
# Run tests
|
|
run_tests
|
|
|
|
# Create configuration files
|
|
create_configs
|
|
|
|
print_status "Build completed successfully!"
|
|
echo ""
|
|
echo -e "${GREEN}Next steps:${NC}"
|
|
echo "1. Activate virtual environment: source $PYTHON_VENV/bin/activate"
|
|
echo "2. Run calibration: python src/calibration/intrinsics.py --help"
|
|
echo "3. Start the holodeck: python src/ingestion/capture.py"
|
|
echo ""
|
|
}
|
|
|
|
# Run main function
|
|
main "$@" |