Challenge - 5 Problems
Optical Flow Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Calculate displacement from optical flow data
Given the optical flow vectors detected by a drone's downward camera, what is the resulting displacement in meters after processing the flow data for 1 second?
Assume the drone's altitude is 2 meters, and the optical flow sensor reports pixel shifts that translate to velocity components as shown in the code.
Assume the drone's altitude is 2 meters, and the optical flow sensor reports pixel shifts that translate to velocity components as shown in the code.
Drone Programming
altitude = 2.0 # meters flow_x = 0.1 # meters/second flow_y = -0.05 # meters/second time_seconds = 1 displacement_x = flow_x * time_seconds displacement_y = flow_y * time_seconds print(f"Displacement X: {displacement_x} m") print(f"Displacement Y: {displacement_y} m")
Attempts:
2 left
💡 Hint
Multiply the velocity components by the time to get displacement.
✗ Incorrect
Displacement is velocity multiplied by time. Here, flow_x and flow_y are velocities in meters per second, so multiplying by 1 second gives the displacement directly.
🧠 Conceptual
intermediate1:30remaining
Understanding optical flow limitations indoors
Which of the following is the main challenge when using optical flow sensors for indoor positioning of drones?
Attempts:
2 left
💡 Hint
Think about what optical flow needs to detect movement.
✗ Incorrect
Optical flow relies on detecting changes in visual features. Uniform surfaces indoors often lack distinct features, making it hard to track movement accurately.
🔧 Debug
advanced2:30remaining
Fix the error in optical flow velocity calculation
The following code attempts to calculate the velocity from optical flow pixel shifts and altitude, but it raises an error. Identify the cause and select the correct fixed code.
Drone Programming
pixel_shift_x = 15 pixel_shift_y = 10 altitude = 3.0 focal_length = 2.5 velocity_x = pixel_shift_x * altitude / focal_length velocity_y = pixel_shift_y * altitude / focal_length print(f"Velocity X: {velocity_x}") print(f"Velocity Y: {velocity_y}")
Attempts:
2 left
💡 Hint
Check the operators used for division and multiplication.
✗ Incorrect
The original code is correct and does not raise an error. Options A, C, and D change the formula incorrectly or use integer division which can cause wrong results.
📝 Syntax
advanced2:00remaining
Identify the syntax error in optical flow data processing
Which option contains a syntax error when trying to create a dictionary of pixel shifts mapped to their velocities?
Drone Programming
pixel_shifts = {'x': 12, 'y': 8}
altitude = 2.5
focal_length = 3.0
velocities = {axis: pixel_shifts[axis] * altitude / focal_length for axis in pixel_shifts}
print(velocities)Attempts:
2 left
💡 Hint
Check the syntax of the for loop in the dictionary comprehension.
✗ Incorrect
Option C is missing the 'in' keyword in the for loop of the dictionary comprehension, causing a syntax error.
🚀 Application
expert3:00remaining
Calculate total distance traveled using optical flow data
A drone collects optical flow velocity data every second for 5 seconds as follows (in meters/second): [0.1, 0.15, 0.12, 0.13, 0.20]. What is the total distance traveled in meters after 5 seconds?
Attempts:
2 left
💡 Hint
Sum all velocities and multiply by the time interval (1 second each).
✗ Incorrect
Total distance = sum of velocities * time interval. Sum is 0.1+0.15+0.12+0.13+0.20 = 0.70 meters.