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

  • Home
  • SEARCH
  • 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 7931757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:48:55+00:00 2026-06-03T20:48:55+00:00

How can I retrieve the current frame number of a video using OpenCV? Does

  • 0

How can I retrieve the current frame number of a video using OpenCV? Does OpenCV have any built-in function for getting the current frame or I have to do it manually?

  • 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-03T20:48:57+00:00Added an answer on June 3, 2026 at 8:48 pm

    You can use the "get" method of your capture object like below :

    capture.get(CV_CAP_PROP_POS_FRAMES); // retrieves the current frame number
    

    and also :

    capture.get(CV_CAP_PROP_FRAME_COUNT); // returns the number of total frames 
    

    Btw, these methods return a double value.

    You can also use cvGetCaptureProperty method (if you use old C interface).

    cvGetCaptureProperty(CvCapture* capture,int property_id);

    property_id options are below with definitions:

    CV_CAP_PROP_POS_MSEC 0

    CV_CAP_PROP_POS_FRAME 1

    CV_CAP_PROP_POS_AVI_RATIO 2

    CV_CAP_PROP_FRAME_WIDTH 3

    CV_CAP_PROP_FRAME_HEIGHT 4

    CV_CAP_PROP_FPS 5

    CV_CAP_PROP_FOURCC 6

    CV_CAP_PROP_FRAME_COUNT 7

    • POS_MSEC is the current position in a video file, measured in
      milliseconds.
    • POS_FRAME is the position of current frame in video (like 55th frame of video).
    • POS_AVI_RATIO is the current position given as a number between 0 and 1
      (this is actually quite useful when you want to position a trackbar
      to allow folks to navigate around your video).
    • FRAME_WIDTH and FRAME_HEIGHT are the dimensions of the individual
      frames of the video to be read (or to be captured at the camera’s
      current settings).
    • FPS is specific to video files and indicates the number of frames
      per second at which the video was captured. You will need to know
      this if you want to play back your video and have it come out at the
      right speed.
    • FOURCC is the four-character code for the compression codec to be
      used for the video you are currently reading.
    • FRAME_COUNT should be the total number of frames in video, but
      this figure is not entirely reliable.

    (from Learning OpenCV book )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I retrieve the current position of the vertices after they have been
How can i retrieve the current CPU usage in c# using WMI? I've seen
On every frame of my application, I can call timeGetTime() to retrieve the current
How can I programmatically retrieve the current connection type (eg. LAN or Direct connection)?
I know I can retrieve some settings.xml parameters using properties, like, for example ${settings.localRepository}
I have generic list which must be a preserved order so I can retrieve
I developp a Java application using Windows Desktop Search from which I can retrieve
I have a blob saved in my database (a text file). I can retrieve
Is there ASP code which can retrieve the users current language? In javascript I
How can I retrieve the current working directory of cmd.exe? This seems possible. For

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.