Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:22:43+00:00 2026-06-05T19:22:43+00:00

I want to get the video stream from my webcam using python and OpenCV,

  • 0

I want to get the video stream from my webcam using python and OpenCV, for that task i’ve implemented this simple code:

import cv

cv.NamedWindow("w1", cv.CV_WINDOW_AUTOSIZE)
capture = cv.CaptureFromCAM(0)

def repeat():
  frame = cv.QueryFrame(capture)
  cv.ShowImage("w1", frame)


while True:
  repeat()

when i try to execute it, i get the following error:

andfoy@ubuntu:~/Python$ python camera.py
VIDIOC_QUERYMENU: Argumento inválido   
VIDIOC_QUERYMENU: Argumento inválido
VIDIOC_QUERYMENU: Argumento inválido

I changed the following line as suggested by other posts:

capture = cv.CaptureFromCAM(0)

to:

capture = cv.CaptureFromCAM(-1) 

but the error persists.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:22:45+00:00Added an answer on June 5, 2026 at 7:22 pm

    You need to add waitkey function at end.

    Below piece of code works fine for me.

    import cv
    cv.NamedWindow("w1", cv.CV_WINDOW_AUTOSIZE)
    capture = cv.CaptureFromCAM(0)
    
    def repeat():
        frame = cv.QueryFrame(capture)
        cv.ShowImage("w1", frame)
    
    while True:
        repeat()
        if cv.WaitKey(33)==27:
            break
    
    cv.DestroyAllWindows()
    

    And if you are not aware, Present OpenCV uses new python api cv2 and it has lots of features. In that, same code is written as :

    import cv2
    import numpy as np
    c = cv2.VideoCapture(0)
    
    while(1):
        _,f = c.read()
        cv2.imshow('e2',f)
        if cv2.waitKey(5)==27:
            break
    cv2.destroyAllWindows()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to live stream video from android device. I found out that ffserver
i want get weather from http://www.google.com/ig/api?weather= I use this // load xml result from
Is there a simple way to remove the video-stream from a IMediaWriter? I have
So we want to be able to stream a video from a website. We
I want to stream the video from android phone camera to VLC media player
I'm trying to get the RTSP video stream play in my Android App using
I have a small video site where I want to get related videos on
Given a file path URL such as http://example.com/video.flv?start=5 , I want to get out
I want to get a thumbnail image for videos from Vimeo. When getting images
I want get the user profile large or normal picture from facebook. Now I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.