Image

Meet LookoutConnect.py: Bridging AI and Wildfire Detection

In wildfire mitigation, the window between ignition and detection determines the outcome of the disaster. LookoutConnect.py is a robust, lightweight middleware designed to turn standard IP cameras into intelligent wildfire sentinels. By acting as a resilient bridge between local hardware and the LookOut Wildfire Detection SaaS, it ensures that critical visual data reaches the cloud for analysis, even in the harshest environments.

Image

What Does LookoutConnect.py Do?

LookoutConnect.py is engineered for mission-critical reliability, featuring a suite of advanced tools that go far beyond simple file transfers:

  • Network Resilience: Wildfire cameras are often stationed at remote sites using cellular or radio links. LookoutConnect.py utilizes an Exponential Backoff algorithm for uploads. If a transmission fails due to signal jitter, the script waits and retries with increasing intervals, ensuring the image eventually reaches the AI without crashing the local network connection.
  • Smart Bandwidth Management: While the script defaults to high-fidelity original images, it includes a smart 1080p Resizing Logic. By using the --resize flag, users can downscale images using Lanczos resampling before transmission, drastically reducing data costs on metered links without sacrificing the clarity needed for smoke detection.
  • System Integrity: To ensure 24/7 uptime, the script includes a file system-level Process Lock to prevent multiple instances from overlapping. Additionally, a Watchdog Timer monitors every execution; if a network request hangs, the watchdog kills the process after 55 seconds (default value) to prevent “zombie” tasks from piling up.
  • Pushover Emergency Alerts: We have integrated Pushover API support. When the LookOut wildfire detection informs a detection, the script immediately dispatches a high-priority emergency alert to the user’s mobile device. These alerts use “Priority 2” settings, which bypass silent modes and repeat until acknowledged.
  • Manual Override: For testing or forensic re-analysis, the new Manual File mode allows users to specify a single file for upload (e.g., --file test.jpg). This bypasses the automatic directory polling, making it an essential tool for system verification.
Image

Outputs & Forensic Logs

LookoutConnect provides a transparent audit trail for every event:

  • detectionResults.txt: This is the system’s heartbeat. It logs the timestamp, filename, and the raw AI detection metadata (coordinates and scores). To save disk space, the log automatically rotates once it reaches 5MB.
  • Image Archiving (API Mode): In API mode, if a detection is confirmed, the script automatically saves a copy of the evidence image into the archive folder, providing a permanent visual record for fire investigators.
  • State Tracking (.ptr file): To prevent duplicate processing in FTP mode, the script maintains a “pointer” file. This tracks the unique signature of the last processed image, ensuring that even after a reboot, the script never resends old data.

How to Use

Deployment: LookoutConnect.py is designed for the “Edge.” Because the code is highly optimized and lightweight, it does not require a server. It can run on any PC directly connected to the camera network, making it the perfect candidate for Raspberry Pi or Mini PC deployments at the network boundary.

1. Choose Your Mode

  • API Mode: The script “pulls” a snapshot from the camera using a direct HTTP request. Ideal for cameras with robust web APIs.
  • FTP Mode: The script “watches” a folder. This is perfect for cameras configured to automatically push images to a local directory or NVR.

2. Configure the .env File

Create a .env file in the script directory to store your credentials securely:

  • CAMERA_IP/USER/PASS: Credentials for API snapshot requests.
  • SOURCE_PATH: The directory to monitor for FTP images.
  • ARCHIVE_DIR: Where images are archived once wildfires are detected in API mode.
  • LOOKOUT_API_KEY: Your unique AI platform key. The part of your LookOut camera endpoint URL after apiKey=. It is a 32-character string.
  • PUSHOVER_APP_TOKEN & USER_KEY: For emergency mobile alerts.

3. Execute

Run the script manually or via a one-minute Cron job:

  • Standard run: python3 LookoutConnect.py ftp
  • Bandwidth-saving: python3 LookoutConnect.py api --resize
  • Manual test: python3 LookoutConnect.py ftp --file fire_test.jpg

You can run the script periodically via cron jobs and redirect the outputs to files.

  • * * * * * cd /home/your/directory/ && /usr/bin/python3 LookoutConnect.py api >> log.txt 2>&1
  • * * * * * cd /home/your/directory/ && /usr/bin/python3 LookoutConnect.py ftp >> log.txt 2>&1

By combining surveillance cameras with edge computing and cloud AI, LookoutConnect.py offers a professional-grade solution for early wildfire detection, ensuring that when smoke appears, the right people are notified immediately.

Image

Learn Python to Automate Boring Stuff

Automate the Boring Stuff with Python‘ (hereafter referred to as ‘Automate’) is an easy-to-read and quick-to-apply Python book with numerous practical program examples. Thanks, Al!

Image
Fig 1: Automate the Boring Stuff with Python, source: automatetheboringstuff.com

After graduation, I didn’t engage in programming beyond simple automation shell scripts. This summer, I aimed to assist my interns in building a new MVP (Minimum Viable Product). I was eager to develop automation tools for my LookOut Wildfire Detection SaaS customers to manage their cameras. I’m glad I took action to learn and code in Python!

Fortunately, I discovered the book ‘Automate’ on amazon.com. The book cover is eye-catching, and the preface clarifies what readers can achieve. The code examples and quizzes are invaluable, covering topics like Regular Expressions, sending text messages with Twilio, and adding text to images. I applied these skills to construct my first Python-based MVP.

Image
Fig 2: public webcam image with the addition of local time and weather condition

‘Automate’ enabled me to create automation tools that delighted my customers. I connected with the author, Al Sweigart, on LinkedIn, expressed my gratitude, and engaged in intriguing conversations. It’s been an engaging reading experience.

I aspired to write an Amazon product review but encountered a hurdle—Amazon deemed me ineligible. I disagreed.

Last Saturday morning, I contacted Amazon customer service through the iPhone app’s chatbox, harboring skepticism about a resolution. After a few clicks, I interacted with customer service agents Ajithkumar and Abul. They recommended reaching out to Amazon community service, available 24/7. They resolved my issue, allowing me to post my Amazon product review just nine hours after emailing Amazon community service. Impressive.

This marks my first Amazon product review, following more than a decade as a customer. Remarkable.

Image
Fig 3: my first Amazon product review

Gratitude to Ajithkumar, Abul, and Amazon community service. It was a delightful customer service experience.

Programming is a creative pursuit. I take joy in crafting Python tools to automate tedious and mundane tasks. I’m eager to progress further in my Python journey with the book ‘Beyond the Basic Stuff with Python‘!

Image
Fig 4: Beyond the Basic Stuff with Python, source: automatetheboringstuff.com

LookOut Messenger – our new MVP

LookOut Messenger is an MVP (minimum viable product) designed to enable image input to LookOut Wildfire Detection SaaS. Its Python codes are freely available on GitHub.

Why?
Some potential customers aim to use their existing cameras for detecting wildfires, especially small farms and communities with limited budgets for wildfire risk mitigation. Some want to deploy our solutions immediately to get early warning of wildfire and mitigate the risk, and it is only possible if we make use of their existing cameras. Our goals are to empower them to utilize Lookout Wildfire Detection SaaS now with their current equipment and avoid the wait time for new hardware.

Image
Fig 1: Network diagram: LookOut Messenger gets images from camera and sends them to LookOut Wildfire Detection SaaS

Using a surveillance camera to detect forest fires is simple: set up the camera to send JPEG images to LookOut periodically using the HTTP Post method. LookOut will then analyze the images to identify wildfires and send detection alerts to users.

While all AXIS surveillance cameras support this setup, other security cameras cannot achieve it. These cameras are not intended for enterprise customers, so interoperability and third-party system support are not their main focus.

How?
Creating software to enable security cameras to provide image input to LookOut is technically feasible, given the security cameras provide API access to live JPEG images. The software program is lightweight and can run on most old or budget computers or Raspberry Pi. There’s no need for new hardware investment. This tool can help more customers use our LookOut Wildfire Detection SaaS. It is viable for us to provide the application for free. It looks like a good idea according to the Desirability-Viability-Feasibility (DVF) framework.

Image
Fig 2: Desirability, Viability and Feasibility (DVF) framework (source: Marcus Kirsch)

What?

We build a prototype to validate the idea last November. It was a simple Bash shell script to perform two tasks repeatedly every 30 seconds:

  • obtain a JPEG image from a camera
  • send the image to LookOut Wildfire Detection SaaS

These tasks are messenger-based, with no visual changes or display. They run in the background. The internal codename of this shell script is LookOut Messenger.

Fast Iterations during the Summer Internship
This summer, we collaborated with our interns on multiple R&D projects. Two ambitious undergrads teamed up us under the CITRIS Workforce Innovation Program. They joined our customer meetings. We listened to our customers, identified common needs, and worked together to build MVPs to get more customer feedback and validate our findings.

One MVP is a new version of LookOut Messenger. We added the new capabilities that our customers need. We build the MVP with Python. In addition to the features of the Bash shell script, the LookOut Messenger can:

  1. add local time to input images
  2. add OpenWeather weather info to input images
  3. output the program execution status to a file
  4. send SMS notifications of AI detection
  5. support PTZ camera guard tour
  6. support more security camera models

These new capabilities help some customers to make their specific use cases. Customers can set up schedules to execute LookOut Messenger and use LookOut Wildfire Detection SaaS at specific times of the day. The new LookOut Messenger empowers customers to further customize LookOut to better suit their needs. The new Python software is lightweight and can run in the background without slowing down the computer. Some customers are evaluating the new Lookout Messenger.

Image
Fig 3: LookOut Messenger – program flowchart

Image
Fig 4: Python IDE

We learn more about how to use the DVF model to prioritize new ideas. We try different things to build MVP to measure customer usage. We practice frequently how to design products with human-centered mindset. All these lead to creative journeys full of unknowns that I thoroughly enjoy.

“Programming is a creative task, like painting, writing, knitting, or constructing LEGO castles. Like painting a blank canvas, making software has many constraints but endless possibilities,” said Al Sweigart in his book Automate the Boring Stuff with Python.

Image
Fig 5: public webcam image with the addition of local time and weather condition

Design a site like this with WordPress.com
Get started