Skip to content

koushikvasa/Car-temperature-analysis

Repository files navigation

Car Temperature Using Thermal Image/Camera

A machine learning project that predicts car temperature based on environmental conditions and car characteristics using thermal imaging data. This capstone project was developed at SRM University - AP, Andhra Pradesh to improve fuel efficiency in automobiles through temperature prediction.

📋 Table of Contents

📝 Abstract

With emerging technology, engineers have developed methods to monitor car temperature using thermal sensors. This project proposes a simpler, cost-effective solution to predict the temperature range of a car using just two parameters: car color and current outside temperature - without requiring any physical devices.

Key Motivation

When a vehicle is parked in the sun, temperature levels in the cabin can be more than 20°C above the ambient temperature. This project helps:

  • Determine car temperature in different weather conditions
  • Provide insights on fuel savings during hot summer days
  • Enable consumers to efficiently plan their air conditioning usage
  • Help new car buyers analyze vehicle efficiency

🎯 Project Overview

Temperature of an automobile significantly impacts its fuel efficiency. When drivers return to cars parked in sunlight and immediately use air conditioning to decrease temperature, it compromises fuel efficiency by increasing consumption.

Solution Approach

Instead of using expensive automatic temperature analysis devices, we use thermal imaging analysis with a FLIR (Forward Looking InfraRed) camera to:

  • Capture thermal data of automobiles
  • Train machine learning models on the captured data
  • Predict car temperature using only external parameters
  • Provide temperature range predictions without thermal cameras

🎯 Objectives

  • Increase fuel efficiency of automobiles by providing temperature data to consumers without using thermal cameras
  • Use multiple machine learning models to improve accuracy and predict automobile temperature range
  • Improve thermal imaging applications to solve real-world problems with simple and feasible techniques
  • Enable informed decision-making for both current and prospective car owners

📊 Dataset

Data Collection

Data was collected using a FLIR (Forward Looking InfraRed) thermal camera provided by the mentor.

Key Features:

  • Time: Time of day when measurement was taken
  • Temperature of Day: Current ambient temperature (°C)
  • Temperature of Object: Car surface temperature (°C)
  • Inside/Outside: Parking location
  • Cloudy/Sunny: Weather condition
  • Color of Object: Car color (Black, White, Silver, Orange, Green, Blue, Cream, etc.)

Sample Dataset

Image No Name Time Temp of Day Temp of Obj Location Weather Color
FLIR0116 Black Stand 3:05 PM 43°C 42.9°C Outside Sunny Black
FLIR0118 Iron Rod 12:05 PM 45°C 39.7°C Outside Sunny Blue
FLIR0122 Basketball 12:30 PM 46°C 41.6°C Outside Sunny Orange
FLIR0132 Chevrolet Car 11:00 PM 41°C 40.9°C Outside Sunny Cream

Data Augmentation

To generate more data points from limited thermal images:

  1. Thermal images captured in grayscale with fixed dimensions
  2. Extracted 10 random 8×8 matrices from each image
  3. Calculated average grayscale value for each matrix (pixel intensity)
  4. Applied formula to determine exact temperature:
ExactTemp(a) = ((a'/255) × (maxTemp(a) - minTemp(a))) + minTemp(a)

Where:

  • a = Image pixel matrix (r1, r2)
  • a' = mean(a) - average grayscale value
  • Result: 10 temperature measurements per image, drastically increasing dataset size

📁 Project Structure

Car-temperature-analysis/
│
├── Car temperature analysis.ipynb              # Main Jupyter notebook
├── Car Temperature Using Thermal Image_Camera.pdf  # Final project report
├── README.md                                    # Project documentation
└── data/
    └── Final.csv                                # Processed dataset (if applicable)

File Descriptions

  • Car temperature analysis.ipynb: Complete implementation including:

    • Data loading and preprocessing
    • Feature engineering (time extraction)
    • Model training (Random Forest, Decision Tree, Linear Regression, KNN)
    • Model evaluation and comparison
  • Car Temperature Using Thermal Image_Camera.pdf: Comprehensive final report containing:

    • Literature survey
    • Detailed methodology
    • Results and visualizations
    • Thermal graphs for different car colors
    • Model performance metrics

🔧 Requirements

  • Python 3.7+
  • Jupyter Notebook or JupyterLab

Python Libraries

pandas
numpy
scikit-learn
matplotlib
seaborn

💻 Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/Car-temperature-analysis.git
    cd Car-temperature-analysis
  2. Create a virtual environment (optional but recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install required packages:

    pip install pandas numpy scikit-learn matplotlib seaborn jupyter
  4. Launch Jupyter Notebook:

    jupyter notebook
  5. Open and run:

    • Navigate to Car temperature analysis.ipynb
    • Run all cells to reproduce the analysis

🔬 Methodology

Workflow

Car Temperature Thermal Image
         ↓
    ┌────────┴────────┐
    ↓                 ↓
Grayscale         Color Image
    ↓
    ├─────────────────┤
    ↓                 ↓
Training Dataset 80%  Testing Dataset 20%
    └────────┬────────┘
             ↓
      Classification
             ↓
    ┌────────┼────────┬────────┐
    ↓        ↓        ↓        ↓
Linear   Random   Decision   KNN
Regression Forest   Tree
    └────────┴────────┴────────┘
             ↓
Performance Values Calculated
             ↓
          Decision

Data Processing Steps

  1. Missing Value Handling

    • Converted '?' placeholders to NaN values
    • Standardized data handling for efficient analysis
  2. Feature Engineering

    • Extracted hour and minute from time stamps
    • Encoded categorical variables (car color, weather conditions)
    • Standardized numerical features
  3. Train-Test Split

    • 80% training data
    • 20% testing data
    • Ensures uniformity across model evaluations
  4. Model Training

    • Trained four different ML models
    • Evaluated using multiple performance metrics
    • Compared results with and without feature engineering

🤖 Models Implemented

1. Random Forest Regressor

  • Ensemble learning method using multiple decision trees
  • Reduces overfitting through bagging
  • Provides robust predictions through majority voting/averaging

Advantages:

  • Unbiased due to training on different data subsets
  • Very stable - new data points affect only one tree
  • Handles non-linear relationships effectively

Disadvantages:

  • High computational complexity
  • Longer training time than individual models
  • Requires more computational resources

2. Decision Tree Regressor

  • Tree-based learning with hierarchical decision rules
  • Each node represents a feature split
  • Leaf nodes provide final predictions

Advantages:

  • Easy to understand and interpret
  • Minimal data preprocessing required
  • Handles both categorical and numerical data

Disadvantages:

  • Prone to overfitting without pruning
  • Higher multidimensional complexity
  • Requires more memory for calculations

3. Linear Regression

  • Establishes linear relationship between features and target
  • Uses least-squares method to fit the line
  • Simple statistical model

Equation:

y = b₀ + b₁x₁ + b₂x₂ + ... + bₙxₙ

Advantages:

  • Based on fundamental statistical concepts
  • Easy to understand and implement
  • Fast training and prediction

Disadvantages:

  • Does not automatically incorporate non-linearity
  • Performance degrades with many variables
  • Assumes linear relationships

Note: Linear Regression performed poorly with categorical data in this use case.

4. K-Nearest Neighbors (KNN)

  • Instance-based learning algorithm
  • Predicts based on similarity to k nearest neighbors
  • Uses distance metrics (Euclidean, Manhattan)

Advantages:

  • No explicit model training required
  • Automatically adjusts with new training data
  • Effective for non-linear patterns

Disadvantages:

  • Computationally expensive with large datasets
  • Difficult to determine optimal k value
  • Sensitive to feature scaling

📈 Results

Model Performance Metrics

Random Forest

R² Score: 0.9998
Mean Absolute Error: 0.0247
Mean Square Error: 0.0069

🏆 Best Overall Performance

Linear Regression

R² Score: 1.0
Mean Absolute Error: 5.995 × 10⁻¹⁵
Mean Square Error: 6.074 × 10⁻²⁹

Note: Perfect scores indicate overfitting on training data, performs poorly on categorical features

Decision Tree

R² Score: 1.0
Mean Absolute Error: 0.0
Mean Square Error: 0.0

Note: Perfect training scores but may overfit

KNN

R² Score: 0.9214
Mean Absolute Error: 1.0375
Mean Square Error: 2.04

Sample Prediction

Input Parameters:

  • Time: 3:50 AM
  • Climate: Cold
  • Color: Black
  • Current Temperature: 25°C

Predicted Car Temperature:

Model Predicted Temperature (°C)
Random Forest 31.10
Decision Tree 32.50
Linear Regression 10,955.66*
KNN 34.19

*Linear regression failed due to categorical data handling

Model Performance Summary

Model Strengths Use Case
Random Forest Best balance of accuracy and generalization Recommended for production
Decision Tree Perfect training accuracy, interpretable Good for understanding patterns
KNN Good accuracy, simple Suitable for smaller datasets
Linear Regression Fast, simple Not suitable for this categorical data

🔍 Key Findings

Temperature Variation by Car Color

Dark-colored cars absorb more sunlight and heat up faster than light-colored cars:

Sunny Atmosphere (No Climate Interference)

  • Black cars: Highest temperature increase (up to 45°C+)
  • Silver cars: Moderate temperature increase (~42°C)
  • White/Cream cars: Lowest temperature increase (~40°C)
  • Color Impact: Dark colors can be 5-7°C hotter than light colors

Cloudy Atmosphere

  • Black cars: Still highest at ~42.5°C
  • Silver cars: ~41.5°C
  • Brown/White cars: ~41°C
  • Grey cars: Lowest at ~36-37°C

Scientific Explanation

Why darker colors heat up more:

  • Darker colors absorb more light energy across the spectrum
  • Lighter colors reflect more sunlight away from the surface
  • Black surfaces can absorb up to 90% of incident radiation
  • White surfaces reflect up to 70% of incident radiation

Practical Implications

  1. Fuel Efficiency: Dark-colored cars require more air conditioning, consuming more fuel
  2. Parking Strategy: Light-colored cars are better for sunny climates
  3. Interior Comfort: Cabin temperature can exceed ambient by 20°C+
  4. Material Consideration: Beyond color, car body material affects heat absorption

✨ Benefits of Thermal Imaging

Advantages for Automotive Applications

  1. Non-Contact Measurement

    • No physical sensors required
    • No installation costs
    • No maintenance needed
  2. Problem Detection

    • Identify overheating components
    • Detect cooling system issues
    • Locate thermal leaks in HVAC systems
  3. Safety & Security

    • Detect potential fire hazards
    • Identify malfunctioning electrical equipment
    • Monitor brake and tire temperatures
  4. Cost Reduction

    • Early problem detection reduces repair costs
    • Improves vehicle efficiency
    • Extends component lifespan
  5. Energy Efficiency

    • Identify energy loss points
    • Optimize HVAC system performance
    • Better insulation planning
  6. Non-Invasive & Non-Destructive

    • Ideal for sensitive equipment
    • Real-time monitoring
    • Large-area coverage

🚀 Future Work

Recommended Enhancements

  1. Advanced Feature Engineering

    • Derive time-based features (morning/afternoon/evening)
    • Create temperature difference features
    • Include humidity and wind speed data
    • Add geographical location data
  2. Advanced Algorithms

    • Implement Neural Networks for complex pattern recognition
    • Test Gradient Boosting algorithms (XGBoost, LightGBM)
    • Explore Support Vector Regression (SVR)
    • Try Deep Learning models for image-based prediction
  3. Hyperparameter Optimization

    • Grid Search for systematic parameter exploration
    • Random Search for efficient optimization
    • Bayesian Optimization for advanced tuning
  4. Ensemble Methods

    • Implement Stacking to combine multiple models
    • Use Bagging for variance reduction
    • Apply Boosting for bias reduction
  5. Model Validation

    • Cross-validation for robust performance estimates
    • Time-series validation for temporal data
    • Evaluate generalization on unseen car models
  6. Deployment

    • Create web application for real-time predictions
    • Develop mobile app for on-the-go temperature estimates
    • Implement API for third-party integration
  7. Continuous Improvement

    • Collect user feedback
    • Regular model retraining with new data
    • Adapt to changing climate patterns
    • Expand to different geographical regions

Potential Applications

  • Car Manufacturers: Integrate into vehicle design considerations
  • Insurance Companies: Factor in for premium calculations
  • Fleet Management: Optimize parking and fuel efficiency
  • Consumer Apps: Help buyers choose efficient cars

📄 License

This project is available for educational and research purposes.

📚 References

  1. Guo, L. H., Tang, F., Chen, J.P. (2012). "Engine Waste Heat Recovery Based on Organic Rankine Cycle." Vehicle Engine, 2012(2): 30-34.

  2. Soni, A. K., et al. (2022). "Modelling and thermal analysis for automobile piston using ANSYS." International Journal on Interactive Design and Manufacturing (IJIDeM), 1-15.

  3. Sadhukhan, D., et al. (2020). "Estimating surface temperature from thermal imagery of buildings for accurate thermal transmittance (U-value): A machine learning perspective." Journal of Building Engineering, 32, 101637.

  4. Miao, Z., et al. (2023). "A novel method based on thermal image to predict the personal thermal comfort in the vehicle." Case Studies in Thermal Engineering, 45, 102952.

  5. He, M.G., Zhang, X.X., Zeng, K. (2009). "A New Combined Thermodynamic Cycle for Waste Heat Recovery Vehicle Engine." Journal of Xi'An Jiaotong University, 43(11).

  6. Paidi, V., Fleyeh, H., & Nyberg, R. G. (2020). "Deep learning‐based vehicle occupancy detection in an open parking lot using thermal camera." IET Intelligent Transport Systems, 14(10), 1295-1302.

  7. Cruz, S., et al. (2021). "Real-time quality control of heat sealed bottles using thermal images and artificial neural network." Journal of Imaging, 7(2), 24.

  8. Szurgacz, D., et al. (2021). "Thermal imaging study to determine the operational condition of a conveyor belt drive system structure." Energies, 14(11), 3258.

  9. Holst, G. C. (2000). Common sense approach to thermal imaging (Vol. 1). Washington: SPIE Optical Engineering Press.

  10. Williams, T. (2009). Thermal imaging cameras: characteristics and performance. CRC Press.

📧 Contact

For questions or feedback about this project, please reach out through the university department or open an issue in the repository.


Note: This project was developed as a capstone project for partial fulfillment of Bachelor of Technology degree requirements in Computer Science and Engineering at SRM University - AP.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors