Ejemplo n.º 1
0
    def test_read_video(self):
        '''test if video can be succesfully read.'''

        fn = os.path.join('project', 'tests', 'test.mp4')
        camera = Camera(path=fn)  # from video
        img = camera.read_video()

        self.assertIsNotNone(img)
Ejemplo n.º 2
0
    def test_take_picture_and_resize(self):
        '''test if we can take a picture and resize it to specific size.'''

        camera = Camera()  # from video source
        shape = (96, 96)
        image = camera.take_picture_and_resize(shape=shape)

        self.assertIsNotNone(image)
        self.assertEqual(image.shape, (96, 96, 3))
        self.assertEqual(image.dtype, np.uint8)
Ejemplo n.º 3
0
    def test_get_picture(self):
        '''Test if Camera can take a picture.'''

        camera = Camera()  # from video source
        image = camera.take_picture()

        self.assertIsNotNone(image)
        self.assertEqual(image.shape,
                         (480, 640, 3))  # dimensions of my webcam images
        self.assertEqual(image.dtype, np.uint8)
Ejemplo n.º 4
0
def take_pic():
    '''take a picture, with the Camera object, send the resulting numpy array.'''

    response_object = {
        'status': 'fail',
        'message': 'Invalid payload.',
        'image': np.zeros((96, 96, 3), dtype=np.uint8).tolist(),
    }

    try:
        image = Camera().take_picture_and_resize()

        response_object = {
            'status': 'success',
            'message': 'image was taken!',
            'image': image.tolist(),
        }

        return jsonify(response_object), 200
    except:
        pass

    return jsonify(response_object), 400
Ejemplo n.º 5
0
def video_feed():
    return Response(gen(Camera()),
                    mimetype='multipart/x-mixed-replace; boundary=frame')
Ejemplo n.º 6
0
 def test_get_frame(self):
     '''Test if Camera.get_frame returns an object.'''
     camera = Camera()
     jpeg_bytes = camera.get_frame()
     self.assertIsNotNone(jpeg_bytes)
Ejemplo n.º 7
0
 def test_create_camera_path_none(self):
     '''Test if Camera can be instantiated for streaming purposes.'''
     camera = Camera()
     self.assertIsNotNone(camera.video)
Ejemplo n.º 8
0
 def test_create_camera_path(self):
     '''Test if Camera can be instantiated from a video file.'''
     fn = os.path.join('project', 'tests', 'test.mp4')
     camera = Camera(path=fn)
     self.assertIsNotNone(camera.video)