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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:17:45+00:00 2026-05-17T18:17:45+00:00

This should be easy. I have a video stream coming in from my webcam.

  • 0

This should be easy. I have a video stream coming in from my webcam. I’m just playing with image transformation etc. I’d like to be able to view the original images (video input) in one window and the transformed video in another. Problem is, as soon as I start capturing video instead of just single images, the original video window displays transformed video. I don’t understand why.

cvNamedWindow("in", CV_WINDOW_AUTOSIZE);
cvNamedWindow("out", CV_WINDOW_AUTOSIZE);

CvCapture *fc = cvCaptureFromCAM(0);

IplImage* frame = cvQueryFrame(fc);

if (!frame) {
    return 0;
}

IplImage* greyscale = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 1);
IplImage* output = cvCreateImage(cvGetSize(frame),IPL_DEPTH_32F , 1);

while(1){

    frame= cvQueryFrame(fc);
    cvShowImage("in", frame);

    // manually convert to greyscale
    for (int y = 0; y < frame->height; y++) {
        uchar* p = (uchar*) frame->imageData + y* frame->widthStep; // pointer to row
        uchar* gp = (uchar*) greyscale->imageData + y*greyscale->widthStep;  
        for(int x = 0; x < frame->width; x++){
            gp[x] = (p[3*x] + p[3*x+1] + p[3*x+2])/3;   // average RGB values 
        }
    }

    cvShowImage("out", greyscale);

    char c = cvWaitKey(33);
    if (c == 27) {
        return 0;
    }
}

In this simple example, both video streams end up appearing greyscale… The pointer values and imagedata for frame and greyscale are totally different. If I stop showing greyscale in the “out” window, then frame will appear in color.

Also, if I continue and apply a Sobel operation on the greyscale image and display the result in “out”, both “in” and “out” windows will show the Sobel image!

Any ideas?

  • 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-17T18:17:46+00:00Added an answer on May 17, 2026 at 6:17 pm

    Hmm This was weird, but it seems using CV_WINDOW_AUTOSIZE was the problem? Perhaps it’s not supported in OpenCV 2.1 (which I’m pretty sure is what I’m running). Anyways, using 0 instead of CV_WINDOW_AUTOSIZE when creating the windows works fine.

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

Sidebar

Related Questions

This should be an easy one. I have a table like so: <table> <tr>
This seemed like it should be easy, but I have had trouble getting it
This should be easy but I have just started toying with matplotlib and python.
Seems like in Perl this should be easy or a module, but I have
This one should be easy, I think. I have a paginated image gallery, and
Seems like this should be easy but I must just be missing something... I
This seems like this should be easy but I have not been able to
This should be easy for many of you, but for me it's just another
This should be easy, just curious. I know httpd is the HTTP daemon, just
OK, I'm feeling like this should be easy but am obviously missing something fundamental

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.