Thread View: borland.public.cppbuilder.multimedia
6 messages
6 total messages
Started by Edward
Thu, 27 Nov 2003 18:50
WebCam Capture, BMP resize problem.
Author: Edward
Date: Thu, 27 Nov 2003 18:50
Date: Thu, 27 Nov 2003 18:50
63 lines
2339 bytes
2339 bytes
Hi all
I using my code above to capture a imagem direct from my web cam and
save into a BMP file but i need to resize the image and when i do that i
have some problems i dont know what is happening.
In the future the program will be hinding from user so i cant show the
FROM.
Thanks
Edward
CAPSTATUS CapStatus;
char str[12];
TimerRefresh->Enabled = false;
if(!FileExists("SAIR.DAT"))
{
if(ctImg>=20)
{
ctImg=0;
}
ctImg++;
sprintf(str,"web%03d.bmp",ctImg);
try
{
capGetStatus(hWndC, &CapStatus, sizeof (CAPSTATUS));
capFileSaveDIB(hWndC, str);
Graphics::TBitmap *bmpOld = new Graphics::TBitmap();
Graphics::TBitmap *bmpNew = new Graphics::TBitmap();
bmpOld->LoadFromFile(str);
bmpNew->Width = tamXVL;
bmpNew->Height = tamYVL;
bmpNew->Canvas->StretchDraw(bmpNew->Canvas->ClipRect, bmpOld);
bmpNew->Assign(bmpNew);
bmpNew->SaveToFile(str);
delete bmpOld;
delete bmpNew;
}
catch (Exception &Ex)
{
MessageDlg("Exception type " + Ex.ClassName() + " returned error
message: " + Ex.Message + "\r" + " in form " + this->ClassName(), mtError,
TMsgDlgButtons() << mbOK, 0);
abort();
}
}
else
{
capDriverDisconnect(hWndC);
FreeLibrary(AVICapDllHandle);
Close();
}
TimerRefresh->Enabled = true;
Re: WebCam Capture, BMP resize problem.
Author: Hans Galema
Date: Fri, 28 Nov 2003 07:39
Date: Fri, 28 Nov 2003 07:39
17 lines
1525 bytes
1525 bytes
Edward wrote: > I using my code above to capture a imagem direct from my web cam and > save into a BMP file but i need to resize the image and when i do that i > have some problems i dont know what is happening. What are the problems ? > bmpNew->Canvas->StretchDraw(bmpNew->Canvas->ClipRect, bmpOld); You could have a look at CopyRect(). > bmpNew->Assign(bmpNew); What should that statement do ? Hans.
Re: WebCam Capture, BMP resize problem.
Author: Edward
Date: Mon, 01 Dec 2003 21:01
Date: Mon, 01 Dec 2003 21:01
27 lines
1686 bytes
1686 bytes
Ok. There are errors. But what is the solution? Thanks any way. "Hans Galema" <dontusethis@dontusethis.nl> escreveu na mensagem news:3fc6fadd$1@newsgroups.borland.com... > Edward wrote: > > > I using my code above to capture a imagem direct from my web cam and > > save into a BMP file but i need to resize the image and when i do that i > > have some problems i dont know what is happening. > > What are the problems ? > > > bmpNew->Canvas->StretchDraw(bmpNew->Canvas->ClipRect, bmpOld); > > You could have a look at CopyRect(). > > > bmpNew->Assign(bmpNew); > > What should that statement do ? > > Hans. >
OTHER WAY
Author: Edward
Date: Wed, 03 Dec 2003 02:10
Date: Wed, 03 Dec 2003 02:10
153 lines
4589 bytes
4589 bytes
I have two layers of programs "MY WEBCAMCAP" and "OTHER PROGRAM WHERE I
SHOW THE VIDEO" first i try capture BMP and make other program read those
BMP after i try to put video direct on program.
I trying to made a another way to my program work showing the image
direct on the DESKTOP but i have problem of FLICKER using:
HWND hForm = GetDesktopWindow() ;
Using HWND hForm = FindWindow("MYPROG",NULL); doenst work.
ANY IDEIA?
My question is: How to capture video from a webcam without use FORM or
DESKTOP like Handle.
THE CODE
void __fastcall TFormPrincipal::FormCreate(TObject *Sender)
{
AVICapDllHandle = LoadLibrary( "AVICAP32.DLL" );
// HWND hForm = FormPrincipal->Handle;
HWND hForm = GetDesktopWindow() ;
ctImg=0;
FILE *arqSize;
char strSize[10];
AnsiString strAnsiSize;
DeleteFile("SAIR.DAT");
if(FileExists("SIZE.DAT"))
{
if((arqSize=fopen("SIZE.DAT","rt"))==NULL)
{
ShowMessage("Erro na abertura do Arquivo SIZE.DAT. Arquivo de
configura��o da WEBCAM!");
Close();
}
fseek(arqSize, SEEK_SET, 0);
fgets(strSize, 12, arqSize);
strAnsiSize = AnsiString(strSize);
fclose(arqSize);
tamXVL = strAnsiSize.SubString(1,strAnsiSize.AnsiPos("x")-1).ToInt();
tamYVL =
strAnsiSize.SubString(strAnsiSize.AnsiPos("x")+1,strAnsiSize.Length()-(strAn
siSize.AnsiPos("x")+1) ).ToInt();
}
else
{
tamXVL=320;
tamYVL=240;
}
if(AVICapDllHandle == 0)
{
MessageBox ( NULL, "LoadLibrary:\nAVICAP32.DLL not found.", "Error FS
002", MB_ICONSTOP );
}
hWndC = capCreateCaptureWindow("CamWin", WS_CHILD | WS_VISIBLE, 330, 250,
tamXVL, tamYVL, hForm, 0 );
if(capDriverConnect(hWndC, 0))
{
if(capPreviewRate(hWndC, 100/3))
{
capPreviewScale(hWndC, TRUE);
capPreview(hWndC, TRUE);
}
}
TimerRefresh->Enabled = true;
}
//--------------------------------------------------------------------------
-
"Edward" <registrados@via-rs.net> escreveu na mensagem
news:3fc6476a$1@newsgroups.borland.com...
> Hi all
>
> I using my code above to capture a imagem direct from my web cam and
> save into a BMP file but i need to resize the image and when i do that i
> have some problems i dont know what is happening.
>
> In the future the program will be hinding from user so i cant show the
> FROM.
>
> Thanks
>
> Edward
>
>
>
> CAPSTATUS CapStatus;
> char str[12];
>
> TimerRefresh->Enabled = false;
> if(!FileExists("SAIR.DAT"))
> {
> if(ctImg>=20)
> {
> ctImg=0;
> }
> ctImg++;
> sprintf(str,"web%03d.bmp",ctImg);
>
> try
> {
> capGetStatus(hWndC, &CapStatus, sizeof (CAPSTATUS));
> capFileSaveDIB(hWndC, str);
>
> Graphics::TBitmap *bmpOld = new Graphics::TBitmap();
> Graphics::TBitmap *bmpNew = new Graphics::TBitmap();
>
> bmpOld->LoadFromFile(str);
> bmpNew->Width = tamXVL;
> bmpNew->Height = tamYVL;
> bmpNew->Canvas->StretchDraw(bmpNew->Canvas->ClipRect, bmpOld);
>
> bmpNew->Assign(bmpNew);
> bmpNew->SaveToFile(str);
>
> delete bmpOld;
> delete bmpNew;
>
> }
> catch (Exception &Ex)
> {
> MessageDlg("Exception type " + Ex.ClassName() + " returned error
> message: " + Ex.Message + "\r" + " in form " + this->ClassName(), mtError,
> TMsgDlgButtons() << mbOK, 0);
> abort();
> }
> }
> else
> {
> capDriverDisconnect(hWndC);
> FreeLibrary(AVICapDllHandle);
> Close();
> }
> TimerRefresh->Enabled = true;
>
>
Re: OTHER WAY
Author: Hans Galema
Date: Mon, 08 Dec 2003 09:30
Date: Mon, 08 Dec 2003 09:30
78 lines
3345 bytes
3345 bytes
Edward wrote:
> I have two layers of programs "MY WEBCAMCAP" and "OTHER PROGRAM WHERE I
> SHOW THE VIDEO" first i try capture BMP and make other program read those
> BMP after i try to put video direct on program.
What has a BMP to do with a video ?
> I trying to made a another way to my program work showing the image
> direct on the DESKTOP but i have problem of FLICKER using:
Please explain where the flicker resides.
> HWND hForm = GetDesktopWindow() ;
Please tell where you need a HWND for first.
> Using HWND hForm = FindWindow("MYPROG",NULL); doenst work.
What is "MYPROG" ?
Is it "MY WEBCAMCAP" or "OTHER PROGRAM WHERE I SHOW THE VIDEO"
Which program is executing that statement ?
> ANY IDEIA?
Please start to explain better what is going on.
> My question is: How to capture video from a webcam without use FORM or
> DESKTOP like Handle.
Until now you did not anything with FORM or DESKTOP. Do you mean the
use of a TForm ? Or using GetDesktopWindow() ? Then you should
have told also where you needed the handle for.
> void __fastcall TFormPrincipal::FormCreate(TObject *Sender)
Better put all the code in the constructor. FormCreate() can be
tricky to use.
> AVICapDllHandle = LoadLibrary( "AVICAP32.DLL" );
Please supply the type of used variables.
I see that you only very much later in your code check if the library
is loaded. Would not it be better to check that right now?
> // HWND hForm = FormPrincipal->Handle;
If you wanted to use that that better:
HWND hForm = Handle;
> ctImg=0;
This is never used inyour code. Please post as little code as possible
to reproduce the problem. (But with all types, that compiles).
> if(AVICapDllHandle == 0)
> {
> MessageBox ( NULL, "LoadLibrary:\nAVICAP32.DLL not found.", "Error FS
> 002", MB_ICONSTOP );
> }
After this statement you go on. Is that what should be done ?
> hWndC = capCreateCaptureWindow("CamWin", WS_CHILD | WS_VISIBLE, 330, 250,
> tamXVL, tamYVL, hForm, 0 );
Did you try with hForm = NULL already ?
> "Edward" <registrados@via-rs.net> escreveu na mensagem
> news:3fc6476a$1@newsgroups.borland.com...
Here you quoted all the code of your first post.
Please do not quote complete posts. We had read that already.
Hans.
Re: WebCam Capture, BMP resize problem.
Author: Hans Galema
Date: Mon, 08 Dec 2003 09:32
Date: Mon, 08 Dec 2003 09:32
14 lines
1260 bytes
1260 bytes
Edward wrote: > Ok. There are errors. But you could comment on the errors. > But what is the solution? Did you try CopyRect() as suggested ? > Thanks any way. Why do you stop ? Hans.
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