Skip to content

DaiSwap/DC-T

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python script designed to control drone using the DroneKit library while simultaneously utilizing the YOLO model for real-time object detection.

  1. Library Imports:

    • cv2 (OpenCV): Used for capturing video from the camera and displaying it.
    • numpy: Image processing tasks.
    • pydarknet: A Python wrapper for the Darknet YOLO implementation, used for object detection.
    • dronekit: A library that allows communication and control of drones using the MAVLink protocol.
  2. Drone Connection:

    • The drone is connected via a serial connection (usually over USB) using dronekit.connect.
  3. YOLO Model Loading:

    • The YOLO model is loaded using the Detector class from pydarknet. Configuration files and weights are specified for the model.
  4. Camera Initialization:

    • OpenCV is used to capture video from the default camera (cv2.VideoCapture(0)).
  5. Main Loop:

    • The script enters a loop where it continuously captures frames from the camera.
    • Each frame is passed through the YOLO object detector to identify objects within the frame.
  6. Object Detection and Decision Making:

    • For each detected object, if the object is classified as a "person," the script calculates the error in the x and y positions between the detected person’s center and the center of the frame.
    • A simple proportional controller calculates the forward and right movements needed to center the detected person in the frame.
    • These movements are then translated into control commands which are sent to the drone using vehicle.channels.overrides.
  7. Display and Cleanup:

    • The frame with detections is displayed using OpenCV.
    • The loop continues until the 'q' key is pressed.
    • Finally, the script releases the camera, closes all OpenCV windows, and closes the connection to the drone.

Purpose

The script aims to demonstrate a basic example of autonomous drone control based on real-time visual input. Specifically, it uses computer vision to detect a hotspot and adjusts the drone’s position to keep the hotspot centered in the camera's field of view.

About

Drone calibration and testing - For detection/navigation/path planning

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages