Skip to main content

ssdfsdfds

 from ultralytics import YOLO

import cv2
import winsound
import time

# Load pretrained YOLO model
model = YOLO("yolov8n.pt")  # You can replace with yolov9 if needed

# Animal + Human classes we want to detect
TARGET_CLASSES = {
    0: "person",
    14: "bird",
    15: "cat",
    16: "dog",
    17: "horse",
    18: "sheep",
    19: "cow",
    20: "elephant",
    21: "bear",
    22: "zebra",
    23: "giraffe"
}

# Alert sound file
ALERT_SOUND = "alert.wav"

def play_alert():
    try:
        winsound.PlaySound(ALERT_SOUND, winsound.SND_FILENAME)
    except:
        print("Error playing alert sound!")

def main():
    cap = cv2.VideoCapture(0)   # 0 = default webcam

    last_alert_time = 0

    while True:
        ret, frame = cap.read()
        if not ret:
            break

        results = model(frame)

        detected = False

        for r in results:
            for box in r.boxes:
                cls_id = int(box.cls)
                conf = float(box.conf)

                if cls_id in TARGET_CLASSES:
                    detected = True
                    x1, y1, x2, y2 = map(int, box.xyxy[0])
                    label = f"{TARGET_CLASSES[cls_id]} {conf:.2f}"

                    # Draw box
                    cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
                    cv2.putText(frame, label, (x1, y1 - 10),
                                cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 2)

        # Play alert if detected someone/something
        if detected and time.time() - last_alert_time > 2:
            play_alert()
            last_alert_time = time.time()

        cv2.imshow("Animal + Human Detection", frame)

        if cv2.waitKey(1) & 0xFF == 27:  # ESC to exit
            break

    cap.release()
    cv2.destroyAllWindows()


if __name__ == "__main__":
    main()

Comments

Popular posts from this blog

ഇടുക്കി - അയ്യപ്പൻകോവിൽ തൂക്കുപാലം. Ayyappankovil hanging bridge in Malayalam

ഇടുക്കി ജില്ലയിലെ കാഞ്ചിയാർ - അയ്യപ്പൻകോവിൽ പഞ്ചായത്തുകളെ തമ്മിൽ ബന്ധിച്ചുകൊണ്ട് നിലനിൽക്കുന്നു. ഇടുക്കി ജില്ലയിലെ ഏറ്റവും വലിയ തൂക്കുപാലമാണിത്.  2013 ൽ ഇടുക്കി ജലാശയത്തിന് കുറുകേയാണ് ഈ തൂക്കുപാലം നിർമ്മിച്ചത്. 200 മീറ്റർ നീളത്തിൽ സ്ഥിതി ചെയ്യുന്ന അയ്യപ്പൻകോവിൽ  തൂക്കുപാലം സഞ്ചരികളുടെ മനം കവര്‍ന്നു. വർഷകാലത്ത് നിറഞ്ഞു കിടക്കുന്ന ജലാശയത്തിന് മീതെയായും വേനൽകാലത്ത് വെള്ളം ഇറങ്ങി കഴിഞ്ഞു കാണുന്ന പുൽമേടുകൾക്ക് മീതെയായും നിൽക്കുന്ന തൂക്കുപാലം കണ്ണിനും മനസ്സിനുംഒരുപോലെ സന്തോഷം പകരുന്നു.  

Chokramudi Peak || short blog || Yathrakal ishtam

 Chokramudi Peak is the one of the highest peak in Idukki, Kerala at the elevation of 7300 ft. Located in the Eravikulam national park between bisonvalley and munnar.    This peak provides a beautiful view of the surrounding valley, mountains covered with dense forest and tea plantation. Also an amazing view of anamudi peak and Idukki dam. That's an unforgettable experience. Chokramudi Trek is very short and easy trek that can be done in a day. The starting point of the trek is near from bisonvalley. From here, the trek can be of 4 to 6 hours to covering a distance of 10km upwards.   Months of December to February is the best time to trek anywhere in munnar. The breezing atmosphere and the chilling cold gives you an unforgettable memory.

ഇന്ത്യയുടെ ആത്മീയ തലസ്ഥാനം-ഋഷികേശ് |Yathrakal ishtam| spiritual capital of India Rishikesh in Malayalam

Kedarnath temple Photo courtesy insta@ keraliann വടക്കൻ ഉത്തരാഖണ്ഡിലെ ഒരു നഗരമാണ് ഋഷികേശ്. ഹിമാലയൻ മലനിരകൾ അതിരിട്ടു നിൽക്കുന്ന താഴ് വരയിൽ പുണ്ണ്യനദിയായ ഗംഗയുടെ തീരത്താണ് ഋഷികേശ് സ്ഥിതി ചെയ്യുന്നത്. നൂറിലധികം ക്ഷേത്രങ്ങളും യോഗ കേന്ദ്രങ്ങളും, പ്രകൃതി മനോഹാരിതയുമാണ് ഈ സ്ഥലത്തെ സവിശേഷമാക്കുന്നത്     കേദാർനാഥ്, ബദരീനാഥ്, ഗംഗോത്രി, യമുനോത്രി എന്നീ ക്ഷേത്രങ്ങളിലേക്കുള്ള  യാത്ര ആരംഭിക്കുന്നത് ഇവിടെ നിന്നാണ്. പണ്ട് കാലത്ത് ഋഷിവര്യന്മാർ ശാന്തമായ ഗംഗയുടെ തീരത്ത് തപസ്സ് ചെയ്യതിരുന്നതായി പറയപ്പെടുന്നു. യോഗ കാപ്പിറ്റൽ എന്ന് അറിയപ്പെടുന്നത് ഋഷികേശാണ്. ഒരുപാടത്തികം യോഗ കേന്ദ്രങ്ങൾ ഇവിടെ പ്രവർത്തിച്ചുവരുന്നുണ്ട്. ആദ്യകാലത്ത് ആത്മീയത തേടിയായിരുന്നു ഏറ്റവുമധികം ആളുകൾ ഇവിടെ എത്തിച്ചേരുന്നത്. ഇപ്പോൾ ആത്മീയതക്ക് പുറമെ ടൂറിസവും പച്ച പിടിച്ചിട്ടുണ്ട്.     ഗംഗയിലുടെയുള്ള റിവർ റാഫ്ടിംഗ്, പാരാഗ്ലൈടിംഗ്, കായാക്കിങ്, ബൻജി ജംമ്പിങ്,  ക്യാമ്പിങ്. ഇത്തരത്തിലുള്ള നിരവധി സാഹസിക പ്രവർത്തനങ്ങൾ സഞ്ചാരികളെ ആകർഷിക്കുന്നുണ്ട്.