我有以下文字:
import cv2
import numpy as np
import pickle
cam = cv2.VideoCapture(0);
faceDetect = cv2.CascadeClassifier('haarcascade_frontalface_default.xml');
id = raw_input('Enter user Name')
sampleNo = 0;
while(True):
ret,img = cam.read();
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = faceDetect.detectMultiScale(gray, 1.3, 5);
for(x,y,w,h) in faces:
sampleNo = sampleNo+1;
cv2.imwrite("dataSet/"+str(id)+"_" +str(sampleNo)+ ".jpg", gray[y:y+h, x:x:w])
cv2.rectangle(img,(x,y),(x+w, y+h), (0,0,0), 2)
cv2.waitKey(100);
cv2.imshow("Face", img);
cv2.waitKey(1);
if(sampleNo > 20):
break;
cam.release()
cv2.destroyAllWindows()
我想在每一行都得到匹配,直到最后一个不是空格的字符 这就是我想要的:
aa
bb cc
dd
ee ff gg
我试着遵循:
Match until the next (and not the last) space after a specific pattern
并使用:
aa
bb cc
dd
ee ff gg
但它没有帮助。