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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:07:34+00:00 2026-05-30T18:07:34+00:00

I have a very simple program on OpenCV: #include <cv.h> #include <cxcore.h> #include <highgui.h>

  • 0

I have a very simple program on OpenCV:

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

using namespace std;

void showVideo(CvCapture *video)
{
    int width = (int) cvGetCaptureProperty(video, CV_CAP_PROP_FRAME_WIDTH);
    int height = (int) cvGetCaptureProperty(video, CV_CAP_PROP_FRAME_HEIGHT);
    //int fps = (int) cvGetCaptureProperty(video, CV_CAP_PROP_FPS);
    IplImage* frame = cvCreateImage(cvSize(width, height), 8, 1);
    cvNamedWindow("Showing Video:", 0);
    while (true)
    {
        frame = cvQueryFrame(video);
        cvShowImage("Showing Video:", frame);
        cvWaitKey(10);
    }
    //cvDestroyWindow("Showing Video:");
    //cvReleaseImage(&frame);
}
int main()
{
    CvCapture *video = cvCaptureFromCAM(CV_CAP_ANY);
    showVideo(video);
    return 0;
}

I want to have a char ch; and something like this while(ch != 'q') then it still plays the video. There is some ways such as kbhit() or getch() but they are not standard and I want something that whenever the ‘q’ key is pressed, then the showing the video will finish, otherwise video showing will be still running.

How can I do this job?

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

    cvWaitKey() returns 0 if no key was pressed in the allotted time or the key code if a key is pressed. Change your call to cvWaitKey() to test the return value like this:

    chr = cvWaitKey(10);
    if (chr == 'q')
        break;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple print program called print.c: #include <stdio.h> int main(void){ printf(Random
I have a very simple test program, running on Solaris 5.8: #include <stdio.h> #include
I have created a very simple program that uses recursion. I'm using the g++
Have a look at this very simple example WPF program: <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
I have a very simple WPF application in which I am using data binding
So I have a very simple program that reads the 3 first bytes of
I have a very simple program that I am trying to improve performance. One
I have a very simple SDL program that uses only 1MB of memory with
I'm planning to make a very simple program using php and mySQL. The main
I have a very simple program but this is giving me a seg fault.

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.