Click here to Skip to main content
13,191,400 members (81,139 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I am trying to show a webcam on the window using c++.

For that i created a window with createwindowex() function and to this window i need

to add the camera. Using opencv i tried access the camera but it is not displaying the

window also. i tried in many ways but not displaying the camera.

can anyone suggest me in other way.

Thanks in advance.
Posted 24-Sep-12 0:43am
Kumar 091.2K
Updated 24-Sep-12 22:49pm
Sergey Alexandrovich Kryukov 24-Sep-12 12:37pm
You can show a Web camera in your windows by photographing of this camera with the help of any other camera and making a bitmap file for it. Showing it in the window is simple :-)
Kumar 09 24-Sep-12 21:30pm
any example plz
Example? Sure: Fujifilm, Canon, Pentax, Nikon, Olympus, Sigma, Leika, Ricoh, Samsung, Panasonic...
Legor 25-Sep-12 4:50am
How do you use openCV to show the camera output? You have to provide more details (the specific lines of code) where you have problems. Use the "Improve question" button to add more details to your question.
Kumar 09 2-Oct-12 2:05am

I am working on Credential Provider using VC++. Where i want start a web cam using

opencv classes and libraries. Added all the header files and its libraries to

credential provider for accessing.

Code Like this:

cvCapture *camera = 0;
IplImage *frame;
IplImage *showimg;
cvNamedWindow("Input", CV_WINDOW_AUTOSIZE);
camera = cvCaptureFromCAM(0);
cvSetCaptureProperty(camera, CV_CAP_PROP_FRAME_WIDTH, 360);
cvSetCaptureProperty(camera, CV_CAP_PROP_FRAME_HEIGHT, 240);
frame = cvQueryFrame(camera);
showimg = cvCloneImage(frame);
cvShowImage("Input", showimg);

added this code to display the cam on the window.

but its not displaying cam but displaying the window and giving the error Like this:

"This application has requested the runtime to terminate it in a unusual way. Please contact the application's support team for more information".

Can anyone give me some idea, how to solve this issue.

Thanks in Advance. .
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you want to capture video (from your webcam) using OpenCV, check out the following sample at OpenCV wiki:[^]

If you want to use Win SDK, use either Video for Windows (WfW) or DirectShow.

WfW provides capCreateCaptureWindow() API to create a Window for capturing video. There are a lot of samples available on the Internet.

E.g. a basic sample is available at MSDN:[^]

Good luck!
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171017.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100