import numpy as np import numpy.typing as npt from matplotlib import pyplot as plt import cv2 import uz_framework.image as uz_image import uz_framework.text as uz_text import os ############################################## # EXCERCISE 1: Exercise 1: Image derivatives # ############################################## def ex1(): one_b() def one_a() -> None: """ d = (f * px)/pz + f(T - px)/pz => d = (f * T) / pz """ def one_b() -> None: """ Write a script that computes the disparity for a range of values of pz. Plot the values to a figure and set the appropriate units to axes. Use the following parameters of the system: focal length is f = 2.5mm and stereo system baseline is T = 12cm """ pz_values = np.arange(0.001, 0.1, 0.001) f = 0.0025 T = 0.12 d = (f * T) / pz_values plt.plot(pz_values, d) plt.xlabel('pz [m]') plt.ylabel('d [m]') plt.title('Disparity for a range of values of pz') plt.show() def one_c() -> None: """ In order to get a better grasp on the idea of distance and disparity, you will calculate the numbers for a specific case. We will take the parameters from a specification of a commercial stereo camera Bumblebee2 manufactured by the company PointGray: f = 2.5mm, T = 12cm, whose image sensor has a resolution of 648×488 pixels that are square and the width of a pixel is 7.4µm. We assume that there is no empty space between pixels and that both cameras are completely parallel and equal. Lets say that we use this system to observe a (point) object that is detected at pixel 550 in x axis in the left camera and at the pixel 300 in the right camera. How far is the object (in meters) in this case? How far is the object if the object is detected at pixel 540 in the right camera? Solve this task analytically and bring your solution to the presentation of the exercise. """ # ######## # # SOLUTION # # ######## # def main(): ex1() #ex2() #ex3() if __name__ == '__main__': main()