= gtsam.Point3(-3,0,5) # point at the feet of the person, 5 meters in front of camera, 3 meters to the left
feet = gtsam.Point3(-3,-2,5) # point at the top of the head (note, Y = *minus* 2 meters)
head = 1 # meter
F = plane(-F) + [ray(feet, -F), ray(head, -F)] + axes())) show_3d(go.Figure(data
diffdrive
Differential Drive Chapter
Our simulated differential drive robot has a camera, so a lot of the code here is support for some computer vision.
Pinhole Figures
Some plotting support code to illustrate the pinhole camera model.
show_3d
show_3d (fig)
ray
ray (point3, F, color='orange')
plane
plane (Z:float)
axes
axes (length=1.5)
Add axes to a plotly figure
= plane(F) + [ray(feet, F), ray(head, F)] + axes())) show_3d(go.Figure(data
Reading Images
read_image
read_image (image_name)
Read image from a the book repo
= "LL_color_1201754063.387872.bmp"
image_name = read_image(image_name) # locally: PIL.Image.open(image_name)
image print(f"resolution = {image.width}x{image.height}")
resolution = 512x384
import matplotlib.pyplot as plt
; plt.imshow(image)
from PIL import ImageOps
= PIL.ImageOps.grayscale(image)
grayscale_image ="gray"); plt.imshow(grayscale_image, cmap
Easy Convolution
conv2
conv2 (input, filter)
Convolve input image of shape (iW,iH) with filter of shape (kW,kH)
= torch.from_numpy(np.asarray(grayscale_image, dtype=float))
grayscale print(f"type={type(grayscale)}, dtype={grayscale.dtype}, shape={grayscale.shape}")
filter = torch.tensor([[-1.0, 0.0, 1.0]], dtype=float)
filter.shape
type=<class 'torch.Tensor'>, dtype=torch.float64, shape=torch.Size([384, 512])
torch.Size([1, 3])
= conv2(grayscale, filter)
vertical_edges ="RdYlGn"); plt.imshow(vertical_edges, cmap