Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
  2.  
  3. faces = CascadeClassifier.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5)
  4.  
  5. for (x, y, w, h) in faces:
  6. print(x,y,w,h)
  7. roi_gray = gray[y:y+h, x:x+w]
  8.  
  9. roi_color = gray[y:y+h, x:x+w]
  10.  
  11. img_item = 'image.png'
  12. cv2.imwrite(img_item, roi_gray)
  13. # Our operations on the frame come here
  14.  
  15. color = (255,0,0) #BGR 0=255
  16.  
  17. stroke = 2
  18.  
  19.  
  20. end_cord_x = x + w
  21.  
  22. end_cord_y = y + h
  23.  
  24. cv2.rectangle(frame, (x, y), (end_cord_x, end_cord_y), color, stroke)
  25.  
  26. # Display the resulting frame
  27. cv2.imshow('frame',frame)
  28. if cv2.waitKey(20) & 0xFF == ord('q'):
  29. break
  30.  
  31. # When everything done, release the capture
  32. cap.release()
  33. cv2.destroyAllWindows()
  34.  
  35. File "camera-test.py", line 34, in <module>
  36. end_cord_x = x + w
  37. NameError: name 'x' is not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement