Comments (15)
This is my code:
camera1 = cv.VideoCapture(0);
camera2 = cv.VideoCapture(1);
pause(2);
figure
subplot(1,2,1);
frame1 = camera1.read;
h1 = imshow(frame1);
subplot(1,2,2);
frame2 = camera2.read;
h2 = imshow(frame2);
from mexopencv.
Can you do the same in C++? I don't know what is the reason, but VideoCapture is not super stable all the time in my impression. For example, in my environment (OS X 10.8.2, Matlab r2011a, OpenCV 2.4.3), I need to wait a few seconds before I start to read an image. It can be a driver issue, OpenCV issue, or a Matlab issue. If it works in C++ program, probably it's an issue in a dynamic loader.
from mexopencv.
check that both video captures were opened successfully:
camera1 = cv.VideoCapture(0);
camera2 = cv.VideoCapture(1);
pause(2)
camera1.isOpened()
camera2.isOpened()
It is known that running multiple simultaneous webcams can be bandwidth-consuming. I came across this problem before, here's an example from someone else: http://pastebin.com/yhYXpHbj
If it's the case, try to capture images at a lower resolution with less frequent frame rate (see the camera.set('prop',val)
function)
from mexopencv.
I set the image size to a lower resolution and I manage to capture from both cameras.
So my cameras were flooding bus.
I tried to change the fps rate and confirming the changed value by:
camera1.set('FPS', 10)
camera1.get('FPS')
and all I got was -1
(I tried more values than 10 and the result was the same)
any idea why?
from mexopencv.
@peugas: probably means your webcam doesn't support changing the FPS..
This is a limitation of your hardware or OpenCV itself, but its not a mexopencv bug..
I think the issue can be closed now
from mexopencv.
No, I'm able to change the FPS on MATLAB, Cheese and guvcview.
from mexopencv.
@peugas: could it be that OpenCV is using a different driver to access the webcam?
Just to confirm, create a simple C++ program (linking against OpenCV directly), and try setting and retrieving the FPS in there... If that doesn't work, file a bug to OpenCV developers
from mexopencv.
Ok, I'll try to do that and post the results.
thanks
from mexopencv.
@peugas: did you succeed in setting the FPS from OpenCV? It should be simple to write some C++ code to check this..
from mexopencv.
My C++ skills are very limited (or close to none) so I wasn't able to do that.
I'll try to find a good tutorial to help me through that.
from mexopencv.
@peugas: here's an example you can try: http://pastebin.com/Q9FZ1aVV
It calls the get/set functions as specified in the docs
from mexopencv.
@amroamroamro: thanks a lot for the example.
I've compiled the example and this was the output:
VIDIOC_QUERYMENU: Invalid argument
...
VIDIOC_QUERYMENU: Invalid argument
HIGHGUI ERROR: V4L2: Unable to get property <unknown property string>(5) - Invalid argument old FPS = -1
HIGHGUI ERROR: V4L: Property <unknown property string>(5) not supported by device
HIGHGUI ERROR: V4L2: Unable to get property <unknown property string>(5) - Invalid argument new FPS = -1
libv4l2: error turning on stream: No space left on device
VIDIOC_STREAMON: No space left on device
libpng warning: Image width is zero in IHDR
libpng warning: Image height is zero in IHDR
libpng error: Invalid IHDR data
By the "No space left on device" I assume that it is a bandwidth problem but there's still the -1fps.
I've manage to preview both cameras under MATLAB lowering the image size to 320x240 and frame rate to 10fps but not with mexopencv.
I've changed your example to change the image resolution and it didn't work.
It seems like I'm not able to change my webcam settings with OpenCV or mexopencv.
from mexopencv.
@peugas:
According to the error message, as far as OpenCV is concerned "setting the FPS is not supported by your device".
It appears to be using the Video4Linux API underneath... (error originates from this line)
Perhaps you should file a bug with OpenCV devs at: http://code.opencv.org/projects/opencv/issues/new
from mexopencv.
@kyamagu, @peugas:
i believe it is ok to close this issue. As the c++ test showed, the error is not originating from mexopencv side (rather driver, opencv, or one of its dependencies)
from mexopencv.
Thanks for all the debugging effort. As it seems to be a driver problem, I'd close this issue.
from mexopencv.
Related Issues (20)
- Mexopencv using MatLab Runtime
- Using homebrew to install OpenCV==3.4.1
- windows opencv3.4.1 cmake
- Setting up mexopencv for matlab 2018b HOT 2
- No output from cv.getBuildInformation() in Octave 5.1.0
- maybe bug about the queryIdx and trainIdx
- ld: symbol(s) not found for architecture x86_64
- Invalid MEX-file : Missing dependent shared libraries
- [error 3] gcc >= 4.4 g++ >= 4.4 is installed
- v3.2.0 and xfeatures2d HOT 1
- mexopencv not compiling HOT 2
- error in setup opencv and mexopencv
- how Mac to mexopencv HOT 1
- [lib/mexopencv_features2d.o] Error 255 HOT 1
- MxArray::toMoments out of order arguments to cv::Moments
- Consider leveraging MATLAB in your CI
- MATLAB Error: Unrecognized function or variable 'FeaturesFinder_'.
- why can't I use the 'cv.detectMarkers' function???
- Hi all, I have a big problem when I am using matlab R2021a to builed mexopencv. HOT 1
- mexopencv building error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mexopencv.