selecting a device without UI
-
this is the link to download code: http://www.planet-source-code.com/upload_PSC/ftp/My_Webcam853695202002.zip[^] note : if you haven't CBuilder you can open main.cpp and main.h with notepad .
Looks like it's based on the project that I found. Look at the edited post above this one for comments. As I mentioned earlier look at EnumCapDrv, it calls capGetDriverDescription() to get devices. From looking at the API again though, my initial idea is wrong. Looks like you specify the device from the index.
for (i=0; i<10; i++)
{
if(capGetDriverDescription(i, szDeviceName, sizeof(szDeviceName),
szDeviceVersion, sizeof(szDeviceVersion)) )
{
if(strcmp(szDeviceName, "MyDeviceName") == 0)
{
SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, i, 0L);
}
}
}Anyway i think the code is a bit buggy.
// get the selected driver
SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, sel);Shouldn't it be
// get the selected driver
SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, &sel);Actually I think he should have just used a single selection listbox and use the LB_GETCURSEL message to get the current selection. Anyway, if it happens that your problem was that you couldn't select anything other than the first device, then this might be the reason. -- modified at 5:26 Thursday 4th May, 2006
-
Looks like it's based on the project that I found. Look at the edited post above this one for comments. As I mentioned earlier look at EnumCapDrv, it calls capGetDriverDescription() to get devices. From looking at the API again though, my initial idea is wrong. Looks like you specify the device from the index.
for (i=0; i<10; i++)
{
if(capGetDriverDescription(i, szDeviceName, sizeof(szDeviceName),
szDeviceVersion, sizeof(szDeviceVersion)) )
{
if(strcmp(szDeviceName, "MyDeviceName") == 0)
{
SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, i, 0L);
}
}
}Anyway i think the code is a bit buggy.
// get the selected driver
SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, sel);Shouldn't it be
// get the selected driver
SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, &sel);Actually I think he should have just used a single selection listbox and use the LB_GETCURSEL message to get the current selection. Anyway, if it happens that your problem was that you couldn't select anything other than the first device, then this might be the reason. -- modified at 5:26 Thursday 4th May, 2006
-
I looked my code , it was the correct one . and my problem isn't that I change the default device but it doesn't change , my problem is that I dont know how to change that .
Reread my previous posts (I might have modified them after you read them) and tell me which part you don't understand. What do you mean by "your code was the correct one"? Setting the device just involves setting the index 'i' in the WM_CAP_DRIVE_CONNECT message.
SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, i, 0L);
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_wm_cap_driver_connect.asp[^] As I said before use capGetDriverDescription() to figure out which index your device corresponds to. -- modified at 6:21 Thursday 4th May, 2006
-
Reread my previous posts (I might have modified them after you read them) and tell me which part you don't understand. What do you mean by "your code was the correct one"? Setting the device just involves setting the index 'i' in the WM_CAP_DRIVE_CONNECT message.
SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, i, 0L);
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_wm_cap_driver_connect.asp[^] As I said before use capGetDriverDescription() to figure out which index your device corresponds to. -- modified at 6:21 Thursday 4th May, 2006
-
I cant find similarity of our sources , and when you refer to somthing in code I cant find where you are saying . and because I didn't work on devices befor this I cant guess what are you saying. can you say it simpler ? thank you
More like working with Video For Windows API in this case. Devices is too generic a term. In fact most people do this using DirectShow instead of VFW these days. My suggestion to how to get the device index that you want.
for (i=0; i<10; i++)
{
if(capGetDriverDescription(i, szDeviceName, sizeof(szDeviceName), szDeviceVersion, sizeof(szDeviceVersion)) )
{
if(strcmp(szDeviceName, "MyDeviceName") == 0)
{
SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, i, 0L);
break;
}
}
}Look at this to see how he enumerates the Video For Windows devices main.cpp: Line 185
int TForm1::EnumCapDrv() // enumerate the installed capture drivers
main.cpp: Line 118
SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, sel, 0L);
main.cpp: Line 115
SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, sel);
Should be
SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, &sel);
Or it will only set the device to index 0, as sel was initialised to 0.
-
More like working with Video For Windows API in this case. Devices is too generic a term. In fact most people do this using DirectShow instead of VFW these days. My suggestion to how to get the device index that you want.
for (i=0; i<10; i++)
{
if(capGetDriverDescription(i, szDeviceName, sizeof(szDeviceName), szDeviceVersion, sizeof(szDeviceVersion)) )
{
if(strcmp(szDeviceName, "MyDeviceName") == 0)
{
SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, i, 0L);
break;
}
}
}Look at this to see how he enumerates the Video For Windows devices main.cpp: Line 185
int TForm1::EnumCapDrv() // enumerate the installed capture drivers
main.cpp: Line 118
SendMessage( hwndVideo, WM_CAP_DRIVER_CONNECT, sel, 0L);
main.cpp: Line 115
SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, sel);
Should be
SendMessage( hwndSelCapDrvDlg_LBox, LB_GETSELITEMS, 1, &sel);
Or it will only set the device to index 0, as sel was initialised to 0.
-
I use two webcams in my project and want to switch between them without oppenning UI window . kindly ask to send the code for switching between two cameras .
Does sending the
WM_CAP_DRIVER_CONNECT
message not work?SendMessage(hwndVideo, WM_CAP_DRIVER_CONNECT, camIndex, 0L);
or the macro
capDriverConnect(hwndVideo, camIndex);
What problems are you facing?
-
Does sending the
WM_CAP_DRIVER_CONNECT
message not work?SendMessage(hwndVideo, WM_CAP_DRIVER_CONNECT, camIndex, 0L);
or the macro
capDriverConnect(hwndVideo, camIndex);
What problems are you facing?
-
Um. Windows recognizes both webcams as in... they both have VFW drivers? Did you see the webcams listed in the listbox of this application?
-
Um. Windows recognizes both webcams as in... they both have VFW drivers? Did you see the webcams listed in the listbox of this application?
-
Yes I can choose between two webcams in windows UI dialog . but as mentioned above when I put the camIndex=1 it doesn't recognize it.
What windows UI dialog? Is it present in the SelCapDrvDlg in this application? Set a breakpoint in main.cpp line 199. What are the indexes of the 2 webcams you are interested in?
-
What windows UI dialog? Is it present in the SelCapDrvDlg in this application? Set a breakpoint in main.cpp line 199. What are the indexes of the 2 webcams you are interested in?
-
And there we have it. One of your webcams only has a WDM driver. You would have to write a DirectShow application.
-
And there we have it. One of your webcams only has a WDM driver. You would have to write a DirectShow application.
-
If you have VC7+, download and install the latest Platform SDK. Go to http://tmhare.mvps.org/downloads.htm[^] to get the project files for the samples since Microsoft has for some reason stripped it out. Then go have a look at the PlayCap sample application in "..\Program Files\Microsoft Platform SDK\Samples\Multimedia\DirectShow\Capture\PlayCap" If you have VC6 though, you would have to grab an old DirectX SDK, maybe 2003 or 2004.
-
If you have VC7+, download and install the latest Platform SDK. Go to http://tmhare.mvps.org/downloads.htm[^] to get the project files for the samples since Microsoft has for some reason stripped it out. Then go have a look at the PlayCap sample application in "..\Program Files\Microsoft Platform SDK\Samples\Multimedia\DirectShow\Capture\PlayCap" If you have VC6 though, you would have to grab an old DirectX SDK, maybe 2003 or 2004.
-
VC7+: Microsoft Visual C++ 2002/2003/2005 SDK: Software Development Kit http://www.microsoft.com/downloads/details.aspx?FamilyId=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&displaylang=en[^]
-
VC7+: Microsoft Visual C++ 2002/2003/2005 SDK: Software Development Kit http://www.microsoft.com/downloads/details.aspx?FamilyId=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&displaylang=en[^]
-
Your copy of Visual Studio .NET doesn't come with the C++ compiler? I never used CBuilder before so I guess you're on your own in building/getting compatible libs. Here's a link to get you started. http://www.geocities.com/foetsch/borlibs/[^] http://clootie.narod.ru/cbuilder/index.html[^]
-
Your copy of Visual Studio .NET doesn't come with the C++ compiler? I never used CBuilder before so I guess you're on your own in building/getting compatible libs. Here's a link to get you started. http://www.geocities.com/foetsch/borlibs/[^] http://clootie.narod.ru/cbuilder/index.html[^]