https://github.com/kipr/opencv/tree/master/data/haarcascades

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'tehnikum',
'USER': 'root',
'PASSWORD': '1111',
'HOST': 'localhost',
'PORT': '3306',
}
}
====
import cv2 import numpy as np cap = cv2.VideoCapture("videos/Road.mp4") while True: success, img = cap.read() if not success: break # img = cv2.resize(img, (img.shape[1] // 2, img.shape[0] // 2)) # 1. Размытие по Гауссу (убирает шум) img = cv2.GaussianBlur(img, (9, 9), 0) # 2. Перевод в оттенки серого img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # 3. Выделение границ (контуров) методом Кэнни img = cv2.Canny(img, 200, 200) # 4. Создание ядра для морфологических операций kernel = np.ones((5, 5), np.uint8) # 5. Расширение (утолщение линий) img = cv2.dilate(img, kernel, iterations=1) # 6. Сжатие (эрозия — утончение линий) img = cv2.erode(img, kernel, iterations=1) cv2.imshow('Result', img) # Ожидание нажатия клавиши (в оригинале урока строка ниже) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows() =========================================
import sys
import pygame
pygame.init()
screen = pygame.display.set_mode((500, 500))
clock = pygame.time.Clock()
WHITE = (255, 255, 255)
BLUE = (0, 0, 255)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
screen.fill(WHITE)
pole = pygame.draw.rect(screen, BLUE,(130,130,234,234))
button1 = pygame.draw.rect(screen, (0, 255, 0), (140, 140, 70, 70))
button2 =pygame.draw.rect(screen, (0, 255, 0), (212, 140, 70, 70))
button3 =pygame.draw.rect(screen, (0, 255, 0), (284, 140, 70, 70))
button4 =pygame.draw.rect(screen, (0, 255, 0), (140, 212, 70, 70))
button5 =pygame.draw.rect(screen, (0, 255, 0), (212, 212, 70, 70))
button6 =pygame.draw.rect(screen, (0, 255, 0), (284, 212, 70, 70))
button7 =pygame.draw.rect(screen, (0, 255, 0), (140, 284, 70, 70))
button8 =pygame.draw.rect(screen, (0, 255, 0), (212, 284, 70, 70))
button9 =pygame.draw.rect(screen, (0, 255, 0), (284, 284, 70, 70))
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1 and button1.collidepoint(event.pos):
pygame.draw.line(screen, (0, 0, 0),
(button1.left, button1.top),
(button1.right, button1.bottom), 3)
pygame.draw.line(screen, (0, 0, 0),
(button1.right, button1.top),
(button1.left, button1.bottom), 3)
pygame.display.flip()
clock.tick(60)
