## mvmt[m:m+30] = 0 mvmt2 = np.zeros(mvmt.shape[0]) for m in range(0,mvmt.shape[0]-30): mvmt2[m] = np.mean(mvmt[np.where(mvmt[m:m+30]>0)[0]+m]) mvmt2 = (mvmt2 - np.mean(mvmt2))/np.std(mvmt2) for m in range(0,mvmt.shape[0]): if mvmt2[m]>3: mvmt2[m]/=3 if mvmt2[m]<0: mvmt2[m]=0 cam = my_video_capture(video_file_loc + \ "Timm~Katrina_497a1ff8-9b6f-4868-bd2d-752c6b86e192_0078_2.avi", 30) cam = my_video_capture(video_file_loc + \ "Lori~Grigor_a2f52bb6-db8b-4f4f-9763-344db14ef2ce_0027_2.avi", 30) frame_cnt = 1 while cam.has_next(): plt.figure(figsize=(6.4, 0.5), dpi = 10) plt.plot(range(mvmt2.shape[0]), mvmt2, mew=0.1) plt.ylim([0,4]) plt.axis('off') plt.text(0.1,1,"Movement\n levels\n", ha='right', \ va = 'center', fontsize=10) marker_on = frame_cnt-15 plt.plot(marker_on, 2, marker = '|', mew=2, markersize=100) plt.savefig(output_file_loc + "tmp.png", dpi = 100)
cascade_fns.append( args.get( "--cascade", "C:\\Python27\\lib\\site-packages\\pyESig\\vid\\haarcascades\\haarcascade_profileface.xml", ) ) nested_fn = args.get( "--cascade", "C:\\Python27\\lib\\site-packages\\pyESig\\vid\\haarcascades\\haarcascade_eye.xml" ) # cascade_fn = args.get('--cascade', "C:\\Python27\\lib\\site-packages\\pyESig\\vid\\haarcascades\\Mouth.xml") for cascade_fn in cascade_fns: cascades.append(cv2.CascadeClassifier(cascade_fn)) nested = cv2.CascadeClassifier(nested_fn) cam = my_video_capture(video_src, 4) frame_cnt = 0 while cam.has_next(): print "video:" + str(n) + " || frame:" + str(frame_cnt) faces = [] for i in xrange(4): if cam.has_next(): img = cam.read() detected, face = crop_face(cascades, img) face = cv2.resize(face, (32, 32)) if detected == True: faces.append(face) if len(faces) > 3: cv2.imwrite( "D:\\face\\" + sbj_id + "_" + day + "\\" + num + "_" + str(frame_cnt) + "_1.png", faces[0] )
cascade_fns.append( args.get( '--cascade', "C:\\Python27\\lib\\site-packages\\pyESig\\vid\\haarcascades\\haarcascade_profileface.xml" )) nested_fn = args.get( '--cascade', "C:\\Python27\\lib\\site-packages\\pyESig\\vid\\haarcascades\\haarcascade_eye.xml" ) #cascade_fn = args.get('--cascade', "C:\\Python27\\lib\\site-packages\\pyESig\\vid\\haarcascades\\Mouth.xml") for cascade_fn in cascade_fns: cascades.append(cv2.CascadeClassifier(cascade_fn)) nested = cv2.CascadeClassifier(nested_fn) cam = my_video_capture(video_src, 4) frame_cnt = 0 while cam.has_next(): print "video:" + str(n) + " || frame:" + str(frame_cnt) faces = [] for i in xrange(4): if cam.has_next(): img = cam.read() detected, face = crop_face(cascades, img) face = cv2.resize(face, (32, 32)) if (detected == True): faces.append(face) if (len(faces) > 3): cv2.imwrite( "D:\\face\\" + sbj_id + "_" + day + "\\" + num + "_" + str(frame_cnt) + "_1.png", faces[0])
mvmt2[m] = np.mean(mvmt[np.where(mvmt[m:m+30]>0)[0]+m]) mvmt2 = (mvmt2 - np.mean(mvmt2))/np.std(mvmt2) for m in range(0,mvmt.shape[0]): if mvmt2[m]>3: mvmt2[m]/=3 if mvmt2[m]<0: mvmt2[m]=0 cam = my_video_capture(video_file_loc + \ "_0145_2.avi", 30) frame_cnt = 1 while cam.has_next(): plt.figure(figsize=(6.4, 0.5), dpi = 10) plt.plot(range(mvmt2.shape[0]), mvmt2, mew=0.1) plt.ylim([0,4]) plt.axis('off') plt.text(0.1,1,"Movement\n levels\n", ha='right', \ va = 'center', fontsize=10) marker_on = frame_cnt-15 plt.plot(marker_on, 2, marker = '|', mew=2, markersize=100) plt.savefig(output_file_loc + "tmp.png", dpi = 100)
mvmt2[m] = np.mean(mvmt[np.where(mvmt[m:m+30]>0)[0]+m]) mvmt2 = (mvmt2 - np.mean(mvmt2))/np.std(mvmt2) for m in range(0,mvmt.shape[0]): if mvmt2[m]>3: mvmt2[m]/=3 if mvmt2[m]<0: mvmt2[m]=0 cam = my_video_capture(video_file_loc + \ "Timm~Katrina_497a1ff8-9b6f-4868-bd2d-752c6b86e192_0145_2.avi", 30) frame_cnt = 1 while cam.has_next(): plt.figure(figsize=(6.4, 0.5), dpi = 10) plt.plot(range(mvmt2.shape[0]), mvmt2, mew=0.1) plt.ylim([0,4]) plt.axis('off') plt.text(0.1,1,"Movement\n levels\n", ha='right', \ va = 'center', fontsize=10) marker_on = frame_cnt-15 plt.plot(marker_on, 2, marker = '|', mew=2, markersize=100) plt.savefig(output_file_loc + "tmp.png", dpi = 100)
for m in range(0, mvmt.shape[0] - 30): mvmt2[m] = np.mean(mvmt[np.where(mvmt[m:m + 30] > 0)[0] + m]) mvmt2 = (mvmt2 - np.mean(mvmt2)) / np.std(mvmt2) for m in range(0, mvmt.shape[0]): if mvmt2[m] > 3: mvmt2[m] /= 3 if mvmt2[m] < 0: mvmt2[m] = 0 cam = my_video_capture(video_file_loc + \ "Timm~Katrina_497a1ff8-9b6f-4868-bd2d-752c6b86e192_0145_2.avi", 30) frame_cnt = 1 while cam.has_next(): plt.figure(figsize=(6.4, 0.5), dpi=10) plt.plot(range(mvmt2.shape[0]), mvmt2, mew=0.1) plt.ylim([0, 4]) plt.axis('off') plt.text(0.1,1,"Movement\n levels\n", ha='right', \ va = 'center', fontsize=10) marker_on = frame_cnt - 15 plt.plot(marker_on, 2, marker='|', mew=2, markersize=100) plt.savefig(output_file_loc + "tmp.png", dpi=100) img = cam.read()
## if np.where(mvmt[m:m+30] > 1.1)[0].shape[0] < 5: ## mvmt[m:m+30] = 0 mvmt2 = np.zeros(mvmt.shape[0]) for m in range(0, mvmt.shape[0] - 30): mvmt2[m] = np.mean(mvmt[np.where(mvmt[m:m + 30] > 0)[0] + m]) mvmt2 = (mvmt2 - np.mean(mvmt2)) / np.std(mvmt2) for m in range(0, mvmt.shape[0]): if mvmt2[m] > 3: mvmt2[m] /= 3 if mvmt2[m] < 0: mvmt2[m] = 0 cam = my_video_capture(video_file_loc + \ "497a1ff8-9b6f-4868-bd2d-752c6b86e192_0078_2.avi", 30) cam = my_video_capture(video_file_loc + \ "_a2f52bb6-db8b-4f4f-9763-344db14ef2ce_0027_2.avi", 30) frame_cnt = 1 while cam.has_next(): plt.figure(figsize=(6.4, 0.5), dpi=10) plt.plot(range(mvmt2.shape[0]), mvmt2, mew=0.1) plt.ylim([0, 4]) plt.axis('off') plt.text(0.1,1,"Movement\n levels\n", ha='right', \ va = 'center', fontsize=10) marker_on = frame_cnt - 15 plt.plot(marker_on, 2, marker='|', mew=2, markersize=100) plt.savefig(output_file_loc + "tmp.png", dpi=100)
## mvmt[m:m+30] = 0 mvmt2 = np.zeros(mvmt.shape[0]) for m in range(0,mvmt.shape[0]-30): mvmt2[m] = np.mean(mvmt[np.where(mvmt[m:m+30]>0)[0]+m]) mvmt2 = (mvmt2 - np.mean(mvmt2))/np.std(mvmt2) for m in range(0,mvmt.shape[0]): if mvmt2[m]>3: mvmt2[m]/=3 if mvmt2[m]<0: mvmt2[m]=0 cam = my_video_capture(video_file_loc + \ "497a1ff8-9b6f-4868-bd2d-752c6b86e192_0078_2.avi", 30) cam = my_video_capture(video_file_loc + \ "_a2f52bb6-db8b-4f4f-9763-344db14ef2ce_0027_2.avi", 30) frame_cnt = 1 while cam.has_next(): plt.figure(figsize=(6.4, 0.5), dpi = 10) plt.plot(range(mvmt2.shape[0]), mvmt2, mew=0.1) plt.ylim([0,4]) plt.axis('off') plt.text(0.1,1,"Movement\n levels\n", ha='right', \ va = 'center', fontsize=10) marker_on = frame_cnt-15 plt.plot(marker_on, 2, marker = '|', mew=2, markersize=100) plt.savefig(output_file_loc + "tmp.png", dpi = 100)
for m in range(0, mvmt.shape[0] - 30): mvmt2[m] = np.mean(mvmt[np.where(mvmt[m:m + 30] > 0)[0] + m]) mvmt2 = (mvmt2 - np.mean(mvmt2)) / np.std(mvmt2) for m in range(0, mvmt.shape[0]): if mvmt2[m] > 3: mvmt2[m] /= 3 if mvmt2[m] < 0: mvmt2[m] = 0 cam = my_video_capture(video_file_loc + \ "_0145_2.avi", 30) frame_cnt = 1 while cam.has_next(): plt.figure(figsize=(6.4, 0.5), dpi=10) plt.plot(range(mvmt2.shape[0]), mvmt2, mew=0.1) plt.ylim([0, 4]) plt.axis('off') plt.text(0.1,1,"Movement\n levels\n", ha='right', \ va = 'center', fontsize=10) marker_on = frame_cnt - 15 plt.plot(marker_on, 2, marker='|', mew=2, markersize=100) plt.savefig(output_file_loc + "tmp.png", dpi=100) img = cam.read()