-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_record.py
60 lines (43 loc) · 1.52 KB
/
process_record.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from pydbus import SessionBus
import pydbus_module
from lane_follower import LaneFollower
#from image_processor import *
from class_image_processor import ImageProcessor
import cv2 as cv
import time
from jetcam.csi_camera import CSICamera
# PyDbus Setting
bus = SessionBus()
service = pydbus_module.VehicleControlDBusService()
bus.publish("com.team2.VehicleControl", service)
print("VehicleControl D-Bus service is running.")
width = 1280
height = 720
# Controller Init
lane_follower = LaneFollower(width=width, height=height, camera_offset=0, max_steer=1.0, normal_throttle=1.0, k_o=1.4, k_c=0.8)
imageprocessor = ImageProcessor()
# # Image Init
#cap = cv.VideoCapture('camera_test/new_output.avi')
camera = CSICamera(width=width, height=height, capture_width=width, capture_height=height, capture_fps=5)
fourcc = cv.VideoWriter_fourcc(*'XVID')
out = cv.VideoWriter('new_output.avi', fourcc, 15, (1280, 720))
# while cap.isOpened():
# ret, frame = cap.read()
while 1:
image = camera.read()
#cv.imshow('frame', image)
start_time = time.time()
middle_points = imageprocessor.frame_processor(image)
end_time = time.time()
execution_time = end_time - start_time
print(f"Execution time: {execution_time} seconds")
lane_follower.calculate_control(middle_points)
throttle, steer = lane_follower.get_control()
service.SetThrottle(0.2)
service.SetSteering(steer * -1.0)
out.write(image)
if cv.waitKey(1) == ord('q'):
break
out.release()
# cap.release()
cv.destroyAllWindows()