예제 #1
0
import re
import math

import cv2
import numpy as np

from tests.utils import list_files, ImageAssertionHelper
import design.vision.vertices as vertices
import design.vision.exceptions as exceptions

SAMPLE_IMAGES = list(list_files('samples'))
CONTOURS_NUMBER_BY_ONBOARD_IMAGES_NAME_PATTERNS = {
    re.compile('boot.*'):
    np.array([[[140, 28]], [[245, 30]], [[243, 253]], [[192,
                                                        253]], [[191, 213]],
              [[151, 253]], [[37, 251]], [[38, 211]], [[139, 130]]]),
    re.compile('/arrow.*'):
    np.array([[[237, 38]], [[152, 120]], [[265, 190]], [[197, 263]],
              [[121, 152]], [[46, 222]], [[51, 39]]]),
    re.compile('inverted_arrow.*'):
    np.array([[[261, 45]], [[262, 232]], [[179, 151]], [[108, 264]],
              [[34, 194]], [[146, 120]], [[75, 45]]]),
    re.compile('hat.*'):
    np.array([[[123, 60]], [[149, 78]], [[176, 61]], [[205, 180]], [[242,
                                                                     171]],
              [[230, 227]], [[68, 224]], [[50, 171]], [[88, 178]]]),
    re.compile('m(_\d+)?\.(jpg|png)'):
    np.array([[[283, 226]], [[208, 226]], [[201, 134]], [[149, 186]],
              [[98, 136]], [[88, 227]], [[16, 223]], [[84, 69]], [[213, 68]]]),
    re.compile('house.*'):
    np.array([[[40, 153]], [[147, 46]], [[182, 80]], [[239, 80]], [[240, 137]],
예제 #2
0
 def setUpClass(self):
     self.instructions = list(
         map(lambda f: f[:-2],
             list_files('tests/instructions', extension='.s')))
import json
import os.path as path

import cv2
import pytest

from design.vision.obstacles_detector import ObstaclesDetector
from tests.utils import (ImageAssertionHelper, list_files)

WORLD_CAMERA_SAMPLES_PATH = path.join('samples', 'world_camera_samples')
SAMPLE_IMAGES = list_files(
    WORLD_CAMERA_SAMPLES_PATH, lambda filename: filename.endswith(
        ('.png', '.jpg', '.jpeg')))
SAMPLE_JSON = list_files(WORLD_CAMERA_SAMPLES_PATH,
                         lambda filename: filename.endswith(('.json')))
SAMPLES_IMAGES_AND_JSON = dict(zip(SAMPLE_IMAGES, SAMPLE_JSON))


@pytest.mark.skip(reason='The images can not be extracted')
def test_that_given_images_with_obstacles_when_find_obstacles_positions_then_all_obstacles_positions_are_found(
):
    image_assertion_helper = ImageAssertionHelper(
        0.12)  # 0.12 is the maximum error percentage (so min is 87)
    obstacles_detector = ObstaclesDetector()

    for image_path, json_path in SAMPLES_IMAGES_AND_JSON.items():

        obstacles_coordinates = []
        found_obstacles_coordinates = []
        image = cv2.imread(image_path)