Thread View: borland.public.cppbuilder.multimedia
5 messages
5 total messages
Started by Andrew
Sun, 26 Feb 2006 08:47
Multiple Video Display USB
Author: Andrew
Date: Sun, 26 Feb 2006 08:47
Date: Sun, 26 Feb 2006 08:47
130 lines
5345 bytes
5345 bytes
Hi, I am using BCB5, Win XP
Using the Following code (posted by Gambit) a long time ago,
displays video on a panel from a USB camera.
Is there a way to display from a second camera,
possibly on a second panel?
I'm sure it has to do with Indexing, but can't make work yet.
Thanks in Advance.
Following is post from Gambit for Video.
#include <vcl.h>
#pragma hdrstop
#include "Test_Video_Unit.h"
#include <vfw.h>
HWND CaptureWindow = NULL;
CAPDRIVERCAPS DriverCaps;
CAPTUREPARMS CapParams;
LRESULT PASCAL FrameCallback(HWND hWnd, LPVIDEOHDR lpVHdr);
LRESULT PASCAL ErrorCallback(HWND hWnd, int nErrID, LPSTR
lpErrorText);
LRESULT PASCAL StatusCallback(HWND hWnd, int nID, LPSTR
lpStatusText);
//-------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
char szDeviceName[80];
char szDeviceVersion[80];
for(int wIndex = 0; wIndex < 10; wIndex++)
{
if(capGetDriverDescription(wIndex, szDeviceName,
sizeof(szDeviceName), szDeviceVersion, sizeof(szDeviceVersion)))
{
// Append name to list of installed capture drivers
// and then let the user select a driver to use.
ComboBox1->Items->Add(szDeviceName);
}
}
CapParams.dwRequestMicroSecPerFrame = 4444;
CapParams.fYield = TRUE;
CapParams.fCaptureAudio = FALSE;
}
//--------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
if(CaptureWindow)
{
capCaptureStop(CaptureWindow);
capDriverDisconnect(CaptureWindow);
}
}
//--------------------------------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender)
{
int wID;
CaptureWindow = capCreateCaptureWindow("MyWindow", WS_CHILD |
WS_VISIBLE, 0, 0, 160, 120, (HWND)Panel1->Handle, 0);
if(CaptureWindow)
{
if(capDriverConnect(CaptureWindow, 0))
{
capDriverGetCaps(CaptureWindow, &DriverCaps,
sizeof(CAPDRIVERCAPS));
capPreviewScale(CaptureWindow, FALSE);
capCaptureSetSetup(CaptureWindow, &CapParams,
sizeof(CAPTUREPARMS));
capSetCallbackOnFrame(CaptureWindow, FrameCallback);
capSetCallbackOnError(CaptureWindow, ErrorCallback);
capSetCallbackOnStatus(CaptureWindow, StatusCallback);
if(DriverCaps.fHasOverlay)
capOverlay(CaptureWindow, TRUE);
else
{
capPreviewRate(CaptureWindow, 66);
capPreview(CaptureWindow, TRUE);
}
}
else
ShowMessage("Driver not connected");
}
else
ShowMessage("Could not create capture window");
}
//--------------------------------------------------------------void __fastcall TForm1::Button2Click(TObject *Sender)
{
if(CaptureWindow)
{
if(DriverCaps.fHasOverlay)
capOverlay(CaptureWindow, FALSE);
else
capPreview(CaptureWindow, FALSE);
capDriverDisconnect(CaptureWindow);
DestroyWindow(CaptureWindow);
CaptureWindow = NULL;
}
}
//--------------------------------------------------------------LRESULT PASCAL FrameCallback(HWND hWnd, LPVIDEOHDR lpVHdr)
{
// do something
return (LRESULT)TRUE;
}
// -------------------------------------------------------------
LRESULT PASCAL ErrorCallback(HWND hWnd, int nErrID, LPSTR lpErrorText)
{
if (nErrID == 0) // Starting a new major function.
return TRUE; // Clear out old errors.
char caption[256];
// Show the error identifier and text.
wsprintf(caption, "Error# %d", nErrID);
MessageBox(hWnd, lpErrorText, caption, MB_OK | MB_ICONEXCLAMATION);
return (LRESULT)TRUE;
}
// -------------------------------------------------------------
LRESULT PASCAL StatusCallback(HWND hWnd, int nID, LPSTR lpStatusText)
{
char caption[256];
if (nID == 0)
{
// Clear old status messages.
SetWindowText((HWND)Form1->Handle, "My Webcam");
return (LRESULT)TRUE;
}
// Show the status ID and status text...
wsprintf(caption, "Status# %d: %s", nID, lpStatusText);
SetWindowText((HWND)Form1->Handle, (LPSTR)caption);
return (LRESULT)TRUE;
}
Re: Multiple Video Display USB Code Adjustment
Author: Andrew
Date: Mon, 27 Feb 2006 07:31
Date: Mon, 27 Feb 2006 07:31
22 lines
1377 bytes
1377 bytes
Just to clarify program.
Some Line RETURNS were not shown in previous code example.
To Clarify their are four lines that should be on their own
line:
and not be after a series of >//--------- .....
They Are:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
void __fastcall TForm1::Button1Click(TObject *Sender)
void __fastcall TForm1::Button2Click(TObject *Sender)
LRESULT PASCAL FrameCallback(HWND hWnd, LPVIDEOHDR lpVHdr)
Clarifying in case it is not obvious
Thank you
Andrew
Re: Multiple Video Display USB
Author: Clayton Arends
Date: Mon, 27 Feb 2006 17:05
Date: Mon, 27 Feb 2006 17:05
18 lines
1573 bytes
1573 bytes
In the code you are using there is a tiny bug. I'm not sure if it was
present in the original code that Remy posted or was caused by a subsequent
change. The line that connects to the driver doesn't care what has been
selected in the combo box. Probably not an issue for systems that have only
one device.
However, for you specific issue, in the line that connects to the driver,
have you tried to create a second set of controls (Panel2, ComboBox2, etc)
and then connect to index 1?
if(capDriverConnect(CaptureWindow, 1))
or, better
if(capDriverConnect(CaptureWindow, ComboBox2->ItemIndex))
HTH,
- Clayton
Re: Multiple Video Display USB Image Sizes?
Author: Andrew
Date: Sat, 04 Mar 2006 05:18
Date: Sat, 04 Mar 2006 05:18
26 lines
1742 bytes
1742 bytes
Thanks for that solution.
You are correct.
It was probably something I had changed once apon a time,
and never undone.
Because this worked so well, and my Kingsington camera is old,
I bought a new webcam. ("Creative Live!")
When I change the size from 320x240 to something larger
ie. 640 x 480, the camera view image will not increase.
I went through the settings in their program options and
changed video mode to 640x480, but it did not make any
difference.
Logitech camera's will not increase either. I spoke to
Logitech customer support and their result was nothing could
be done....
My old Kingsington changed to any size I tried, it was great,
but that was in the days of Win98SE.
Is there a way to increase the size, I'd prefer to stay
with WinXP ?
Thanks in Advance
Andrew
Re: Multiple Video Display USB Image Sizes?
Author: Clayton Arends
Date: Sun, 05 Mar 2006 15:14
Date: Sun, 05 Mar 2006 15:14
11 lines
1431 bytes
1431 bytes
I am not an expert in VFW but I can try to find the answer for you. In the meantime you might do better by posting this as a new question on the newsgroup so that it has new visibility (and has nothing to do with the title anymore). When you post your new question answer this question for me. Can you not change the camera size in just your application or is it not getting changed in *any* application (like MSNIM, Logitech's IM, camera settings area, etc)? - Clayton
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads