I trying to stream a webcam parallel process method. One of the function shows an error libv4l2 resource busy. Tried with using a narrow delay between the functions it's works fine. And when i use two camera it's also works. I think the problem with the settings of the libv4l2 or something. How solve this issue ?
import threading
from threading import Thread
import cv2
import numpy as np
def func1():
video = cv2.VideoCapture(0)
success, image = video.read()
print success
def func2():
video = cv2.VideoCapture(0)
success, image = video.read()
print success
if __name__ == '__main__':
Thread(target = func1).start()
Thread(target = func2).start()
And it's output like this.
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
libv4l2: error setting pixformat: Device or resource busy
HIGHGUI ERROR: libv4l unable to ioctl S_FMT
libv4l2: error setting pixformat: Device or resource busy
libv4l1: error setting pixformat: Device or resource busy
HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT
False
True
Firstly I would highly recommend to check if your device i.e. the web-cam does provide the parallel input/ouput control at all.
Apparently it doesn't because you get the input/ouput control command failures
HIGHGUI ERROR: libv4l unable to ioctl S_FMT
HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT
You have to implement another abstraction layer which will do the splitting/duplication of the video stream for you. But not on device level as you are doing it now.
Similar problem has been discussed and resolved here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With