study

meet

GitHub Nemolite study

Qmenu

Хабр Qt6

КП Урок

ИИУрок 7

mysql+table

 

pip install flask flask-sqlalchemy

pip install PyMySql

pip install mysqlclient

ИИ (Глава 8 стр.387)

doc AI (стр 326)

doc1  

doc2

bat-файлы

CTkinter

doc

key

vid

openCV

jup

txt

doc

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)
 # ==============================================================
import pymysql

# Подключение к БД
connection = pymysql.connect(
    host='localhost',  # хост (обычно localhost)
    port=3306,  # порт (по умолчанию 3306)
    user='root',  # имя пользователя
    password='1111',  # пароль
    database='basa2',  # имя базы данных
    charset='utf8mb4'  # кодировка для русских букв
)

try:
    with connection.cursor() as cursor:
        # Выполняем запрос
        cursor.execute("SELECT VERSION()")

        # Получаем результат (одну строку)
        version = cursor.fetchone()
        print(f"Версия MySQL: {version[0]}")
finally:
    connection.close()
 =================================
# Словари

dict1 = {"host":"localhost",
        "name_basa":"basa",
        "login":"root",
        "password":1111,
         "kkey1":1

}
# print(dict1)
# print(dict1["login"])
# print(dict1["password"])

# print(dict1.get("kkey1"))
# print(dict1.get("kkey1",0))

# del dict1["kkey1"]
#
# print(dict1)

a = dict1.pop("kkey1")
print(a)
print(dict1)

b = dict1.pop("password",34535)
print(b)

dict3 = dict1.copy()

print(dict3)
print(dict1)
dict1.pop("login")
print(dict3)
print(dict1)
dict7 =dict3.update(dict1)
print(dict7)

dict2 = {
    "key1":"value1",
    "key2":"value2",
    "key3":"value3",
    "key4":"value4",
    "key5":"value5"
}

dict2.update(dict1)
print(dict2)

# 1 -  и ключи и значения
# 2 - только знаачеия
# 3 - только ключи

#
# for k,v in dict2.items():
#     print(k,v)
#
# for v in dict2.values():
#     print(v)
#
# for k in dict2.keys():
#     print(k)

=================================
from tkinter import *
from tkinter import ttk
import pymysql

def cursor_db():

    # Подключение к БД
    connection = pymysql.connect(
        host='localhost',  # хост (обычно localhost)
        port=3306,  # порт (по умолчанию 3306)
        user='root',  # имя пользователя
        password='1111',  # пароль
        database='basa2',  # имя базы данных
        charset='utf8mb4'  # кодировка для русских букв
    )

    if connection:
       return connection
    else:
        connection

root = Tk()
root.title("Работа с БД")
root.geometry("500x500")
label = ttk.Label(text="Передача данных в таблицу indef БД def", font=("Arial", 14))
label.pack()


def send_to_bd():
    connection = cursor_db()
    cursor = connection.cursor()
    id = int(entry_id.get())
    Name = entry_Name.get()
    print(id,Name)
    sql = f"INSERT INTO basa2.stud (Id, Name) VALUES ({id}, \"{Name}\")"
    print(sql)
    cursor.execute(sql)
    connection.commit()

# label for id
entry_id = ttk.Entry()
entry_id.pack(anchor=NW, padx=6, pady=6)

# label for Name
entry_Name = ttk.Entry()
entry_Name.pack(anchor=NW, padx=6, pady=6)

btn = ttk.Button(text="Click", command=send_to_bd)
btn.pack(anchor=NW, padx=6, pady=6)
# basa2 stud

root.mainloop()
 

Наши координаты

Мы используем cookie-файлы для наилучшего представления нашего сайта. Продолжая использовать этот сайт, вы соглашаетесь с использованием cookie-файлов.
Принять