How to overcome error VIDIOC_QUERYMENU: Invalid argument in OpenCV?

There is such code:
import cv,time

cv.NamedWindow("webcam", 1)

cam = cv.CaptureFromCAM(-1)


feed = cv.QueryFrame(cam)
cv.ShowImage("webcam", feed)

time.sleep(2);

The picture with the camera does not get
Videt 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


Tried to change on cv.CaptureFromCAM(0).
Code:
import cv2
cam = cv2.VideoCapture(-1)

Gives the same error
July 9th 19 at 13:14
1 answer
July 9th 19 at 13:16
Solution
And you what version do you use?
An example tutorial from Opencv 2.4 I have to start with polpinka:
# -*- coding: utf-8 -*-
import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
 # Capture frame-by-frame
 ret, frame = cap.read()

 # Our operations on the frame come here
 gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

 # Display the resulting frame
cv2.imshow('frame',gray)
 if cv2.waitKey(1) & 0xFF == ord('q'):
break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
Version 2.4.8, trying to compile version 3. But run into different errors. I want to run on Armagh. (single-Board computer Odroid)
What would the robot moved from sign to sign at the camera.
This code returns the same error... - Dolly_Kuvalis37 commented on July 9th 19 at 13:19
: 3 version I flew. IMHO - for your card is more stable than the 2.4.x
I tried on 2.4.12 - Nathan_Gaylord commented on July 9th 19 at 13:22
: thanks for the reply. It worked) - Dolly_Kuvalis37 commented on July 9th 19 at 13:25
: Got what I wanted
https://youtu.be/YuSX1VfMrK4 - Dolly_Kuvalis37 commented on July 9th 19 at 13:28
: super! What we need :) - Nathan_Gaylord commented on July 9th 19 at 13:31

Find more questions by tags PythonARMRaspberry PiLinuxOpenCV