def test_camera_image():
    '''
    Tests reading an image from a camera sensor. The image is saved locally
    '''
    CounterFitConnection.init('127.0.0.1', 5000)
    image_data = CounterFitConnection.read_binary_sensor('Picamera')

    with open('test_image.png', 'wb') as image_file:
        image_file.write(image_data.read())
Esempio n. 2
0
    def capture(self, output, image_format=None):
        '''
        Capture an image from the camera, storing it in *output*.
        '''
        # read the image from Counterfit
        raw_image = CounterFitConnection.read_binary_sensor('Picamera')
        raw_image.seek(0)

        image = Image.open(raw_image)

        if self.__rotation > 0:
            image = image.rotate(self.__rotation, expand=True)

        if self.__width > 0 and self.__height > 0:
            image = self.__resize_and_crop(image)

        image.save(output, format=image_format)