enable flake8 E231: missing whitespace after comma

This commit is contained in:
Adeeb Shihadeh
2020-05-31 12:37:52 -07:00
parent ddcc78d2d5
commit efd5dffb1e
60 changed files with 228 additions and 228 deletions
+1 -1
View File
@@ -104,7 +104,7 @@ while not done:
for i in range( buttons ):
button = joystick.get_button( i )
textPrint.printf(screen, "Button {:>2} value: {}".format(i,button) )
textPrint.printf(screen, "Button {:>2} value: {}".format(i, button) )
textPrint.unindent()
+1 -1
View File
@@ -207,7 +207,7 @@ def rgb24toyuv420(rgb):
yuv420[y_len:y_len + uv_len] = us.reshape(-1)
yuv420[y_len + uv_len:y_len + 2 * uv_len] = vs.reshape(-1)
return yuv420.clip(0,255).astype('uint8')
return yuv420.clip(0, 255).astype('uint8')
def decompress_video_data(rawdat, vid_fmt, w, h, pix_fmt):
+1 -1
View File
@@ -57,7 +57,7 @@ class KBHit:
def kbhit(self):
''' Returns True if keyboard character was hit, False otherwise.
'''
dr,dw,de = select([sys.stdin], [], [], 0)
dr, dw, de = select([sys.stdin], [], [], 0)
return dr != []
+16 -16
View File
@@ -5,25 +5,25 @@ def rot_matrix(roll, pitch, yaw):
cr, sr = np.cos(roll), np.sin(roll)
cp, sp = np.cos(pitch), np.sin(pitch)
cy, sy = np.cos(yaw), np.sin(yaw)
rr = np.array([[1,0,0],[0, cr,-sr],[0, sr, cr]])
rp = np.array([[cp,0,sp],[0, 1,0],[-sp, 0, cp]])
ry = np.array([[cy,-sy,0],[sy, cy,0],[0, 0, 1]])
rr = np.array([[1, 0, 0], [0, cr, -sr], [0, sr, cr]])
rp = np.array([[cp, 0, sp], [0, 1, 0], [-sp, 0, cp]])
ry = np.array([[cy, -sy, 0], [sy, cy, 0], [0, 0, 1]])
return ry.dot(rp.dot(rr))
def draw_pose(img, pose, loc, W=160, H=320, xyoffset=(0,0), faceprob=0):
rcmat = np.zeros((3,4))
rcmat[:,:3] = rot_matrix(*pose[0:3]) * 0.5
rcmat[0,3] = (loc[0]+0.5) * W
rcmat[1,3] = (loc[1]+0.5) * H
rcmat[2,3] = 1.0
def draw_pose(img, pose, loc, W=160, H=320, xyoffset=(0, 0), faceprob=0):
rcmat = np.zeros((3, 4))
rcmat[:, :3] = rot_matrix(*pose[0:3]) * 0.5
rcmat[0, 3] = (loc[0]+0.5) * W
rcmat[1, 3] = (loc[1]+0.5) * H
rcmat[2, 3] = 1.0
# draw nose
p1 = np.dot(rcmat, [0,0,0,1])[0:2]
p2 = np.dot(rcmat, [0,0,100,1])[0:2]
tr = tuple([int(round(x + xyoffset[i])) for i,x in enumerate(p1)])
pr = tuple([int(round(x + xyoffset[i])) for i,x in enumerate(p2)])
p1 = np.dot(rcmat, [0, 0, 0, 1])[0:2]
p2 = np.dot(rcmat, [0, 0, 100, 1])[0:2]
tr = tuple([int(round(x + xyoffset[i])) for i, x in enumerate(p1)])
pr = tuple([int(round(x + xyoffset[i])) for i, x in enumerate(p2)])
if faceprob > 0.4:
color = (255,255,0)
cv2.line(img, tr, pr, color=(255,255,0), thickness=3)
color = (255, 255, 0)
cv2.line(img, tr, pr, color=(255, 255, 0), thickness=3)
else:
color = (64,64,64)
color = (64, 64, 64)
cv2.circle(img, tr, 7, color=color)
+11 -11
View File
@@ -27,8 +27,8 @@ if __name__ == "__main__":
pygame.init()
pygame.display.set_caption('livedm')
screen = pygame.display.set_mode((320,640), pygame.DOUBLEBUF)
camera_surface = pygame.surface.Surface((160,320), 0, 24).convert()
screen = pygame.display.set_mode((320, 640), pygame.DOUBLEBUF)
camera_surface = pygame.surface.Surface((160, 320), 0, 24).convert()
while 1:
polld = poller.poll(1000)
@@ -46,34 +46,34 @@ if __name__ == "__main__":
faceOrientation[1] *= -1
facePosition[0] *= -1
img = np.zeros((320,160,3))
img = np.zeros((320, 160, 3))
if faceProb > 0.4:
cv2.putText(img, 'you', (int(facePosition[0]*160+40), int(facePosition[1]*320+110)), cv2.FONT_ITALIC, 0.5, (255,255,0))
cv2.putText(img, 'you', (int(facePosition[0]*160+40), int(facePosition[1]*320+110)), cv2.FONT_ITALIC, 0.5, (255, 255, 0))
cv2.rectangle(img, (int(facePosition[0]*160+40), int(facePosition[1]*320+120)),\
(int(facePosition[0]*160+120), int(facePosition[1]*320+200)), (255,255,0), 1)
(int(facePosition[0]*160+120), int(facePosition[1]*320+200)), (255, 255, 0), 1)
not_blink = evt.driverMonitoring.leftBlinkProb + evt.driverMonitoring.rightBlinkProb < 1
if evt.driverMonitoring.leftEyeProb > 0.6:
cv2.line(img, (int(facePosition[0]*160+95), int(facePosition[1]*320+140)),\
(int(facePosition[0]*160+105), int(facePosition[1]*320+140)), (255,255,0), 2)
(int(facePosition[0]*160+105), int(facePosition[1]*320+140)), (255, 255, 0), 2)
if not_blink:
cv2.line(img, (int(facePosition[0]*160+99), int(facePosition[1]*320+143)),\
(int(facePosition[0]*160+101), int(facePosition[1]*320+143)), (255,255,0), 2)
(int(facePosition[0]*160+101), int(facePosition[1]*320+143)), (255, 255, 0), 2)
if evt.driverMonitoring.rightEyeProb > 0.6:
cv2.line(img, (int(facePosition[0]*160+55), int(facePosition[1]*320+140)),\
(int(facePosition[0]*160+65), int(facePosition[1]*320+140)), (255,255,0), 2)
(int(facePosition[0]*160+65), int(facePosition[1]*320+140)), (255, 255, 0), 2)
if not_blink:
cv2.line(img, (int(facePosition[0]*160+59), int(facePosition[1]*320+143)),\
(int(facePosition[0]*160+61), int(facePosition[1]*320+143)), (255,255,0), 2)
(int(facePosition[0]*160+61), int(facePosition[1]*320+143)), (255, 255, 0), 2)
else:
cv2.putText(img, 'you not found', (int(facePosition[0]*160+40), int(facePosition[1]*320+110)), cv2.FONT_ITALIC, 0.5, (64,64,64))
cv2.putText(img, 'you not found', (int(facePosition[0]*160+40), int(facePosition[1]*320+110)), cv2.FONT_ITALIC, 0.5, (64, 64, 64))
draw_pose(img, faceOrientation, facePosition,
W = 160, H = 320, xyoffset = (0, 0), faceprob=faceProb)
pygame.surfarray.blit_array(camera_surface, img.swapaxes(0,1))
pygame.surfarray.blit_array(camera_surface, img.swapaxes(0, 1))
camera_surface_2x = pygame.transform.scale2x(camera_surface)
screen.blit(camera_surface_2x, (0, 0))
pygame.display.flip()
+2 -2
View File
@@ -6,8 +6,8 @@ from tools.lib.route import Route
route_name = sys.argv[1]
routes = Route(route_name)
data_dump = {
"camera":routes.camera_paths(),
"logs":routes.log_paths()
"camera": routes.camera_paths(),
"logs": routes.log_paths()
}
json.dump(data_dump, open("routes.json", "w"))
+10 -10
View File
@@ -23,7 +23,7 @@ _PATH_X = np.arange(192.)
_PATH_XD = np.arange(192.)
_PATH_PINV = compute_path_pinv(50)
#_BB_OFFSET = 290, 332
_BB_OFFSET = 0,0
_BB_OFFSET = 0, 0
_BB_SCALE = 1164/640.
_BB_TO_FULL_FRAME = np.asarray([
[_BB_SCALE, 0., _BB_OFFSET[0]],
@@ -110,24 +110,24 @@ def draw_lead_on(img, closest_x_m, closest_y_m, calibration, color, sz=10, img_o
def init_plots(arr, name_to_arr_idx, plot_xlims, plot_ylims, plot_names, plot_colors, plot_styles, bigplots=False):
color_palette = { "r": (1,0,0),
"g": (0,1,0),
"b": (0,0,1),
"k": (0,0,0),
"y": (1,1,0),
"p": (0,1,1),
"m": (1,0,1) }
color_palette = { "r": (1, 0, 0),
"g": (0, 1, 0),
"b": (0, 0, 1),
"k": (0, 0, 0),
"y": (1, 1, 0),
"p": (0, 1, 1),
"m": (1, 0, 1) }
if bigplots:
fig = plt.figure(figsize=(6.4, 7.0))
else:
fig = plt.figure()
fig.set_facecolor((0.2,0.2,0.2))
fig.set_facecolor((0.2, 0.2, 0.2))
axs = []
for pn in range(len(plot_ylims)):
ax = fig.add_subplot(len(plot_ylims),1,len(axs)+1)
ax = fig.add_subplot(len(plot_ylims), 1, len(axs)+1)
ax.set_xlim(plot_xlims[pn][0], plot_xlims[pn][1])
ax.set_ylim(plot_ylims[pn][0], plot_ylims[pn][1])
ax.patch.set_facecolor((0.4, 0.4, 0.4))
+1 -1
View File
@@ -35,7 +35,7 @@ if __name__ == "__main__":
if sm.updated['liveCalibration']:
intrinsic_matrix = eon_intrinsics
img_transform = np.array(fpkt.frame.transform).reshape(3,3)
img_transform = np.array(fpkt.frame.transform).reshape(3, 3)
extrinsic_matrix = np.asarray(sm['liveCalibration'].extrinsicMatrix).reshape(3, 4)
ke = intrinsic_matrix.dot(extrinsic_matrix)
warp_matrix = get_camera_frame_from_medmodel_frame(ke)
+8 -8
View File
@@ -63,7 +63,7 @@ def ui_thread(addr, frame_address):
camera_surface = pygame.surface.Surface((640, 480), 0, 24).convert()
cameraw_surface = pygame.surface.Surface(MODEL_INPUT_SIZE, 0, 24).convert()
top_down_surface = pygame.surface.Surface((UP.lidar_x, UP.lidar_y),0,8)
top_down_surface = pygame.surface.Surface((UP.lidar_x, UP.lidar_y), 0, 8)
frame = messaging.sub_sock('frame', addr=addr, conflate=True)
sm = messaging.SubMaster(['carState', 'plan', 'carControl', 'radarState', 'liveCalibration', 'controlsState', 'liveTracks', 'model', 'liveMpc', 'liveParameters', 'pathPlan'], addr=addr)
@@ -113,7 +113,7 @@ def ui_thread(addr, frame_address):
while 1:
list(pygame.event.get())
screen.fill((64,64,64))
screen.fill((64, 64, 64))
lid_overlay = lid_overlay_blank.copy()
top_down = top_down_surface, lid_overlay
@@ -122,7 +122,7 @@ def ui_thread(addr, frame_address):
rgb_img_raw = fpkt.frame.image
if fpkt.frame.transform:
img_transform = np.array(fpkt.frame.transform).reshape(3,3)
img_transform = np.array(fpkt.frame.transform).reshape(3, 3)
else:
# assume frame is flipped
img_transform = np.array([
@@ -200,17 +200,17 @@ def ui_thread(addr, frame_address):
for lead in [sm['radarState'].leadOne, sm['radarState'].leadTwo]:
if lead.status:
if calibration is not None:
draw_lead_on(img, lead.dRel, lead.yRel, calibration, color=(192,0,0))
draw_lead_on(img, lead.dRel, lead.yRel, calibration, color=(192, 0, 0))
draw_lead_car(lead.dRel, top_down)
# *** blits ***
pygame.surfarray.blit_array(camera_surface, img.swapaxes(0,1))
pygame.surfarray.blit_array(camera_surface, img.swapaxes(0, 1))
screen.blit(camera_surface, (0, 0))
# display alerts
alert_line1 = alert1_font.render(sm['controlsState'].alertText1, True, (255,0,0))
alert_line2 = alert2_font.render(sm['controlsState'].alertText2, True, (255,0,0))
alert_line1 = alert1_font.render(sm['controlsState'].alertText1, True, (255, 0, 0))
alert_line2 = alert2_font.render(sm['controlsState'].alertText2, True, (255, 0, 0))
screen.blit(alert_line1, (180, 150))
screen.blit(alert_line2, (180, 190))
@@ -229,7 +229,7 @@ def ui_thread(addr, frame_address):
screen.blit(cameraw_surface, (320, 480))
pygame.surfarray.blit_array(*top_down)
screen.blit(top_down[0], (640,0))
screen.blit(top_down[0], (640, 0))
i = 0
SPACING = 25
+2 -2
View File
@@ -22,12 +22,12 @@ args = parser.parse_args()
pm = messaging.PubMaster(['frame', 'sensorEvents', 'can'])
W,H = 1164, 874
W, H = 1164, 874
def cam_callback(image):
img = np.frombuffer(image.raw_data, dtype=np.dtype("uint8"))
img = np.reshape(img, (H, W, 4))
img = img[:, :, [0,1,2]].copy()
img = img[:, :, [0, 1, 2]].copy()
dat = messaging.new_message('frame')
dat.frame = {
+2 -2
View File
@@ -37,7 +37,7 @@ def can_function(pm, speed, angle, idx, cruise_button=0, is_engaged=False):
msg.append(packer.make_can_msg("GAS_PEDAL_2", 0, {}, idx))
msg.append(packer.make_can_msg("SEATBELT_STATUS", 0, {"SEATBELT_DRIVER_LATCHED": 1}, idx))
msg.append(packer.make_can_msg("STEER_STATUS", 0, {}, idx))
msg.append(packer.make_can_msg("STEERING_SENSORS", 0, {"STEER_ANGLE":angle_to_sangle(angle)}, idx))
msg.append(packer.make_can_msg("STEERING_SENSORS", 0, {"STEER_ANGLE": angle_to_sangle(angle)}, idx))
msg.append(packer.make_can_msg("POWERTRAIN_DATA", 0, {}, idx))
msg.append(packer.make_can_msg("VSA_STATUS", 0, {}, idx))
msg.append(packer.make_can_msg("STANDSTILL", 0, {}, idx))
@@ -63,7 +63,7 @@ def can_function(pm, speed, angle, idx, cruise_button=0, is_engaged=False):
# fill in the rest for fingerprint
done = set([x[0] for x in msg])
for k,v in FINGERPRINTS[CAR.CIVIC][0].items():
for k, v in FINGERPRINTS[CAR.CIVIC][0].items():
if k not in done and k not in [0xE4, 0x194]:
msg.append([k, 0, b'\x00'*v, 0])
pm.send('can', can_list_to_can_capnp(msg))
+4 -4
View File
@@ -167,19 +167,19 @@ def wheel_poll_thread(q):
q.put(str("steer_%f" % normalized))
if mtype & 0x01: # buttons
if number in [0,19]: # X
if number in [0, 19]: # X
if value == 1: # press down
q.put(str("cruise_down"))
if number in [3,18]: # triangle
if number in [3, 18]: # triangle
if value == 1: # press down
q.put(str("cruise_up"))
if number in [1,6]: # square
if number in [1, 6]: # square
if value == 1: # press down
q.put(str("cruise_cancel"))
if number in [10,21]: # R3
if number in [10, 21]: # R3
if value == 1: # press down
q.put(str("reverse_switch"))
+3 -3
View File
@@ -26,8 +26,8 @@ def receiver_thread():
if PYGAME:
pygame.init()
pygame.display.set_caption("vnet debug UI")
screen = pygame.display.set_mode((1164,874), pygame.DOUBLEBUF)
camera_surface = pygame.surface.Surface((1164,874), 0, 24).convert()
screen = pygame.display.set_mode((1164, 874), pygame.DOUBLEBUF)
camera_surface = pygame.surface.Surface((1164, 874), 0, 24).convert()
addr = "192.168.5.11"
if len(sys.argv) >= 2:
@@ -77,7 +77,7 @@ def receiver_thread():
#scipy.misc.imsave("tmp.png", imgff)
pygame.surfarray.blit_array(camera_surface, imgff.swapaxes(0,1))
pygame.surfarray.blit_array(camera_surface, imgff.swapaxes(0, 1))
screen.blit(camera_surface, (0, 0))
pygame.display.flip()
+3 -3
View File
@@ -20,7 +20,7 @@ cam_id = 2
if __name__ == "__main__":
import cv2 # pylint: disable=import-error
trans_webcam_to_eon_front = np.dot(eon_dcam_intrinsics,np.linalg.inv(webcam_intrinsics))
trans_webcam_to_eon_front = np.dot(eon_dcam_intrinsics, np.linalg.inv(webcam_intrinsics))
cap = cv2.VideoCapture(cam_id)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
@@ -29,7 +29,7 @@ if __name__ == "__main__":
while (True):
ret, img = cap.read()
if ret:
img = cv2.warpPerspective(img, trans_webcam_to_eon_front, (1152,864), borderMode=cv2.BORDER_CONSTANT, borderValue=0)
img = img[:,-864//2:,:]
img = cv2.warpPerspective(img, trans_webcam_to_eon_front, (1152, 864), borderMode=cv2.BORDER_CONSTANT, borderValue=0)
img = img[:, -864//2:, :]
cv2.imshow('preview', img)
cv2.waitKey(10)
+3 -3
View File
@@ -24,8 +24,8 @@ webcam_intrinsics = np.array([
if __name__ == "__main__":
import cv2 # pylint: disable=import-error
trans_webcam_to_eon_rear = np.dot(eon_intrinsics,np.linalg.inv(webcam_intrinsics))
trans_webcam_to_eon_front = np.dot(eon_dcam_intrinsics,np.linalg.inv(webcam_intrinsics))
trans_webcam_to_eon_rear = np.dot(eon_intrinsics, np.linalg.inv(webcam_intrinsics))
trans_webcam_to_eon_front = np.dot(eon_dcam_intrinsics, np.linalg.inv(webcam_intrinsics))
print("trans_webcam_to_eon_rear:\n", trans_webcam_to_eon_rear)
print("trans_webcam_to_eon_front:\n", trans_webcam_to_eon_front)
@@ -37,7 +37,7 @@ if __name__ == "__main__":
ret, img = cap.read()
if ret:
# img = cv2.warpPerspective(img, trans_webcam_to_eon_rear, (1164,874), borderMode=cv2.BORDER_CONSTANT, borderValue=0)
img = cv2.warpPerspective(img, trans_webcam_to_eon_front, (1164,874), borderMode=cv2.BORDER_CONSTANT, borderValue=0)
img = cv2.warpPerspective(img, trans_webcam_to_eon_front, (1164, 874), borderMode=cv2.BORDER_CONSTANT, borderValue=0)
print(img.shape, end='\r')
cv2.imshow('preview', img)
cv2.waitKey(10)