Skip to content

Commit b02e8b2

Browse files
authored
Add files via upload
1 parent 0e3fc9e commit b02e8b2

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

mypy.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# import simplejson as json
2+
# import os
3+
4+
import requests
5+
6+
r = requests.get('https://google.com')
7+
print("Status", r.status_code)
8+
9+
# if os.path.isfile("./ages.json") and os.stat("./ages.json").st_size != 0:
10+
# old_file = open("./ages.json", "r+")
11+
# data = json.loads(old_file.read())
12+
# print("Current age is", data["age"], "--- adding a year.")
13+
# data["age"] = data["age"] + 1
14+
# print("New age is", data["age"])
15+
16+
# else:
17+
# old_file = open("./ages.json", "w+")
18+
# data = {"name": "Nick", "age": 27}
19+
# print("No file found, setting default age to", data["age"])
20+
21+
# old_file.seek(0)
22+
# old_file.write(json.dumps(data))
23+
24+
# newfile = open("newfile.txt", "wr+")
25+
26+
# string = "This is a new file created by python"
27+
28+
# newfile.write(string)
29+
# newfile.read(string)

opencv.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# OpenCV Python program to detect cars in video frame
2+
# import libraries of python OpenCV
3+
import cv2
4+
5+
# capture frames from a video
6+
cap = cv2.VideoCapture('video.avi')
7+
8+
# Trained XML classifiers describes some features of some object we want to detect
9+
car_cascade = cv2.CascadeClassifier('cars.xml')
10+
11+
# loop runs if capturing has been initialized.
12+
while True:
13+
# reads frames from a video
14+
ret, frames = cap.read()
15+
16+
# convert to gray scale of each frames
17+
gray = cv2.cvtColor(frames, cv2.COLOR_BGR2GRAY)
18+
19+
# Detects cars of different sizes in the input image
20+
cars = car_cascade.detectMultiScale(gray, 1.1, 1)
21+
22+
# To draw a rectangle in each cars
23+
for (x, y, w, h) in cars:
24+
cv2.rectangle(frames, (x, y), (x + w, y + h), (0, 0, 255), 2)
25+
26+
# Display frames in a window
27+
cv2.imshow('video2', frames)
28+
29+
# Wait for Esc key to stop
30+
if cv2.waitKey(33) == 27:
31+
break
32+
33+
# De-allocate any associated memory usage
34+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)