Ejemplo n.º 1
0
    def sense_and_act(self):

        if self.bbcon.can_take_photo:
            print("Taking photo!")
            image_obj = self.c_sensob.update()
            img = Imager(image=image_obj)
            img.dump_image('/')

            self.match_degree = 0.9

            triple2 = [0] * 3
            for x in range(img.xmax):
                for y in range(img.ymax):
                    t = img.get_pixel(x, y)
                    for i in range(len(triple2)):
                        triple2[i] += t[i]

            print("RGB", triple2)
            print(triple2[0] > triple2[1] and triple2[0] > triple2[2])

            if triple2[0] > triple2[1] and triple2[0] > triple2[2]:
                self.motor_recommendations = ['t']

            else:
                self.motor_recommendations = ['f']
                self.bbcon.photo_taken()

            self.priority = 0.9
Ejemplo n.º 2
0
def camTest():
    ZumoButton().wait_for_press()
    sensor = Camera(img_width=128, img_height=96, img_rot=0) #endre disse?
    sensor2 = Camera(img_width=256, img_height=192, img_rot=0)
    sensor3 = Camera(img_width=512, img_height=384, img_rot=0)
    sensor4 = Camera(img_width=1024, img_height=768, img_rot=0)


    sensor.update()
    sensor2.update()
    sensor3.update()
    sensor4.update()
    pic = sensor.get_value()
    pic2 = sensor2.get_value()
    pic3 = sensor3.get_value()
    pic4 = sensor4.get_value()
    b = Imager()
    b.image = pic
    b.dump_image("test", type="JPEG") #dump as jpeg/jpg/gif?
    b.image = pic2
    b.dump_image("test2", type="JPEG")
    b.image = pic3
    b.dump_image("test3", type="JPEG")
    b.image = pic4
    b.dump_image("test4", type="JPEG")
Ejemplo n.º 3
0
	def update(self):
		image = self.sensor.update()
		if False: # True = save image
			img = Imager(image=image)
			img.dump_image("img.jpeg")
		self.value = self.analyze_picture(image)
Ejemplo n.º 4
0
 def take_picture(self):
     im = Imager(image=self.sensors[0].update()).scale(1,1)  #Takes the picture.
     im.dump_image('red_image.jpeg')                         #Stores the picture.