def main(): aspect_ratio = 1 height = 256 width = int(height * aspect_ratio) # round name = "test.png" wrapper = ImageWrapper(name, width, height) red = Lambertian(Vector3(1, 0, 0)) green = Lambertian(Vector3(0.2, 1, 0.1)) camera = Camera(Vector3(0, 0, 0), Vector3(0, 1, 0), Vector3(0, 0, 1), 1, 90) spheres = [ Sphere(Vector3(0, 10, 0), 5, red), Sphere(Vector3(0, 10, -100), 95, green) ] samples = 50 for y in range(height): for x in range(width): final_color = Vector3(0, 0, 0) for sample in range(samples): ray = camera.generate_ray((x + random.random()) / width, (y + random.random()) / height) color = get_intersection(ray, spheres, MAX_DEPTH) final_color += color final_color /= samples wrapper.write_pixel(x, y, final_color) wrapper.save()
def __init__(self, name): super().__init__(name) self.camera = Camera((-self.display.get_width()//2, -self.display.get_height()//2), 7) self.camera_follow = None #set this to an object with a .pos to have the camera follow it self.render_list = [] #render relitive to camera self.ui_render_list = [] #render without camera interference self.keydict = {pygame.K_ESCAPE:self.quit}
ccd_height = args.ccd_width / aspect_ratio # in this system we force fx == fy, but here fy computed separately # just for fun. fx = focal_len_mm * width / args.ccd_width fy = focal_len_mm * height / ccd_height else: print("Cannot autodetect calibrated focal length, please specify a ccd-width") quit() print('ccd: %.3f x %.3f' % (ccd_width, ccd_height)) print('fx fy = %.2f %.2f' % (fx, fy)) cu = width * 0.5 cv = height * 0.5 print('cu cv = %.2f %.2f' % (cu, cv)) cam = Camera.Camera() cam.set_defaults() cam.set_meta(make, model, lens_model) cam.set_lens_params(ccd_width, ccd_height, focal_len_mm) cam.set_K(fx, fy, cu, cv) cam.set_image_params(width, height) if os.path.exists(camera_file): print("Camera config file already exists:", camera_file) if args.force: print("Overwriting ...") else: print("Use [ --force ] to overwrite ...") quit() print("Saving:", camera_file)
#from lib.Sensor import* load = Solenoid(21) shoot = Solenoid(19) load.block() shoot.block() INPUT_PIN = 36 GPIO.setup(INPUT_PIN, GPIO.IN) #Port 8 : RX green PB0 #Port 10: TX yellow PB1 #serial0 - ttyAMA0 #serial1 - ttyS0 os.system("sudo modprobe bcm2835-v4l2") base = Base() base.step_left(197) camera = Camera(base) #sensor = Sensor() ser = serial.Serial("/dev/ttyS0", 57600) #Open port with baud rate dist_0 = 48 dist_1 = 58 dist_2 = 64 dist_3 = 72 dist_4 = 80 def launch(): # block off both solenoids load.block()