Skip to content

Commit

Permalink
created lf_const.toml, a pyproject.toml, and added type hinting
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaibhav-Hariani committed Sep 29, 2024
1 parent 187bd1b commit 8c363c8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
29 changes: 17 additions & 12 deletions components/lane_follower/src/individual_follower.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Lane Follower for a single camera
# Applies a perspective transform to an image, and isolates lane lines
import numpy as np
import math

import cv2
import numpy as np

from einops import rearrange


class if_result:
pass


class IndividualFollower:
# Constants for how we process images
# These should be parametrized and better defined at a later date: as part of testing
# Get these from .toml or on intiialization
NWINDOWS = 9
SEARCH_WIDTH = 100
MINPIXELS = 40
Expand All @@ -23,25 +27,25 @@ def __init__(self):
# self.fit is set in Plot_Line
self.fit = None
# These two are set below
self._binary_warped = None
self.histogram = None
self._binary_warped = None | np.ndarray
self._histogram = None | np.ndarray

# Need to determine if these should remain properties
# Or if they should be passed as arguments to Plot_Line
@property
def _binary_warped(self, value: np.ndarray):
self._binary_warped = value
self.histogram = np.sum(
self._histogram = np.sum(
self.binary_warped[self.binary_warped.shape[0] // 2 :, :], axis=0
)

def plot_line(self):

if self.binary_warped is None:
def plot_line(self) -> if_result:
if not self._binary_warped:
raise Exception("no binary warp specified")

# Image to visualize output
out_img = (
out_img = rearrange()
(
np.dstack(
(self._binary_warped, self._binary_warped, self._binary_warped)
)
Expand All @@ -60,6 +64,7 @@ def plot_line(self):

empty_windows = 0
lane_base = np.argmax(self.histogram[:])

for window in range(IndividualFollower.NWINDOWS):
window_dims = window * window_height
win_y_upper = self._binary_warped.shape[0] - window_dims
Expand Down
8 changes: 8 additions & 0 deletions components/lane_follower/src/lf_const.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Individual_Follower]
NWINDOWS = 9
SEARCH_WIDTH = 100
MINPIXELS = 40
LANE_POLY_SIZE = 2
BOX_COLOR = [0, 255, 0]
LANE_COLOR = [255, 0, 0]
DRAW_THICKNESS = 2
12 changes: 12 additions & 0 deletions components/lane_follower/src/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[project]
version = '1.0'
name = "individual-follower"
dependencies = [
"cv2",
"numpy",
]
authors = [
{name = "Vaibhav Hariani"},
{name = "Isaiah Rivera"},
]
description = "IGVC lane follower module for a single camera"

0 comments on commit 8c363c8

Please sign in to comment.