I am trying to do the science fair, And one of the parts is that I need to do the object count, But it is kinda tricky, Here's the code:
from imutils.video import FPS
import argparse
import imutils
import time
import cv2
tracker = cv2.LBPHRecognizer_create()
vs = cv2.VideoCapture(0)
initBB = None
while vs.isOpened():
ret,frame = vs.read()
cv2.line(frame, (933 , 462), (1170 , 462), (0,0,255), 3)
if initBB is not None:
(success, box) = tracker.update(frame)
if success:
(x, y, w, h) = [int(v) for v in box]
cv2.rectangle(frame, (x, y), (x + w, y + h),
(0, 255, 0), 2)
cX = int((x + x+w) / 2.0)
cY = int((y + y+h) / 2.0)
cv2.circle(frame, (cX, cY), 4, (255, 0, 0), -1)
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("s"):
initBB = cv2.selectROI("Frame", frame, fromCenter=False,
showCrosshair=True)
tracker.init(frame, initBB)
fps = FPS().start()
elif key == ord("q"):
break
else:
vs.release()
cv2.destroyAllWindows()
And it is basically not running, Here's the error code:
File "g:/資優班/科展/程式碼/HOG-real-time-test.py", line 8, in <module>
tracker = cv2.LBPHRecognizer_create()
AttributeError: module 'cv2.cv2' has no attribute 'LBPHRecognizer_create'
I've tried searching the fixing ways, But it all doesn't help me, I think Maybe it is the OpenCV-python version problem, But still now sure and also still don't know how to fix, I'm kinda in a rush, Pls help me, masters, Thank you!