OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Why? Opencv to detect faces from IP cameras via MJPEG protocol. Very slow?

  • Thread starter Thread starter Hiến Dương Đức
  • Start date Start date
H

Hiến Dương Đức

Guest
I use Opencv to detect faces from IP cameras via MJPEG protocol. Very slow? Here is my code. We hope you can help. Is there any way to do it faster? Or did I do something wrong? My IP camera views data from live MJPEG very quickly. But when using Opencv it is slow, very slow!

Code:
cap = cv2.VideoCapture('http://root:[email protected]/mjpeg')
cap.set(cv2.CAP_PROP_FPS, 30)
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc('m', 'j', 'p', 'g'))
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc('M', 'J', 'P', 'G'))
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)

while True:
    ret, frame = cap.read()

    cv2.imshow('mjpeg', frame)
    img = recognize(frame, clf, faceCascade)

    frames = cv2.imencode('.jpg', img)[1].tobytes()
    yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + frames + b'\r\n')

    key = cv2.waitKey(1)
    if key == 27:
        break

I have used different versions of opencv, but still very slow
<p>I use Opencv to detect faces from IP cameras via MJPEG protocol. Very slow? Here is my code. We hope you can help. Is there any way to do it faster? Or did I do something wrong? My IP camera views data from live MJPEG very quickly. But when using Opencv it is slow, very slow!</p>
<pre class="lang-py prettyprint-override"><code>cap = cv2.VideoCapture('http://root:[email protected]/mjpeg')
cap.set(cv2.CAP_PROP_FPS, 30)
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc('m', 'j', 'p', 'g'))
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc('M', 'J', 'P', 'G'))
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)

while True:
ret, frame = cap.read()

cv2.imshow('mjpeg', frame)
img = recognize(frame, clf, faceCascade)

frames = cv2.imencode('.jpg', img)[1].tobytes()
yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + frames + b'\r\n')

key = cv2.waitKey(1)
if key == 27:
break
</code></pre>
<p>I have used different versions of opencv, but still very slow</p>
 

Latest posts

I
Replies
0
Views
1
impact christian
I
Top