-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61d182e
commit 188b062
Showing
1 changed file
with
8 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,22 @@ | ||
import cv2 | ||
|
||
class Video(object): | ||
def __init__(self): | ||
self.video=cv2.VideoCapture(0) | ||
self.count=0 | ||
def __del__(self): | ||
self.video.release() | ||
def get_frame(self): | ||
ret,frame=self.video.read() | ||
ret,jpg=cv2.imencode('.jpg',frame) | ||
ret,frame=self.video.read() | ||
ret,jpg=cv2.imencode('.jpg',frame,Compress(50)) | ||
self.count +=1 | ||
|
||
return jpg.tobytes() | ||
|
||
|
||
|
||
|
||
|
||
def Compress(value): | ||
return [int(cv2.IMWRITE_JPEG_QUALITY), value] | ||
|
||
|
||
|
||
|
||
# import fractions | ||
# import cv2 | ||
|
||
# video=cv2.VideoCapture(0) | ||
|
||
# faceDetect=cv2.CascadeClassifier('haarcascade_frontalface_default.xml') | ||
# print(faceDetect) | ||
# while True: | ||
# ret,frame=video.read() | ||
# print(ret) | ||
# positions=faceDetect.detectMultiScale(frame,1.3,5) | ||
# for x,y,w,h in positions: | ||
# cv2.rectangle(frame,(x,y),(x+w,y+h),(255,0,255),2) | ||
# cv2.imshow('Frame',frame) | ||
# k=cv2.waitKey(1) | ||
# if k==ord('q'): | ||
# break | ||
# video.release() | ||
# cv2.destroyAllWindows() |