This is the complete program that combines everything we have learned! It captures data, calculates speed using two methods, decides which one is best, and saves the result.
We import libraries like SenseHat for sensors, Camera for taking photos, ISS for orbit info, and cv2 (OpenCV) for image processing. We also set up some constants like RAIO_TERRA (Earth radius).
calcular_distancia_coords uses the Haversine formula. This is a special math way to measure distance on a sphere (like Earth) given two points (latitude/longitude).
We use a loop to grab the ISS coordinates 10 times, waiting 10 seconds between each grab. This gives us a path of points over time.
Another loop takes 10 photos, also 10 seconds apart. We save their filenames so we can analyze them later.
We calculate the speed between each pair of coordinates (Distance / Time). Then we find the median (middle value) to ignore any weird errors.
This is the advanced part! We use OpenCV’s ORB to find "key points" (like corners) in each photo. We match these points between two photos to see how far the ground moved in pixels. We convert pixels to km using KM_POR_PIXEL and calculate speed.
We compare the two speeds. If the photo speed is close to the coordinate speed (within 1 km/s), we trust it. Otherwise, we stick to the coordinate speed as a backup. Finally, we write the answer to result.txt.