Saptami Biswas
Published © LGPL

Human detector light is detected by car head light

It is a human detector light is detected by car head light. it will detect human body and become stop without hitting the body.

IntermediateFull instructions providedOver 1 day155
Human detector light is detected by car head light

Things used in this project

Hardware components

Pico
SB Components Pico
×1
Webcam, Logitech® HD Pro
Webcam, Logitech® HD Pro
×1
DC POWER JACK 2.1MM BARREL-TYPE PCB MOUNT
TaydaElectronics DC POWER JACK 2.1MM BARREL-TYPE PCB MOUNT
×1

Software apps and online services

VS Code
Microsoft VS Code

Hand tools and fabrication machines

Soldering Tip, For Tenma Digital Display Soldering Stations 21-1590 and 21-147
Soldering Tip, For Tenma Digital Display Soldering Stations 21-1590 and 21-147

Story

Read more

Custom parts and enclosures

enclosure

it is the enclosure of my project and parts of the machine

Schematics

schematic

it is the representation of my project with flochart and components

Code

Human detector is detected by car headlight

Python
This is a AI model car ,it will stop if suddenly any human body comes infront of car ,then the light will detect the body and will stop
import cv2
import numpy as np
import tensorflow as tf

model = tf.keras.applications.MobileNetV2(weights="imagenet")


def preprocess_image(image):
    img = cv2.resize(image, (224, 224))
    img = img.astype("float32")
    img = tf.keras.applications.mobilenet_v2.preprocess_input(img)
    img = np.expand_dims(img, axis=0)
    return img

def is_human_detected(predictions):
    for _, label, score in predictions[0]:
        if label == "person" and score > 0.5:
            return True
    return False

def stop_car():
    print("Human detected! Stopping the car.")


cap = cv2.VideoCapture(0) 

while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
        break
    
   
    preprocessed_image = preprocess_image(frame)
    
    
    predictions = model.predict(preprocessed_image)
    
    
    decoded_predictions = tf.keras.applications.mobilenet_v2.decode_predictions(predictions, top=1)
    
    
    if is_human_detected(decoded_predictions):
        stop_car()
    
   
    cv2.imshow('Headlight Camera', frame)
    
   
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# Release the video capture and destroy all windows
cap.release()
cv2.destroyAllWindows()

Credits

Saptami Biswas
1 project • 0 followers

Comments