Git Product home page Git Product logo

visualbuffer / copilot Goto Github PK

View Code? Open in Web Editor NEW
148.0 2.0 54.0 15.42 MB

Lane and obstacle detection for active assistance during driving. Uses windowed sweep for lane detection. Combination of object tracking and YOLO for obstacles. Determines lane change, relative velocity and time to collision

Home Page: https://towardsdatascience.com/copilot-driving-assistance-635e1a50f14

License: MIT License

Python 23.84% Jupyter Notebook 76.16%
yolov3 autonomous-vehicles lane-detection cv2 obstacle-detection lane-lines-detection lane-finding lane-tracking lane-curvature lane-lines

copilot's Introduction

Copilot : Driving assistance on mobile devices

Lane and obstacle detection for active assistance during driving.


Vehicle Position + collision time superposed in the top view

Accompanying article https://towardsdatascience.com/copilot-driving-assistance-635e1a50f14

Global annual road accidents fatalities total about 1.5 million which is just about the population of Mauritius. 90% of these occur in low and middle income countries which have less than half of the total vehicles in the world. Advanced driver-assistance systems (ADAS) Lane detection, collision warning are present in less than 0.1% of the vehicles. They are almost non existent in developing countries. Median Smartphone ownership in emerging economies is about 10 times as high as that of four wheeler. While we already have semi autonomous vehicles running about in parts of the world. This repository checks how close we might come to using a mobile computing platform as an ADAS copilot.

DOWNLOAD WEIGHTS AND CODE

! git clone https://github.com/visualbuffer/copilot.git
! mv copilot/* ./
! wget -P ./model_data/ https://s3-ap-southeast-1.amazonaws.com/deeplearning-mat/backend.h5


Robustness for different illumination conditionsz

USAGE EXAMPLE

from frame import FRAME

file_path =  "videos/highway.mp4"# <== Upload appropriate file          
video_out = "videos/output11.mov"
frame =  FRAME( 
    ego_vehicle_offset = .15,                       # SELF VEHICLE OFFSET
    yellow_lower = np.uint8([ 20, 50,   100]),      # LOWER YELLOW HLS THRESHOLD
    yellow_upper = np.uint8([35, 255, 255]),        # UPER YELLOW HLS THRESHOLD
    white_lower = np.uint8([ 0, 200,   0]),         # LOWER WHITE THRESHOLD
    white_upper = np.uint8([180, 255, 100]),        # UPPER WHITE THRESHOLD
    lum_factor = 118,                               # NORMALIZING LUM FACTOR
    max_gap_th = 0.45,                              # MAX GAP THRESHOLD
    YOLO_PERIOD = .25,                              # YOLO PERIOD
    lane_start=[0.35,0.75] ,                        # LANE INITIATION
    verbose = 3)                                    # VERBOSITY
frame.process_video(file_path, 1,\
        video_out = video_out,pers_frame_time =144,\
        t0  =144 , t1 =150)#None)
PARAMETER Description
SELF VEHICLE OFFSET Trim off from bottom edge video if ego vehicle covers part of the frame % of front view
LOWER YELLOW HLS THRESHOLD Lower yellow HLS threshold used to prepare the mask. Tune down if yellow lane is not detected, up if all the foilage is
UPPER YELLOW HLS THRESHOLD Upper threshold for identifying yellow lanes
LOWER WHITE THRESHOLD Lower yellow HLS threshold used to prepare the mask. Tune up saturation if foilage lights up the entire scene
UPPER WHITE THRESHOLD
NORMALIZING LUM FACTOR Factor used to normalize luminosity against, reducing increses lower Lum threshold
MAX GAP THRESHOLD Max continous gap tollerated in the lane detection % of top-view height
YOLO PERIOD Period [s] after which YOLO is detected, typ 2s reducing decreases processing fps increases detection
LANE INITIATION intial guess for lane start % of top-view width
VERBOSITY 1 Show lesser,2 Show less,3 Show everything


Detecting lane change automatically

Notebooks

DIRECTORY COLAB
./notebooks/coPilot.ipynb https://colab.research.google.com/drive/1CdqDXZqssDgSC35W4A-4Gp8kfqzyPKug

Ref:

https://github.com/qqwweee/keras-yolo3

copilot's People

Contributors

imgbotapp avatar visualbuffer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

copilot's Issues

doesn't work on custom video

Thanks for the amazing work. I am getting an error while running on a custom video. Its time duration is 6 seconds and I changed the parameters. but it shows me an error in the attached image.
Your help would be highly appreciated.

Screen Shot 2020-12-02 at 12 48 53 PM

TypeError: 'NoneType' object is not subscriptable

I've downloaded you project and changed the file_path attribute in the frame.py file, here's the code:

    file_path =  "Video/1min.mp4"# <== Upload appropriate file          
    video_out = "Output/1min.mov"

    frame =  FRAME( 
        ego_vehicle_offset = .15,
        yellow_lower = np.uint8([ 20, 50,   100]),
        yellow_upper = np.uint8([35, 255, 255]),
        white_lower = np.uint8([ 0, 200,   0]),
        white_upper = np.uint8([180, 255, 100]), 
        lum_factor = 118,
        max_gap_th = 0.45,
        YOLO_PERIOD = .25,
        lane_start=[0.35,0.75] , 
        verbose = 3)
    frame.process_video(file_path, 1,\
            video_out = video_out,pers_frame_time =144,\
            t0  =144 , t1 =150)#None)

Running the program, I got this error:

davidevitiello@iMac copilot % sudo python3 frame.py
2020-10-07 00:09:10.308022: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2020-10-07 00:09:10.330339: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7fc4fff30b10 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-10-07 00:09:10.330371: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
Video/1min.mp4 WIDTH 640 HEIGHT 360 FPS 29.97 DUR 59.0 s
Traceback (most recent call last):
  File "frame.py", line 313, in <module>
    frame.process_video(file_path, 1,\
  File "frame.py", line 242, in process_video
    self.image = self.image[:frame_h_out,:,:]
TypeError: 'NoneType' object is not subscriptable

How I do get rid of it?

I do have Python 3.7.3 installed on my system an iMac

ZeroDivisionError: float divmod()

Dear Author,
When I run the last part of the code from frame import FRAME

file_path = "./videos/nice_road.mp4"# <== Upload appropriate file
video_out = "videos/output11.mov"
frame = FRAME(
ego_vehicle_offset = .0, # offset for self vehicle in frame
yellow_lower = np.uint8([ 20, 50, 110]), # LOWER YELLOW HLS THRESHOLD
yellow_upper = np.uint8([35, 255, 255]), # UPER YELLOW HLS THRESHOLD
white_lower = np.uint8([ 0, 140, 0]), # LOWER WHITE THRESHOLD
white_upper = np.uint8([180, 255, 100]), # UPPER WHITE THRESHOLD
lum_factor = 110, # NORMALIZING LUM FACTOR
max_gap_th = 0.45, # MAX GAP THRESHOLD
YOLO_PERIOD = 2, # YOLO PERIOD
lane_start=[0.2,0.5] , # LANE INITIATION
verbose = 3) # VERBOSITY
frame.process_video(file_path, 2,video_out = video_out,pers_frame_time =398, t0 =398 , t1 =698)#None) , I am getting the following error: "ZeroDivisionError Traceback (most recent call last)
in ()
14 lane_start=[0.2,0.5] , # LANE INITIATION
15 verbose = 3) # VERBOSITY
---> 16 frame.process_video(file_path, 2,video_out = video_out,pers_frame_time =398, t0 =398 , t1 =698)#None)

/content/drive/MyDrive/copilot/frame.py in process_video(self, file_path, fps_factor, video_out, pers_frame_time, t0, t1)
232 frame_h_out = int(frame_h*(1-self.ego_vehicle_offset))
233 print("{:s} WIDTH {:d} HEIGHT {:d} FPS {:.2f} DUR {:.1f} s".format(
--> 234 file_path,frame_w,frame_h,fps_actual,nb_frames//fps_actual
235 ))
236

ZeroDivisionError: float divmod()". Kindly help me out in the same.

Expected output on custom video

Hi, Thanks for the wonderful work. I really appreciate it. I have a few doubts about the parameters used while running on video.

  1. how do you describe lane start? is it the same coordinate to start detecting the lane in the bird view image?
  2. which factors apart from frame's parameters do I need to change while running on the custom video?

Thanks!!

Screen Shot 2021-01-05 at 12 40 34 PM

How to use custom dataset instead of coco?

With coco dataset I can run the code. Now i want to use a custom dataset with just 3 classes?
What would be best approach to replace coco and integrate custom weights?

Any help would be appreciated- Thanks.

detecting Lane in all condition

Hi, Thanks for the wonderful work. I really appreciate it. I have a few doubts about the parameters used while running on video.

  1. how do you describe lane start? is it the same coordinate to start detecting the lane in the bird view image?
  2. which factors apart from frame's parameters do I need to change while running on the custom video?

Thanks!!

Screen Shot 2021-01-05 at 12 40 34 PM

error: OpenCV(4.8.0) :-1: error: (-5:Bad argument) in function 'circle' > Overload resolution failed: > - Can't parse 'center'. Sequence item with index 0 has a wrong type

I'm getting this error when I'm trying to run the code in colab where the LANE_DETECTION is called:
PERSPECTIVE TRANSFORMATION MATRIX COMPUTED

error Traceback (most recent call last)
in <cell line: 11>()
9 video_reader.set(1,pers_frame)
10 ret, image = video_reader.read()
---> 11 ld = LANE_DETECTION( image,fps,
12 yellow_lower = np.uint8([ 20, 50, 110]),
13 yellow_upper = np.uint8([35, 255, 255]),

1 frames
/content/lane_detection.py in calc_perspective(self, lane_start)
431 cv2.line(img, (int(x2), 0), (int(x2), self.UNWARPED_SIZE[1]), (0, 0, 255), 3)
432
--> 433 cv2.circle(img_orig,tuple(self.vanishing_point),10, color=RED, thickness=5)
434 cv2.circle(img_orig,tuple(orig_points),10, color=GRAY, thickness=4)
435 cv2.imwrite(self.temp_dir+"vanishing_point.jpg",img_orig)

error: OpenCV(4.8.0) 👎 error: (-5:Bad argument) in function 'circle'

Overload resolution failed:

  • Can't parse 'center'. Sequence item with index 0 has a wrong type
  • Can't parse 'center'. Sequence item with index 0 has a wrong type

Where I think the error is due to it not recognizing the tuple(self.vanishing_point) and thus giving the error.
Would like to know the fix to this

It's a great honor to have you answer!

Hello, buddy, this project is really good, I am very interested in your research, I have three questions to ask:
1, I would like to ask this program can run under what operating system, can run on the PC?
2. What toolkits do you need to install before you can run the system?
3. Can you tell me the setup steps and the running command line?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.