注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
海投被捞的, 特斯拉research engineer, 40分钟一到类似OA里面的
求加米继续看面经- Problem
- -------
- You're writing a function to select indices of frames given a clip of the car driving.
-
- We want to select frames that are separated *spatially* based on the movement of the car
- (as measured in cumulative arc-length). For example, every 5 meters apart. We've already
- computed the trajectory for the car, which you have available as a list of (x, y) points with
- an arbitrary non-zero distance between each consecutive point.
-
- [[x_0, y_0],
- [x_1, y_1],
- [x_2, y_2],
- ...
- [x_n, y_n]] <-- current location of the car
-
- The car is currently at the last location in the trajectory.
-
- Additionally you have a list of desired strides, in terms of how many meters ago we want each
- frame to be. For example, it will look something like:
-
- [25.0, 20.0, 15.0, 10.0, 5.0, 0.0]
- ^ furthest frame ^ current frame
-
- This list is always monotonically decreasing (furthest away frame first, closest frame last).
- Furthermore, the list is guaranteed to end with 0.0, i.e. the current frame.
-
- Your task is: for each desired stride, find the index of the frame that's closest to being the
- correct distance away. But if the difference between the desired distance and the closest
- match we can find ends up >= TOL (defined as a constant 1.0 meters below), then return -1 for
- that frame instead (to denote invalid).
-
- Example (1-d)
- -------------
- >>> trajectory = [
- [0, 11.0], # <-- 2.0m ago (matches against desired stride 2.0)
- [0, 10.5], # <-- 1.5m ago
- [0, 10.6], # <-- 1.4m ago
- [0, 11.1], # <-- 0.9m ago (matches against desired stride 1.0)
- [0, 12.0]] # <-- current index = 4 # <-- 0.0m ago (matches against desired stride 0.0)
- >>> desired_strides = [3.5, 2.0, 1.0, 0.0]
- >>> select_indices(trajectory, desired_strides)
- [-1, 0, 3, 4]
-
- Implementation
- --------------
-
- 1) Write an implementation of select_indices. Numpy is optional. O(N * M) is acceptable.
- 2) Write an implementation of select_indices_batched using Numpy. O(B * N * M) is acceptable.
- It should have no loops.
-
- N = length of trajectory
- M = length of desired_strides
-
- Feel free to use the internet. You are encouraged to run the code and use the unit tests to debug.
-
- Important Note
- --------------
- By *cumulative arc-length* we mean that if you travel in a circle, you've traveled cumulatively
- some non-zero distance even though the start point and end point are exactly the same.
-
- Special cases
- -------------
- - Can the same frame be selected by multiple desired strides?
- Answer: Yes! (Assuming it's the closest frame to both desired strides, AND the tolerance is met).
-
- - Can two frames be exactly the same distance away (in terms of cumulative arc-length)?
- Answer: No. You can assume the arclength traveled between two consecutive frames is > 0.01.
- """
- import numpy as np
- from typing import List
-
-
复制代码 |