Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

how to detect a webcam using c++

Posted on 2009-02-23
7
Medium Priority
?
1,154 Views
Last Modified: 2012-05-06
Hi,
i want to detect all the webcams attached to the system using c++ for a win32 console application.

can you please tell me how to do that.

can you also suggest me some (good) sites for " how to read live images from webcam".

Thanks
0
Comment
Question by:kishan66
  • 4
  • 3
7 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 23712100
You could use the following:
#include <iostream>
using namespace std
#include <vfw.h>
#prahma comment(lib,"vfw32.lib")
 
#define MAXCAPDRIVERS                   10      // maximum drivers list size
 
void ListCams() 
{
 
    int j;
    char szName[80];
    char szVer[80];
 
    for (j =0; j < MAXCAPDRIVERS; j++) 
        if (capGetDriverDescription (j,
                szName, sizeof (szName),
                szVer,  sizeof (szVer))) 
        {
           cout << j << ": " << szName << endl;
        }
}
 
void main () 
{
    ListCams ();
}

Open in new window

0
 
LVL 86

Expert Comment

by:jkr
ID: 23712168
Sorry, semicolon missing - make that
#include <iostream>
using namespace std;
#include <vfw.h>
#prahma comment(lib,"vfw32.lib")
 
#define MAXCAPDRIVERS                   10      // maximum drivers list size
 
void ListCams() 
{
 
    int j;
    char szName[80];
    char szVer[80];
 
    for (j =0; j < MAXCAPDRIVERS; j++) 
        if (capGetDriverDescription (j,
                szName, sizeof (szName),
                szVer,  sizeof (szVer))) 
        {
           cout << j << ": " << szName << endl;
        }
}
 
void main () 
{
    ListCams ();
}

Open in new window

0
 

Author Comment

by:kishan66
ID: 23713031
hi jkr,
Thanx for the reply.
as a new chap to c++, i would like to ask some basics. please help me.

i have just opened a win32console application and choose "empty project" in Application settings.

can you guide me through the next process....

Thanks for the help i n advance..


0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:jkr
ID: 23713298
Well, basically you'd copy&paste the above into your .cpp file and compile - with one little change, a header file is missing:
#include <iostream>
using namespace std;
 
#include <windows.h>
#include <vfw.h>
#prahma comment(lib,"vfw32.lib")
 
#define MAXCAPDRIVERS                   10      // maximum drivers list size
 
void ListCams() 
{
 
    int j;
    char szName[80];
    char szVer[80];
 
    for (j =0; j < MAXCAPDRIVERS; j++) 
        if (capGetDriverDescription (j,
                szName, sizeof (szName),
                szVer,  sizeof (szVer))) 
        {
           cout << j << ": " << szName << endl;
        }
}
 
void main () 
{
    ListCams ();
}

Open in new window

0
 

Author Comment

by:kishan66
ID: 23713657
I am  getting different out put.

i am using "logitech webcam" but it is showing out put as " 0:Microsoft WDM Image Capture <win32>"

Y is that so?
0
 

Author Comment

by:kishan66
ID: 23714157
hi jkr,

r u there.
can any one help ?
0
 
LVL 86

Accepted Solution

by:
jkr earned 1000 total points
ID: 23716337
Sorry, that prints the capture driver - will see if I can find something about the cameras...
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question