pkern90 / vehicle-tracking

Vehicle tracking using computer vision
7 stars 1 forks source link

Non-integer index error when running VideoProcessing.py #3

Closed JJablon closed 6 years ago

JJablon commented 6 years ago

I'm getting following error when running VideoProcessing.py. Has anyone experienced it?

$ python VideoProcessing.py [MoviePy] >>>> Building video videos/project_video_very_short_ann.mp4 [MoviePy] Writing video videos/project_video_very_short_ann.mp4 0%| | 0/97 [00:00<?, ?it/s]Traceback (most recent call last): File "VideoProcessing.py", line 134, in <module> project_clip.write_videofile(project_output, audio=False) File "<decorator-gen-51>", line 2, in write_videofile File "C:\Users\lenovo\AppData\Roaming\Python\Python36\site-packages\moviepy\decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "<decorator-gen-50>", line 2, in write_videofile File "C:\Users\lenovo\AppData\Roaming\Python\Python36\site-packages\moviepy\decorators.py", line 137, in use_clip_fps_by_default return f(clip, *new_a, **new_kw) File "<decorator-gen-49>", line 2, in write_videofile File "C:\Users\lenovo\AppData\Roaming\Python\Python36\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB return f(clip, *a, **k) File "C:\Users\lenovo\AppData\Roaming\Python\Python36\site-packages\moviepy\video\VideoClip.py", line 349, in write_videofile progress_bar=progress_bar) File "C:\Users\lenovo\AppData\Roaming\Python\Python36\site-packages\moviepy\video\io\ffmpeg_writer.py", line 209, in ffmpeg_write_video fps=fps, dtype="uint8"): File "C:\Users\lenovo\AppData\Roaming\Python\Python36\site-packages\tqdm\_tqdm.py", line 833, in __iter__ for obj in iterable: File "C:\Users\lenovo\AppData\Roaming\Python\Python36\site-packages\moviepy\Clip.py", line 475, in generator frame = self.get_frame(t) File "<decorator-gen-14>", line 2, in get_frame File "C:\Users\lenovo\AppData\Roaming\Python\Python36\site-packages\moviepy\decorators.py", line 89, in wrapper return f(*new_a, **new_kw) File "C:\Users\lenovo\AppData\Roaming\Python\Python36\site-packages\moviepy\Clip.py", line 95, in get_frame return self.make_frame(t) File "C:\Users\lenovo\AppData\Roaming\Python\Python36\site-packages\moviepy\Clip.py", line 136, in <lambda> newclip = self.set_make_frame(lambda t: fun(self.get_frame, t)) File "C:\Users\lenovo\AppData\Roaming\Python\Python36\site-packages\moviepy\video\VideoClip.py", line 533, in <lambda> return self.fl(lambda gf, t: image_func(gf(t)), apply_to) File "VideoProcessing.py", line 131, in <lambda> project_clip = clip1.fl_image(lambda frame: process_frame(frame, lane_detector, vehicle_detector)) File "VideoProcessing.py", line 101, in process_frame frame_lane = lane_detector.process_frame(frame_lane) File "C:\Users\lenovo\Desktop\lane_watch\vehicle-tracking-master\LaneDetection\LaneDetector.py", line 139, in process_frame left_x, left_y = detect_lane_along_poly(frame, self.left_line.best_fit_poly, self.line_segments) File "C:\Users\lenovo\Desktop\lane_watch\vehicle-tracking-master\LaneDetection\ImageUtils.py", line 234, in detect_lane_along_poly x, y = get_pixel_in_window(img, x, center, pixels_per_step) File "C:\Users\lenovo\Desktop\lane_watch\vehicle-tracking-master\LaneDetection\ImageUtils.py", line 252, in get_pixel_in_window window = img[y_center - half_size:y_center + half_size, x_center - half_size:x_center + half_size] TypeError: slice indices must be integers or None or have an __index__ method

pkern90 commented 6 years ago

Which python version are you using?

JJablon commented 6 years ago

3.6

pkern90 commented 6 years ago

That should be fine. Can you check the datatype of x_center and y_center inside LaneDetection\ImageUtils.py the get_pixel_in_window function?

JJablon commented 6 years ago

<class 'numpy.int32'> <class 'int'> x_center and y_center accordingly

JJablon commented 6 years ago

i've added line: x_center = np.int16(x_center1) in line 251 and renamed parameter x_center to x_center1 seems to work thanks for help!