Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: 2 python apps #639

Merged
merged 2 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import cv2
import mediapipe as mp
import time

cap = cv2.VideoCapture(0)
pTime = 0

mpFaceDetection = mp.solutions.face_detection
mpDraw = mp.solutions.drawing_utils
faceDetection = mpFaceDetection.FaceDetection(0.75)

while True:
success, img = cap.read()

imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
results = faceDetection.process(imgRGB)
print(results)

if results.detections:
for id, detection in enumerate(results.detections):
# mpDraw.draw_detection(img, detection)
# print(id, detection)
# print(detection.score)
# print(detection.location_data.relative_bounding_box)
bboxC = detection.location_data.relative_bounding_box
ih, iw, ic = img.shape
bbox = int(bboxC.xmin * iw), int(bboxC.ymin * ih),
int(bboxC.width * iw), int(bboxC.height * ih)
cv2.rectangle(img, bbox, (255, 0, 255), 2)
cv2.putText(img, f'{int(detection.score[0] * 100)}%',
(bbox[0], bbox[1] - 20), cv2.FONT_HERSHEY_PLAIN,
2, (255, 0, 255), 2)

cTime = time.time()
fps = 1 / (cTime - pTime)
pTime = cTime
cv2.putText(img, f'FPS: {int(fps)}', (20, 70), cv2.FONT_HERSHEY_PLAIN,
3, (0, 255, 0), 2)
cv2.imshow("Image", img)
cv2.waitKey(1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import random

class Codec:

def encode(self, l):
pre,post= l.split('//')
pre+='//'
uri=post.split('/')
domain=uri[0]+'/'
uri.pop(0)
url='/'.join(uri)
n = random.randint(47890665,99999999)
self.dic={}
self.dic['pre']=pre
self.dic['domain']=domain
self.dic[str(n)] = url
s=str(pre)+'tinyurl.com/'+str(n)
return s


def decode(self, s):
tst,n=s.split('.com/')
ans=self.dic['pre']+self.dic['domain']+self.dic[str(n)]
return an