<jupyter_start><jupyter_text>Generate DataTraining the SVM with the given data (car and non-car) led to many false positives. The false positives mainly occured at the left kerbside. A few of the false positives might be caused by actual cars from the opposing lane. Most are not, though. Another reason could be, that there is not enough training data for this particular situations. In this notebook we therefore try to extract more "non-vehicle" data.<jupyter_code>import matplotlib.pyplot as plt
import random
import cv2
from moviepy.editor import VideoFileClip
counter = 0
def process_image(img):
    global counter
    sample_width = 64
    sample_height = 64
    wh_min = 64
    wh_max = 128
    x_min = 0
    x_max = 500
    y_min = 400
    y_max = 700
    
    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    
    for i in range(5):
        w = h = random.randint(wh_min, wh_max)
        x = random.randint(x_min, x_max-w)
        y = random.randint(y_min, y_max-h)

        crop_img = img[y:y + h, x:x + w]
        out_img = cv2.resize(crop_img, (sample_width, sample_height))
        name = 'data/non-vehicles/Extracted/image{}.png'.format(counter)
        cv2.imwrite(name, out_img)
        counter += 1
clip = VideoFileClip('../project_video.mp4').subclip(0,10)

for frame in clip.iter_frames():
    process_image(frame)
    
print('{} images extracted!'.format(counter))<jupyter_output>1250 images extracted!
{'fraction_non_alphanumeric': 0.09007741027445461, 'fraction_numerical': 0.025334271639690358, 'mean_word_length': 3.309090909090909, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '145223', 'license': 'MIT', 'n_tokens_mistral': 493, 'n_tokens_neox': 462, 'n_words': 148, 'path': 'classifier/GenerateData.ipynb', 'repo_name': 'akrost/CarND-VehicleDetection', 'size': '1421'}