Martin NguyenJeff Huang
Published

Fire Alarm 201

Fire Alarm 201 is the revolutionary fire alarm system that distinguish between emergencies and false alarms caused by pranks or accidents

IntermediateWork in progress92
Fire Alarm 201

Story

Read more

Code

Fire Alarm 201

C/C++
#include <opencv2/opencv.hpp>
#include <iostream>

int main() {
    // Simulated sensor data (you should replace this with real sensor data)
    double smokeLevel = 0.2;
    double heatLevel = 0.8;

    // Extract relevant features (simplified for demonstration)
    cv::Mat features(1, 2, CV_64F);
    features.at<double>(0, 0) = smokeLevel;
    features.at<double>(0, 1) = heatLevel;

    // Load your pre-trained machine learning model (e.g., SVM or Random Forest)
    cv::Ptr<cv::ml::SVM> svm = cv::ml::SVM::load("your_model.xml"); // Replace with your model file

    // Perform prediction
    float prediction = svm->predict(features);

    // Interpret prediction result
    if (prediction == 1) {
        std::cout << "Fire detected! Activate the alarm." << std::endl;
        // Trigger the alarm here
    } else {
        std::cout << "False alarm. No action required." << std::endl;
    }

    return 0;
}

Credits

Martin Nguyen
1 project • 0 followers
Jeff Huang
1 project • 0 followers

Comments