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 9006543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:26:21+00:00 2026-06-16T01:26:21+00:00

I’m trying to double buffer my VideoCapture output in my OpenCV program (to reduce

  • 0

I’m trying to double buffer my VideoCapture output in my OpenCV program (to reduce flicker). Here’s the concept so far:

    Mat frameA, frameB;  //alternating between these two for storage
    VideoCapture cap(0); // open the default camera
    for(;;)
    {
        cap >> frameB; 
        waitKey(30);
        cap >> frameA;
        waitKey(30);


        putText(frameA,SSTR("A"),Point(frameA.cols/2,frameA.rows/2),3,5,CV_RGB(250,200,200));
        putText(frameB,SSTR("B"),Point(frameA.cols/2,frameB.rows/2),3,5,CV_RGB(250,200,200));


        imshow("A",frameA);
        imshow("B",frameB);

        waitKey(30);

    }

as a simple test I write the text A or B in the center of the frame. But the output has A and B overlapping – as if there were not two separate frames. What am I doing wrong?
I have made a solution by using the .clone() operator, but I understand that that sort of thing is horribly expensive in terms of CPU (?) and so would like to avoid it. Hopefully we’ve got some C++ double buffering experts here.

  • 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-16T01:26:22+00:00Added an answer on June 16, 2026 at 1:26 am

    I have the same problem. I think, you found a bug in OpenCV (2.4.9v for me) implementation. In source of HiGUI module (cap.cpp):

    bool VideoCapture::retrieve(Mat& image, int channel)
    {
        IplImage* _img = cvRetrieveFrame(cap, channel);
        if( !_img )
        {
            image.release();
            return false;
        }
        if(_img->origin == IPL_ORIGIN_TL)
            image = Mat(_img); << NO COPY
        else
        {
            Mat temp(_img);    << NO COPY
            flip(temp, image, 0); << Here is deep copy done
        }
        return true;
    }
    

    in case if _img->origin == IPL_ORIGIN_TL conversion from IplImage to cv::Mat was done WITHOUT copying the data, because declaration of constructor looks like this:

    //! converts old-style IplImage to the new matrix; the data is not copied by default
    Mat(const IplImage* img, bool copyData=false);
    

    Suggested solution:

    1. copy grabbed cv::Mat manually.
    2. Somebody should submit a bug to OpenCV.

    Upd. seems that this note from documentation actual for OpenCV 2.x too:

    Note: OpenCV 1.x functions cvRetrieveFrame and cv.RetrieveFrame return
    image stored inside the video capturing structure. It is not allowed
    to modify or release the image! You can copy the frame using
    cvCloneImage() and then do whatever you want with the copy.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

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.