Boa diversão.
O importante é incluir a lib Vfw32 que tem na mingw e msvc 2010
O exemplo é feito com hwgui
webcam_mingw.hbp
#
# $Id$
#
# Autor : Alexandre Simões
# VersÆo : 1.0
# Data : 16/08/2015
# Harbour : Harbour 3.4.0dev
# http://harbour-project.org/
# Compilador: MinGW GNU C 5.0.1 (32-bit)
# ---------------------------------------------------------------------------------
# Nome do Executável
# ---------------------------------------------------------------------------------
# -o<outname> Diretiva para nome de arquivo de sa¡da
-owebcam_mingw
# ---------------------------------------------------------------------------------
# Bibliotecas
# ---------------------------------------------------------------------------------
# l<libname> Diretiva para linkar com a biblioteca <libname>. <libname> deve omitir
# path, extensÆo e o prefixo 'lib' (… menos que fa‡a parte do nome-de-arquivo).
-lhwgui
-lprocmisc
-lgtwvg
-lgtwvt
-lhbct
-lhbwin
-lhbnf
-lxhb
-lhbblink
-lhbmemio
-lhbhpdf
-llibhpdf
-lpng
-lhbzebra
-lhbwin
-lversion
-lVfw32
hbssl.hbc
hbtip.hbc
hbxpp.hbc
xhb.hbc
# ---------------------------------------------------------------------------------
# Caminhos dos Includes
# ---------------------------------------------------------------------------------
# -i<p>|-incpath=<p> paths adicionais para pesquisa de arquivos headers
-incpath=\hb32fork\hwgui\include;
# ---------------------------------------------------------------------------------
# Caminho da Lib HPROC E HGAC
# ---------------------------------------------------------------------------------
# -L<libpath> path adicional para pesquisar por bibliotecas
-L\hb32fork\hwgui\lib;
# ---------------------------------------------------------------------------------
# Outros Parƒmetros
# ---------------------------------------------------------------------------------
# .\OBJ\ Grava os arquivos .c e .o na subpasta OBJ
# ---------------------------------------------------------------------------------
# -workdir=<dir> Working directory
# Diretiva para diret¢rio de trabalho da compila‡Æo.
# (default: .hbmk/plat/comp in incremental mode, OS temp
# directory otherwise).
-workdir=.\OBJ\
-gtgui
# ---------------------------------------------------------------------------------
# -[no]head[=<m>] Control source header parsing (in incremental build mode)
# <m> can be: native (uses compiler to extract
# dependencies), full (default, uses simple text parser on
# the whole file), dep, off.
-head=full
# ---------------------------------------------------------------------------------
# /n[<type>] No implicit starting procedure
# <type>: 0=no implicit starting procedure
# 1=no starting procedure at all
# 2=add starting procedure if necessary
-n
# ---------------------------------------------------------------------------------
# -[no]warn[=lev] Define o n¡vel de avisos (warnings) do compilador C
# <lev> pode ser: max, yes, low, no, def (padrão: yes).
-warn=no
# ---------------------------------------------------------------------------------
# -inc Habilita o modo de compilaçao incremental.
-inc
# ---------------------------------------------------------------------------------
# -[no]debug Adicionar/excluir informa‡äes de debug do compilador C.
# Para compilar com Harbour utilize a op‡Æo -b como de
# costume.
-b
# ---------------------------------------------------------------------------------
# -d<diretiva> Diretiva de compila‡Æo para ifdef
-dHARBOUR
# ---------------------------------------------------------------------------------
# -icon=<file> Seta o ícone para o aplicativo. <file> deve possuir um
# formato compat¡vel com a plataforma de destino.
# Diretiva para informar o icone da aplicação.
#-icon=P:\GERAL\HARBOUR\HARB_WIN.ICO
# ---------------------------------------------------------------------------------
# /u[<file>] Usa comando def set em <arquivo> (ou nenhum)
# Diretiva para carregar arquivo header (.ch) para toda
# aplicação.
-u+hbcompat.ch
-mt
# ---------------------------------------------------------------------------------
# Prg(s) e Rc(s)
# ---------------------------------------------------------------------------------
webfoto_mingw.prg
# ---------------------------------------------------------------------------------
webfoto_mingw.prg
#include "windows.ch"
#include "guilib.ch"
*---------------------------------------------------------------------------------------
FUNCTION Main
*---------------------------------------------------------------------------------------
Local oFontBtn
Local oFont := Nil
Local nColor
Local hWnd
Local cDirFoto := HB_DirBase()+"FOTOS\"
SET DELETE ON
SET DATE BRIT
cDriverName:=""
PREPARE FONT oFontBtn NAME "MS Sans Serif" WIDTH 0 HEIGHT -12
INIT WINDOW Form_Main MAIN TITLE "WebCam" ON INIT {||CameraSource(@cDriverName)}
MENU OF Form_Main
MENU TITLE "&WebCam"
MENUITEM "&Ligar Camera" ACTION {||previewCamera(cDriverName,@hWnd,Form_Main)}
MENUITEM "&Bater Foto" ACTION {||capFileSaveDIB(hWnd, cDirFoto+"teste.bmp")}
SEPARATOR
MENUITEM "&Sair" ACTION {||capDriverDisconnect(hWnd),hwg_EndWindow()}
ENDMENU
MENU TITLE "&Ajuda"
MENUITEM "&Sobre" ACTION hwg_MsgInfo(HWG_Version(1))
ENDMENU
ENDMENU
@ 10,0 IMAGE Image_1 SHOW "IMAGE" SIZE 500, 500
Form_Main:Activate()
RETURN NIL
*------------------------------------------------------------------------------*
FUNCTION CameraSource(cDriverName)
*------------------------------------------------------------------------------*
cDriverName:=""
cDriverVersion:=""
For i := 0 To 9
If capGetDriverDescription(i, @cDriverName, 128, @cDriverVersion, 128)
exit
EndIf
Next
RETURN cDriverName
*------------------------------------------------------------------------------*
FUNCTION PreviewCamera(cDriverName,hWnd,Form_Main)
*------------------------------------------------------------------------------*
Local i := 0
Local nMaxAttempt := 10
Local lConnect:=.f.
hWnd := capCreateCaptureWindow("WebCam", hb_bitOr(WS_CHILD, WS_VISIBLE), ;
Form_Main:Image_1:nLeft, Form_Main:Image_1:nTop, Form_Main:Image_1:nWidth, Form_Main:Image_1:nHeight, ;
Form_Main:handle, 1)
do while !lConnect .Or. ++i > nMaxAttempt
lConnect := capDriverConnect(hWnd, cDriverName)
enddo
If lConnect
// set the preview scale
capPreviewScale(hWnd, .T.)
// set the preview rate (ms)
capPreviewRate(hWnd, 30)
// start previewing the image
capPreview(hWnd, .T.)
Else
// error connecting to video source
hwg_DestroyWindow(hWnd)
hWnd := 0
EndIf
RETURN lConnect
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#include "vfw.h"
#if defined( __BORLANDC__ )
#pragma warn -use /* unused var */
#endif
HB_FUNC( CAPGETDRIVERDESCRIPTION )
{
TCHAR lpszName[128];
int iName = hb_parni(3);
TCHAR lpszVer[128];
int iVer = hb_parni(5);
BOOL bRet;
bRet = capGetDriverDescription( (WORD) hb_parnl(1), lpszName, iName, lpszVer, iVer );
hb_storc( lpszName, 2 );
hb_storc( lpszVer, 4 );
hb_retl( bRet );
}
HB_FUNC( CAPCREATECAPTUREWINDOW )
{
hb_retnl( (LONG) capCreateCaptureWindow( (LPCSTR) hb_parc(1),
(DWORD) hb_parnl(2),
hb_parni(3), hb_parni(4),
hb_parni(5), hb_parni(6),
(HWND) hb_parnl(7),
hb_parni(8) ) );
}
HB_FUNC( CAPDRIVERCONNECT )
{
hb_retl( capDriverConnect( (HWND) hb_parnl(1), hb_parni(2) ) );
}
HB_FUNC( CAPDRIVERDISCONNECT )
{
hb_retl( capDriverDisconnect( (HWND) hb_parnl(1) ) );
}
HB_FUNC( CAPPREVIEWRATE )
{
hb_retl( capPreviewRate( (HWND) hb_parnl(1), (WORD) hb_parnl(2) ) );
}
HB_FUNC( CAPPREVIEWSCALE )
{
hb_retl( capPreviewScale( (HWND) hb_parnl(1), hb_parl(2) ) );
}
HB_FUNC( CAPPREVIEW )
{
hb_retl( capPreview( (HWND) hb_parnl(1), hb_parl(2) ) );
}
HB_FUNC( CAPCAPTURESEQUENCE )
{
hb_retl( capCaptureSequence( (HWND) hb_parnl(1) ) );
}
HB_FUNC( CAPFILESAVEAS )
{
hb_retl( capFileSaveAs( (HWND) hb_parnl(1), hb_parc(2) ) );
}
HB_FUNC( CAPFILESAVEDIB )
{
hb_retl( capFileSaveDIB( (HWND) hb_parnl(1), hb_parc(2) ) );
}
#pragma ENDDUMP