finalized changes to ouput ROI frames
This commit is contained in:
parent
0bdea59850
commit
2cb4fb5e70
|
|
@ -6,13 +6,13 @@ from PIL import Image
|
|||
# Opens the Video file
|
||||
video = 'my_face.mov'
|
||||
path_to_script = os.path.dirname(os.path.abspath(__file__))
|
||||
if os.path.exists(path_to_script + r"\frames_testing") == False:
|
||||
os.mkdir(path_to_script + r"\frames_testing")
|
||||
if os.path.exists(path_to_script + r"\frames") == False:
|
||||
os.mkdir(path_to_script + r"\frames")
|
||||
|
||||
def get_frames(vid):
|
||||
cap= cv2.VideoCapture(vid)
|
||||
i=0
|
||||
while i<10:
|
||||
while cap.isOpened():
|
||||
ret, img = cap.read()
|
||||
if ret == False:
|
||||
break
|
||||
|
|
@ -45,10 +45,9 @@ def get_frames(vid):
|
|||
list_eh.append(eh)
|
||||
|
||||
#rectangle on forhead
|
||||
try:
|
||||
fx = min(list_ex) + list_ew[list_ex.index(min(list_ex))]
|
||||
fy = max(list_ey)
|
||||
#extra values in x and y in the parameters are adjustements made after manual testing
|
||||
#cv2.rectangle(roi_color, (fx,fy-150),(fx+100,fy-20),(0,127,255),2)
|
||||
x1 = x + fx
|
||||
x2 = x + fx + 100
|
||||
y1 = y + fy - 150
|
||||
|
|
@ -56,7 +55,12 @@ def get_frames(vid):
|
|||
|
||||
imRGB = img[y1:y2, x1:x2]
|
||||
|
||||
cv2.imwrite('frames_testing/frame'+str(i)+'.jpg',imRGB)
|
||||
cv2.imwrite('frames/frame'+str(i)+'.jpg',imRGB)
|
||||
except:
|
||||
print('error on min value of ex')
|
||||
#extra values in x and y in the parameters are adjustements made after manual testing
|
||||
#cv2.rectangle(roi_color, (fx,fy-150),(fx+100,fy-20),(0,127,255),2)
|
||||
|
||||
i+=1
|
||||
|
||||
cap.release()
|
||||
|
|
|
|||
Loading…
Reference in New Issue