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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:59:25+00:00 2026-05-13T10:59:25+00:00

I want to do background subtraction in a video file using OpenCV method. Right

  • 0

I want to do background subtraction in a video file using OpenCV method. Right now I’m able to do background subtraction, but the problem is that I couldn’t get the output in color mode. All the output after subtracting the background is coming in grayscale color mode 🙁. I want to get the color information to the foreground which is the resulting output after background got subtracted.

Can I do it using masking technique?? like the following procedure which I’m thinking about.

  1. Capture Input — InputFrame (RGB)
  2. Process InputFrame
  3. Subtract background, store foreground in TempFrame (which is coming in grayscale 🙁 )
  4. Create a mask using TempFrame
  5. Apply the created mask to the InputFrame
  6. Get colored foreground as OutFrame

I’m struck up with doing the masking using OpenCV. I’m just a very beginner in OpenCV. Please help me to overcome this.

Thanks in advance.

  • 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-05-13T10:59:26+00:00Added an answer on May 13, 2026 at 10:59 am

    Okay, I don’t understand how TempFrame (your foreground) could be greyscale if you are using background subtraction. You must be using a very special algorithm. But assuming TempFrame is greyscale, then you would do this:

    cv::Mat mask = tempFrame > 0.5;
    
    cv::Mat outFrame;
    capturedFrame.copyTo(outFrame, mask);
    

    That is OpenCV 2.0 code above. The number 0.5 is a threshold, you’ll need to set it to something appropriate. If you’re not using floating-point images, you’d probably set it to 128 or something like that. This is the same thing in OpenCV 1.1 code:

    CvMat* mask = cvCreateMat(tempFrame.rows, tempFrame.cols, CV_8UC1);
    cvCmpS(tempFrame, 0.5, mask);
    
    CvMat* outFrame = cvCreateMat(capturedFrame.rows, capturedFrames.cols, CV_32FC3);
    cvCopy(capturedFrame, outFrame, mask);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 289k
  • Answers 289k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is connector bug and I have reported at mysql. May 13, 2026 at 5:39 pm
  • Editorial Team
    Editorial Team added an answer Would your system handle other processes reading the data that… May 13, 2026 at 5:39 pm
  • Editorial Team
    Editorial Team added an answer Is your main() routine in C++/CLI flagged with [STAThread]? It's… May 13, 2026 at 5:39 pm

Related Questions

Ok, so coming from a background of mostly perl, and mostly writing dirty little
I want to make a simple Go board to design an Computer Go game.
Is it possible to set the size of the background image with CSS? I
Programmatically I am creating buttons and keeping some background image using setBackgroundImage. I want
Ok, maybe I'm missing something really simple and I apologize if that's the case,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.