Giter Club home page Giter Club logo

Comments (15)

peugas avatar peugas commented on July 18, 2024

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.

kyamagu avatar kyamagu commented on July 18, 2024

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.

amroamroamro avatar amroamroamro commented on July 18, 2024

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.

peugas avatar peugas commented on July 18, 2024

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.

amroamroamro avatar amroamroamro commented on July 18, 2024

@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.

peugas avatar peugas commented on July 18, 2024

No, I'm able to change the FPS on MATLAB, Cheese and guvcview.

from mexopencv.

amroamroamro avatar amroamroamro commented on July 18, 2024

@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.

peugas avatar peugas commented on July 18, 2024

Ok, I'll try to do that and post the results.
thanks

from mexopencv.

amroamroamro avatar amroamroamro commented on July 18, 2024

@peugas: did you succeed in setting the FPS from OpenCV? It should be simple to write some C++ code to check this..

from mexopencv.

peugas avatar peugas commented on July 18, 2024

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.

amroamroamro avatar amroamroamro commented on July 18, 2024

@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.

peugas avatar peugas commented on July 18, 2024

@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.

amroamroamro avatar amroamroamro commented on July 18, 2024

@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.

amroamroamro avatar amroamroamro commented on July 18, 2024

@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.

kyamagu avatar kyamagu commented on July 18, 2024

@peugas, @amroamroamro,

Thanks for all the debugging effort. As it seems to be a driver problem, I'd close this issue.

from mexopencv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.