element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Pi OpenCv and usb Webcam Question
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 7 replies
  • Answers 1 answer
  • Subscribers 677 subscribers
  • Views 1349 views
  • Users 0 members are here
  • raspberry_pi
Related

Pi OpenCv and usb Webcam Question

m.ratcliffe
m.ratcliffe over 10 years ago

Any help on this idea would be greatly appreciated, I have found a weird issue with integrating a USB webcam with a Pi and open CV.

If I request a snap shot from the webcam it gives me a old one, i'm assuming this is a shot from the start of a frame buffer because if I "burn" a few shots first it gives me a much newer less lagging image. [essentially I ask it for images 6 times and only accept the last one]

 

OpenCv install I used:

Animated_Grim Blog:3 - Raspbery Pi and OpenCv the Easy Way

 

Webcam :

Logitech C270 but I get the same issue with a cheap generic ebay one.

 

Pi:

Model 2

 

I have been using this work around to get upto date images from the usb webcam, but now I have time I would like to find the root issue and speed my loop up considerably.

 

Header 1

#!/usr/bin/python

 

 

import cv2

cap = cv2.VideoCapture(0)

 

 

while(1):

 

 

    _,frame = cap.read()

    #Display the first image captured

    cv2.imshow('Camera_LAG',frame)

    _,frame = cap.read()

    _,frame = cap.read()

    _,frame = cap.read()   

    _,frame = cap.read()

    _,frame = cap.read()

    _,frame = cap.read()

    #Display the 6th image captured

    cv2.imshow('NO_LAG',frame)

 

 

##***Checks If User Has Asked to Leave

    if cv2.waitKey(33)== 27:

        break

##************** Clean up everything before leaving *****************##

 

 

cap.release()

cv2.destroyAllWindows()

 

Does anyone have any idea why this is happening, can I somehow request the newest image from the camera because I would like to speed my image processing projects up.

 

Mike

  • Sign in to reply
  • Cancel
Parents
  • m.ratcliffe
    0 m.ratcliffe over 10 years ago

    Bump

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • gadget.iom
    0 gadget.iom over 10 years ago in reply to m.ratcliffe

    I have no experience with OpenCV, but is the following article of any use?

    http://stackoverflow.com/questions/24370725/opencv-videocapture-only-updates-after-5-reads

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Reply
  • gadget.iom
    0 gadget.iom over 10 years ago in reply to m.ratcliffe

    I have no experience with OpenCV, but is the following article of any use?

    http://stackoverflow.com/questions/24370725/opencv-videocapture-only-updates-after-5-reads

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Children
  • Problemchild
    0 Problemchild over 10 years ago in reply to gadget.iom

    So essentially what it's saying is have a seperate thread that is consuming the video frames and that hands you the frames to be processed by this guy's OpenCv prog.

     

    Cool

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube