Skip to content
Snippets Groups Projects
Commit ea290159 authored by ssethia2's avatar ssethia2
Browse files

Fix reference before initialization

parent df928996
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ array_map = np.zeros((grid_size, grid_size)) ...@@ -15,7 +15,7 @@ array_map = np.zeros((grid_size, grid_size))
np.set_printoptions(threshold=sys.maxsize, linewidth=sys.maxsize) np.set_printoptions(threshold=sys.maxsize, linewidth=sys.maxsize)
def padMap(map): def padMap(map):
padded_map = np.zeros(len(map), len(map[0])) padded_map = np.zeros((len(map), len(map[0])))
for i in range(len(map)): for i in range(len(map)):
for j in range(len(map[0])): for j in range(len(map[0])):
...@@ -43,7 +43,7 @@ def update_map(): ...@@ -43,7 +43,7 @@ def update_map():
time.sleep(0.3) time.sleep(0.3)
# marking the car as 2 to distinguish location on array # marking the car as 2 to distinguish location on array
array_map[car_location] = 2 #array_map[car_location] = 2
# print(array_map) # print(array_map)
while angle <= 90: while angle <= 90:
distance = fc.get_distance_at(angle) distance = fc.get_distance_at(angle)
...@@ -79,12 +79,13 @@ def update_map(): ...@@ -79,12 +79,13 @@ def update_map():
# print(array_map) # print(array_map)
padded_map = padMap(array_map) padded_map = padMap(array_map)
padded_map[car_location] = 2
# Saving the array in a text file to see results # Saving the array in a text file to see results
file = open("map.txt", "w+") file = open("map.txt", "w+")
content = str(padded_map) content = str(padded_map)
file.write(content) file.write(content)
file.close() file.close()
return padded_map
# this function is used just for testing, enable it in main # this function is used just for testing, enable it in main
def object_locations(): def object_locations():
...@@ -125,4 +126,4 @@ if __name__ == '__main__': ...@@ -125,4 +126,4 @@ if __name__ == '__main__':
# test() # test()
except KeyboardInterrupt: except KeyboardInterrupt:
fc.stop() fc.stop()
exit(0) exit(0)
\ No newline at end of file
...@@ -39,9 +39,10 @@ def object_detection(interpreter, labels, stream): ...@@ -39,9 +39,10 @@ def object_detection(interpreter, labels, stream):
frame = stream.read() frame = stream.read()
frame = cv2.rotate(frame, cv2.ROTATE_180) frame = cv2.rotate(frame, cv2.ROTATE_180)
input_details = interpreter.get_input_details()
height = input_details[0]['shape'][1] height = input_details[0]['shape'][1]
width = input_details[0]['shape'][2] width = input_details[0]['shape'][2]
input_details = interpreter.get_input_details() #input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details() output_details = interpreter.get_output_details()
# Run the current frame through the object detection model # Run the current frame through the object detection model
...@@ -165,7 +166,7 @@ def main(): ...@@ -165,7 +166,7 @@ def main():
while True: while True:
# Step 1: Update the map with the latest sensor data # Step 1: Update the map with the latest sensor data
update_map() array_map = update_map()
# Step 2: Get the updated grid # Step 2: Get the updated grid
grid = array_map.copy() grid = array_map.copy()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment