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)
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)
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)
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
def video_feed(): return Response(gen(Camera()), mimetype='multipart/x-mixed-replace; boundary=frame')
def test_get_frame(self): '''Test if Camera.get_frame returns an object.''' camera = Camera() jpeg_bytes = camera.get_frame() self.assertIsNotNone(jpeg_bytes)
def test_create_camera_path_none(self): '''Test if Camera can be instantiated for streaming purposes.''' camera = Camera() self.assertIsNotNone(camera.video)
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)