почему ето не работает вообще не в каком виде
# import the necessary packages
import cv2
import numpy as np
import smtplib
# initialize the video stream
cap = cv2.VideoCapture(“car.mp4”)
# loop over the frames of the video
while True:
# grab the current frame
ret, frame = cap.read()
# if the frame could not be grabbed, then we have reached the end of the video
if not ret:
break
# convert the frame to grayscale, blur it, and detect edges
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
edged = cv2.Canny(blurred, 50, 150)
# find contours in the edge map
cnts = cv2.findContours(edged.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = imutils.grab_contours(cnts)
# loop over the contours
for c in cnts:
# compute the center of the contour
M = cv2.moments©
cX = int(M / M)
cY = int(M / M)
# compute the bounding box for the contour and draw it
(x, y, w, h) = cv2.boundingRect©
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
# compute the speed of the car
speed = compute_speed(x, y, w, h)
# if the speed is greater than 60 km/h, send an email
if speed > 60:
# send the speed data to the server
send_data_to_server(speed)
# send an email
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(“your_email_address@gmail.com”, “your_password”)
msg = “The speed of the car is ” + str(speed) + “ km/h”
server.sendmail(“your_email_address@gmail.com”, “recipient_email_address@gmail.com”, msg)
server.quit()
# release the video stream
cap.release()