c++ - Multiple cameras and using cv::VideoCapture::set() to set frame size results in libv4l2 error "No space left on device" -
i have 2 logitech pro 9000 webcams. have discovered unusual behaviour in cv::videocapture::set() when setting frame size (width , height) captures resulting in infamous error
libv4l2: error turning on stream: no space left on device vidioc_streamon: no space left on device error: not read video stream
for sec camera. in order prepare have cut down frame size 2 times initial one. here interesting thing:
version 1 (without using cv::videocapture::set()) - manage both cameras , running @ 15fps (i tried 20fps error have mentioned above) resolution of 640x480, seems sort of hidden default cameras (i unable find in source code of cv::videocapture set) if don't specify these. 2 values retrieved using cv::videocapture::get(cv_cap_prop_frame_width) , cv::videocapture::get(cv_cap_prop_frame_height) respectively. here little example:
// indices 1 , 2 since 0 built-in webcam (i'm using notebook) cv::videocapture cap1(1); cv::videocapture cap2(2); if(!cap1.isopened()) { std::cout << "cannot open video cam [1]" << std::endl; homecoming -1; } if(!cap2.isopened()) { std::cout << "cannot open video cam [2]" << std::endl; homecoming -1; } // set both cameras 15fps cap1.set(cv_cap_prop_fps, 15); cap2.set(cv_cap_prop_fps, 15); double dwidth1 = cap1.get(cv_cap_prop_frame_width); double dheight1 = cap1.get(cv_cap_prop_frame_height); double dwidth2 = cap2.get(cv_cap_prop_frame_width); double dheight2 = cap2.get(cv_cap_prop_frame_height); // here display frame size opencv has picked me - 640x480 both cameras std:: cout << "cam[1] frame size: " << dwidth1 << " x " << dheight1 << std::endl; std::cout << "cam[2] frame size: " << dwidth2 << " x " << dheight2 << std::endl; cv::namedwindow("cam[1]",cv_window_autosize); cv::namedwindow("cam[2]",cv_window_autosize); while(1) { cv::mat frame1, frame2; bool bsuccess1 = cap1.read(frame1); bool bsuccess2 = cap2.read(frame2); if (!bsuccess1) { std::cout << "cannot read frame video stream [1]" << std::endl; break; } if (!bsuccess2) { std::cout << "cannot read frame video stream [2]" << std::endl; break; } cv::imshow("cam[1]", frame1); cv::imshow("cam[2]", frame2); if(cv::waitkey(30) == 27) { std::cout << "esc key pressed user" << std::endl; break; } }
this illustration working without issues.
version 2 (using cv::videocapture::set()) - if take exact same values retrieve using cv::videocapture::get() , utilize them cv::videocapture::set() setup exact same parameters above mentioned error occurs:
cv::videocapture cap1(1); cv::videocapture cap2(2); if(!cap1.isopened()) { std::cout << "cannot open video cam [1]" << std::endl; homecoming -1; } if(!cap2.isopened()) { std::cout << "cannot open video cam [2]" << std::endl; homecoming -1; } cap1.set(cv_cap_prop_fps, 15); cap2.set(cv_cap_prop_fps, 15); // values taken output of version 1 , used setup exact same parameters exact same values! cap1.set(cv_cap_prop_frame_width, 640); cap1.set(cv_cap_prop_frame_height, 480); cap2.set(cv_cap_prop_frame_width, 640); cap2.set(cv_cap_prop_frame_height, 480); cv::namedwindow("cam[1]",cv_window_autosize); cv::namedwindow("cam[2]",cv_window_autosize); while(1) { cv::mat frame1, frame2; bool bsuccess1 = cap1.read(frame1); bool bsuccess2 = cap2.read(frame2); if (!bsuccess1) { std::cout << "cannot read frame video stream [1]" << std::endl; break; } if (!bsuccess2) { std::cout << "cannot read frame video stream [2]" << std::endl; break; } cv::imshow("cam[1]", frame1); cv::imshow("cam[2]", frame2); if(cv::waitkey(30) == 27) { std::cout << "esc key pressed user" << std::endl; break; } }
the more verbose error output is
cam[1] frame size: 640 x 480 cam[2] frame size: 640 x 480 init done opengl back upwards available libv4l2: error turning on stream: no space left on device vidioc_streamon: no space left on device cannot read frame video stream [2]
in order create work have cut down frame's width , height of both cameras 352x288 @ 15fps, not acceptable.
has experienced such unusual behaviour and/or know solution?
edit discovered code works without problems on windows.
c++ opencv webcam-capture
No comments:
Post a Comment