Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIDIOC_QUERYMENU: Invalid argument #2

Closed
vincentsaluzzo opened this issue Aug 19, 2013 · 8 comments
Closed

VIDIOC_QUERYMENU: Invalid argument #2

vincentsaluzzo opened this issue Aug 19, 2013 · 8 comments

Comments

@vincentsaluzzo
Copy link

Hi,

I try to make a little program with the example to take screenshot with my webcam.
I have installed OpenCV and I write this piece of code :

var camera = require('camera');
var fs = require('fs');

var webcam = camera.createStream();

webcam.on('data', function(buffer) {
    fs.writeFileSync('cam.jpg', buffer);
    webcam.destroy();
});

when I execute this code, I have an error :

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
/home/pi/babycamble/node_modules/camera/lib/main.coffee:1038: Uncaught TypeError: Cannot call method 'toBuffer' of null

and no image was save... a solution ?

@yocontra
Copy link
Owner

Can you try making writeFileSync async (writeFile) and destroy when it is done writing? I think the underlying opencv binding might not be handling something right here

@vincentsaluzzo
Copy link
Author

I will test but the problem seems not appear inside the callback of webcam.on ('data', function ... but when the createStream was called...

@yocontra
Copy link
Owner

In the README: "createStream optionally takes a camera number and defaults to 0 for the main camera"

Can you try passing in a different number to createStream? It's possible you have a "camera" attached to your computer (physically or virtually) that is messing this up by identifying as your main camera when it isn't

@vincentsaluzzo
Copy link
Author

Ok so I have try to pass an another index to createStream (1, 2, etc.) but it seems not resolved the problem :

HIGHGUI ERROR: V4L: index 1 is not correct!

/home/pi/babycamble/node_modules/camera/lib/main.coffee:30
  cam = new cv.VideoCapture(idx);
        ^
Error: Camera could not be opened
    at Object.module.exports.createStream (/home/pi/babycamble/node_modules/camera/lib/main.coffee:30:13)
    at Object.<anonymous> (/home/pi/babycamble/opencv.js:4:21)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

I have also try to remove the line for writing image to filesystem but the problem always appear...

@yocontra
Copy link
Owner

What type/model camera do you have plugged in? The data coming back from it is not playing well with OpenCV

@yocontra
Copy link
Owner

Okay so it looks that error is in fact coming from a camera compatibility issue. Try another camera or open an issue against OpenCV

@vincentsaluzzo
Copy link
Author

Okay, this error isn't it ! But it sound like a bug because your library don't use the last VideoCapture API of OpenCV.

--> Changelog

And your seems correct the problem in your last commit ! I will try your last commit now...

@vincentsaluzzo
Copy link
Author

Ok, so with your last modification, you've correct the problem ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants