Video latency when a PI cam and webcam are running in an opencv application

I executing a python prgm, using opencv version 4.1.1 on a Jetson nano 2gb SOM.
With only 1 camera active:
– pi camera active I get almost zero latency.
– webcam active is about 1.5 seconds of latency

with two(2) camera active:
– pi camera active there is approx. 7.5 latency.
– webcam active there is approx. 1.5 seconds latency

Is it possible to obtain zero sec latency with 2 camera running videos streams.

Warmly,

Bob

Hello @rjaffeco,

Would it be possible for you to share your application code? Or at least a snipped where you run video capture, so we can have a better understanding of your system.

regards,
Andrew
Embedded Software Engineer at ProventusNova

shown below is the python file :

import cv2
print(cv2.version)
dispW=640 # display Width originally set 320 or 640
dispH=480 # display Height originally set 240 or 480
flip=4 # for picture orientation original set to 4 or 2
camSet=‘nvarguscamerasrc ! video/x-raw(memory:NVMM), width=3264, height=2464, format=NV12, framerate=21/1 ! nvvidconv flip-method=’+str(flip)+’ ! video/x-raw, width=‘+str(dispW)+’, height=‘+str(dispH)+’, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink’

piCam=cv2.VideoCapture(camSet) # created pi camera object
webCam=cv2.VideoCapture(1) # webcam

while True: # True
ret, piframe=piCam.read() # grab a frame
ret, webframe=webCam.read()

webframe=cv2.resize(webframe,(640, 480)) # changed from size 
                                                                                # from 3264 x 2464

cv2.imshow('piCam', piframe) # show or display frame

cv2.imshow('webCam', webframe)
cv2.moveWindow('piCam',0,20)
cv2.moveWindow('webCam',650,20)

if cv2.waitKey(1)==ord('q'): # ord q quit
    break

piCam.release() # release camera
webCam.release()
cv2.destoryAllWindows()

Warmly, bob

Boost the system to performance mode to check.
Check the /etc/nvpmodel.conf to find proper mode.

sudo nvpmodel -m <*>
sudo jetson_clocks

[quote=“ShaneCCC, post:5, topic:309035”]

sudo nvpmodel -m <*>
sudo jetson_clocks

executed the above commands had no impact in boosting performance.

Both cameras have exhibited the same video latency as indicated earlier

Thank you Proventus Nova

The code executed that has video latency is shown below:

import cv2
print(cv2.version)
dispW=640 # display Width originally set 320 or 640
dispH=480 # display Height originally set 240 or 480
flip=4 # for picture orientation original set to 4 or 2
camSet=‘nvarguscamerasrc ! video/x-raw(memory:NVMM), width=3264, height=2464, format=NV12, framerate=21/1 ! nvvidconv flip-method=’+str(flip)+’ ! video/x-raw, width=‘+str(dispW)+’, height=‘+str(dispH)+’, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink’

piCam=cv2.VideoCapture(camSet) # created pi camera object
webCam=cv2.VideoCapture(1) # webcam

while True: # True
ret, piframe=piCam.read() # grab a frame
ret, webframe=webCam.read()

webframe=cv2.resize(webframe,(640, 480)) # changed from size 
                                                                                # from 3264 x 2464

cv2.imshow('piCam', piframe) # show or display frame

cv2.imshow('webCam', webframe)
cv2.moveWindow('piCam',0,20)
cv2.moveWindow('webCam',650,20)

if cv2.waitKey(1)==ord('q'): # ord q quit
    break

piCam.release() # release camera
webCam.release()
cv2.destoryAllWindows()

Warmly, bob

Hello @rjaffeco,

Thanks for sharing the code.
I will try to replicate the issue on my end.
I am having issues with my webcam not being detected by my Jetson, will look into that.

In the meantime, have you tried running the same test but using GStreamer only through the terminal?

regards,
Andrew
Embedded Software Engineer at ProventusNova

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.