Exemple #1
0
    def define_location(window: Window):
        current_img = window.get_screenshot_from_window()
        location_path = "data/locations/"
        location_files = []
        for dir_path, dir_names, file_names in walk(location_path):
            for file_name in file_names:
                location_files.append((file_name.split(".")[0], location_path + file_name))

        current_location = min(map(lambda location: (location[0], Actions.compare_images(current_img, location[1])),
                                   location_files), key=lambda obj: obj[1])
        current_location = current_location[0] if current_location[1] <= 10 else None

        """
        print(current_location)
        for location_file in location_files:
            compare = Actions.compare_images(current_img, location_file[1])
            if compare <= 9:
                current_location = location_file[0]
            print(location_file[0], compare)
        """

        print(f"Current location: {current_location}")
Exemple #2
0
from common.window import Window
if os.getenv("BIG") is not None:
  from common.transformations.model import BIGMODEL_INPUT_SIZE as MEDMODEL_INPUT_SIZE
  from common.transformations.model import get_camera_frame_from_bigmodel_frame as get_camera_frame_from_medmodel_frame
else:
  from common.transformations.model import MEDMODEL_INPUT_SIZE
  from common.transformations.model import get_camera_frame_from_medmodel_frame

from common.transformations.camera import FULL_FRAME_SIZE, eon_intrinsics

from tools.replay.lib.ui_helpers import CalibrationTransformsForWarpMatrix

if __name__ == "__main__":
  sm = messaging.SubMaster(['liveCalibration'])
  frame = messaging.sub_sock('frame', conflate=True)
  win = Window(MEDMODEL_INPUT_SIZE[0], MEDMODEL_INPUT_SIZE[1], double=True)
  calibration = None

  while 1:
    fpkt = messaging.recv_one(frame)
    if len(fpkt.frame.image) == 0:
      continue
    sm.update(timeout=1)
    rgb_img_raw = fpkt.frame.image
    imgff = np.frombuffer(rgb_img_raw, dtype=np.uint8).reshape((FULL_FRAME_SIZE[1], FULL_FRAME_SIZE[0], 3))
    imgff = imgff[:, :, ::-1] # Convert BGR to RGB

    if sm.updated['liveCalibration']:
      intrinsic_matrix = eon_intrinsics
      img_transform = np.array(fpkt.frame.transform).reshape(3,3)
      extrinsic_matrix = np.asarray(sm['liveCalibration'].extrinsicMatrix).reshape(3, 4)
Exemple #3
0
  SCALE = 2
  XMIN, XMAX = 0, 1927
  YMIN, YMAX = 0, 1207
else:
  SCALE = 1
  XMIN = 771
  XMAX = 1156
  YMIN = 483
  YMAX = 724
H, W = ((YMAX-YMIN+1)//SCALE, (XMAX-XMIN+1)//SCALE)

if __name__ == '__main__':
  cameras = ['roadCameraState', 'wideRoadCameraState', 'driverCameraState']
  if "CAM" in os.environ:
    cam = int(os.environ['CAM'])
    cameras = cameras[cam:cam+1]
  sm = messaging.SubMaster(cameras, addr=sys.argv[1])
  win = Window(W*len(cameras), H)
  bdat = np.zeros((H, W*len(cameras), 3), dtype=np.uint8)

  while 1:
    sm.update()
    for i,k in enumerate(cameras):
      if sm.updated[k]:
        #print("update", k)
        bgr_raw = sm[k].image
        dat = np.frombuffer(bgr_raw, dtype=np.uint8).reshape(H, W, 3)[:, :, [2,1,0]]
        bdat[:, W*i:W*(i+1)] = dat
    win.draw(bdat)

Exemple #4
0
import win32gui
import win32ui
import win32con
import win32api
import cv2
import numpy as np
from PIL import Image
import pywinauto
import time
from common.actions import Actions
from common.window import Window

w = Window()

#img = w.get_screenshot_from_window()
#Actions.save_image(img, "data/locations/map_outskirts.bmp")
#patt = cv2.imread("icon.png", 0)
#click_point = Actions.find_patt(img, patt)
#w.mouse_click(*click_point)

while True:
    Actions.define_location(w)