diff --git a/tools/webcam/jetson_test_cam.py b/tools/webcam/jetson_test_cam.py index 0b9610c70c152d..21ed4a8907f900 100755 --- a/tools/webcam/jetson_test_cam.py +++ b/tools/webcam/jetson_test_cam.py @@ -2,9 +2,8 @@ import numpy as np import time import sys -import pygame -from pygame.locals import * from selfdrive.car.tesla.readconfig import CarSettings +from PIL import Image if __name__ == "__main__": import cv2 @@ -15,45 +14,30 @@ " videoscale ! video/x-raw,width=%d,height=%d !" " appsink ") cs = CarSettings() - #cs.roadCameraID - #cs.driverCameraID if len(sys.argv) != 2: cam = str(sys.argv) else: cam = sys.argv[1] if cam == "road" or cam == "driver": print ("Processing camera [%s]\n" % cam) - pygame.init() - pygame.display.set_caption("OpenPilot Jetson camera stream on Pygame") if cam == "road": strm = strm_template % (cs.roadCameraID, 800, 600, 20, 1164,874) - screen = pygame.display.set_mode([1164,874]) else: strm = strm_template % (cs.driverCameraID, 640, 480, 10, 1152,864) - screen = pygame.display.set_mode([1152,864]) print("Capturing with stream [%s}\n" % strm) cap = cv2.VideoCapture(strm) i = 0 try: while True: - ret, frame = cap.read() + ret, img = cap.read() if ret: if i == 0: - print(frame.shape+'\r') - screen.fill([0,0,0]) - frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) - frame = frame.swapaxes(0,1) - frame = pygame.surfarray.make_surface(frame) - screen.blit(frame, (0,0)) - pygame.display.update() - - for event in pygame.event.get(): - if event.type == KEYDOWN: - sys.exit(0) - i = (i + 1) % 20 + print(img.shape,end='\r') + cv2.imshow('preview',img) + cv2.waitKey(1) except (KeyboardInterrupt, SystemExit): - pygame.quit() cv2.destroyAllWindows() else: print ("\nUnknown arguments %s\n" % str(sys.argv)) + print ("When using over ssh make sure you start seesion with 'ssh -Y user@jetson'\n") print ("Usage: %s road|driver\n" % sys.argv[0])