Skip to content
G

Green Ledger

Carbon Credit Minting from Farm image detection.

Created on 8th March 2026

•

G

Green Ledger

Carbon Credit Minting from Farm image detection.

The problem Green Ledger solves

🌿 The Green Ledger
Empowering Small-Scale Farmers for the Global Carbon Economy

Team: DataGeeks (Jadavpur University) Track: Open

🌍 Introduction & Vision
Indian farmers often face severe economic challenges. However, with the recent boom in the global carbon credit exchange ecosystem, these farmers have a massive, untapped opportunity to leverage their farms' CO2 capturing capabilities. The barrier? The traditional verification process is overly complex, manual, and prohibitively expensive for small-scale agriculture.

Our Vision: We replace expensive human auditors with a "Phygital" (Physical + Digital) verification node. By erecting a single pole in the middle of a farm equipped with a 360-degree panoramic camera and basic environmental sensors (temperature/humidity), we can gather raw, localized data. This data is autonomously processed via our Python Computer Vision and AI pipeline to calculate, verify, and mint carbon credits with zero friction.

🛠️ The Architecture & Codebase
Our system is driven by a lightweight, modular Python backend and a zero-build React frontend.

  1. carbon_engine.py
    Summary: The core math engine. Calculates estimated biomass, carbon sequestered, and CO2 credits based on plant counts and sensor data.
    USP (Environmental Penalty Logic): Acts as a smart contract valuer. It dynamically penalizes the farm's "Consistency Score" if the temperature spikes (>35°C) or humidity drops (<40%), ensuring credits reflect true crop conditions.
  2. video_processing.py
    Summary: Processes .mp4 farm videos using OpenCV at 1 FPS. Applies ROI (Region of Interest) masks, converts frames to HSV to isolate green plant clusters, and counts contours to calculate average plant numbers and crop health.
    USP (RGB-based NDVI): Simulates an NDVI (Normalized Difference Vegetation Index) using standard RGB/HSV video inputs, completely removing the need for expensive multispectral cameras.
  3. sensor_ingestion.py
    Summary: Reads local hardware sensor data from a mock JSON file to provide real-time temperature and humidity metrics.
    USP (Fault Tolerance): Built-in redundancy. It automatically falls back to default optimal values if the external IoT JSON file is missing or corrupted, ensuring the main pipeline never crashes due to hardware failure.
  4. main.py
    Summary: The FastAPI orchestrator. Exposes endpoints to run farm analysis, fetch real-time weather from Open-Meteo, and provides the complete API backend.
    USP (Event-Driven Automation): Uses an asynchronous background directory watcher combined with Server-Sent Events (SSE). Dropping a new video into the folder automatically triggers background analysis and pushes a real-time update event to all connected frontend clients.
  5. api_data.json & wokwi_mock.json
    api_data.json (The Green Ledger): A local JSON storage file tracking the history of all processed dates, farm metrics, and calculated carbon credits. It functions as a lightweight, persistent history of verified metrics without the overhead of a full database.
    wokwi_mock.json: A simple flat mock file containing simulated IoT hardware sensor outputs. Its easily modifiable structure allows for rapid end-to-end testing of environmental edge cases.
  6. green_ledger.html
    Summary: A full single-page React application running natively within the HTML file (via Babel standalone). The UI is split into two primary portals:
    Farmer Dashboard: Allows farmers to view environmental metrics and carbon credits. Includes a hardware simulation toggle for testing different dates (test_{date}.mp4) and provides a visual breakdown of how carbon credits are calculated from total biomass.
    Trader Marketplace: Simulates a carbon credit exchange where traders can purchase verified GreenCredit Tokens (GCT) with mock transaction hashing (simulating Polygon Amoy testnet).
    API Integration: Dynamically connects to the FastAPI backend to fetch available dates, load history, trigger the Python analytics pipeline on-demand, display Open-Meteo alerts, and subscribe to Server-Sent Events (SSE) for auto-reloading.
    USP (Zero-Build SVG Analytics): Features a zero-build React architecture using pure native SVG to render complex charts (Line, Area, Health Rings) without bloated external dependencies. The UI features glassmorphism, CSS animations, and a real-time SSE loop.
    🚀 Hackathon Implementation Notes
    To deliver a working prototype within the 36-hour time limit, we utilized the following tools and workarounds:

Demo Data: We generated photorealistic panoramic videos of cabbage and mustard farms using the Veo 3 AI video model to feed our OpenCV pipeline.
Simulated Hardware: IoT sensor data was mocked using Wokwi JSON outputs.
Web3 Simulation: Polygon Amoy testnet transactions were simulated via mock transaction hashing on the frontend.
Deployment: We used localtunnel to create a temporary public server for our local FastAPI workspace, while the frontend UI was deployed seamlessly via Netlify.

Challenges we ran into

🚧 Challenges We Ran Into (And How We Solved Them)

  1. The "Localhost" Cross-Network Trap
    The Problem: During integration, the frontend React app (running on Member 3's laptop) and the Node.js backend (Member 2) could not communicate with the core Python FastAPI AI engine running locally on the Team Lead's machine. Event Wi-Fi networks often use "Client Isolation," blocking peer-to-peer laptop communication.

The Solution: We exposed the FastAPI server to 0.0.0.0 and routed our traffic through localtunnel. This created a secure, temporary public endpoint, allowing our microservices to talk to each other seamlessly despite strict network firewalls.

  1. The 360-Degree Computer Vision "Overcount"
    The Problem: Processing a continuous 360-degree panoramic video of the farm meant that cv2.findContours would analyze the same cabbage plant multiple times as the camera spun, leading to massively inflated biomass calculations.

The Solution: Instead of analyzing every frame, we engineered our Python script to extract frames at precise chronological intervals (simulating North, East, South, and West coordinates). This eliminated duplicate plant counting while still capturing the entire farm's area.

  1. Simulating Multispectral NDVI with Standard RGB
    The Problem: True carbon footprint auditing uses expensive multispectral satellite cameras to calculate the NDVI (Normalized Difference Vegetation Index). We only had standard RGB video generated by Veo 3.

The Solution: We wrote a custom algorithm to convert the BGR video frames into the HSV (Hue, Saturation, Value) color space. By dialing in the exact upper and lower bounds for the "vibrant green" array, we successfully isolated the living biomass from the brown soil shadows, creating a highly accurate "Poor Man's NDVI."

  1. API Timeouts from Heavy AI Processing
    The Problem: Video processing is computationally heavy. When the frontend triggered the /api/v1/analyze-farm endpoint, the React UI would time out waiting for the Python script to finish analyzing the Veo 3 video frame-by-frame.

The Solution: We decoupled the process. We implemented an asynchronous background directory watcher in Python paired with Server-Sent Events (SSE). The API instantly returns a "Processing" status to the frontend, and once the OpenCV engine finishes its math, it pushes the data via SSE to auto-update the React dashboard without forcing the user to refresh.

  1. Hardware Fault Tolerance in the Pipeline
    The Problem: Relying on external simulated IoT data (Wokwi JSON files) meant that if a "sensor" went offline or the file path broke, the entire Carbon Math engine would crash, returning a 500 Internal Server Error during the demo.

The Solution: We built strict error handling and fallback logic into sensor_ingestion.py. If the hardware payload is missing or corrupted, the system automatically injects historical baseline data, ensuring the web application and Web3 minting process remain completely stable.

Tracks Applied (1)

Slash (Open)

Green technology + mock IOT + Web3

Technologies used

Discussion

Builders also viewed

See more projects on Devfolio