Tomando fotos con la webcam

Tomando fotos con la webcam

Postby Antonio Linares » Thu Aug 25, 2016 6:53 pm

Aqui teneis un ejemplo completo para usar la webcam para tomar fotografías:

Se incluye el EXE y todo el código fuente. Puede ser muy util para vuestras aplicaciones:

https://bitbucket.org/fivetech/fivewin-contributions/downloads/dshow.zip

No funciona con Borland, sólo con Microsoft Visual Studio Community 2015

para construirlo, desde FWH\samples:

buildh32.bat dshow

para tomar una foto, simplemente haced click en la imagen de la cámara
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Tomando fotos con la webcam

Postby FranciscoA » Fri Aug 26, 2016 2:29 am

Gracias, Antonio.
Probado y funciona bien en Windows 7 Ultimate.
Saludos.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2159
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Tomando fotos con la webcam

Postby luisduque » Sat Aug 27, 2016 3:08 am

Maestro Antonio saludos

Descargué y perfecto en windows 10 trabaja muy bien, y twebcam no sirve con windows 8 ni con windows 10

Sin embargo al compilar da error porque no consigue #import "qedit.dll" raw_interfaces_only named_guids

┌────────────────────────────────────────────────────────────────────────────┐
│ FiveWin for Harbour 16.06 (MSVC++) Jun. 2016 Harbour development power │▄
│ (c) FiveTech 1993-2016 for Microsoft Windows 9X/NT/200X/ME/XP/Vista/7/8/10 │█
└────────────────────────────────────────────────────────────────────────────┘█
  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Compiling...
Harbour 3.2.0dev (r1603301435)
Copyright (c) 1999-2016, http://harbour-project.org/
Compiling 'dshow.prg' and generating preprocessed output to 'dshow.ppo'...
Lines 4908, Functions/Procedures 2
Generating C source output to 'dshow.c'... Done.
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23918 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

dshow.c
Creating library dshow.lib and object dshow.exp
dshow.obj : error LNK2019: unresolved external symbol _IID_ICaptureGraphBuilder2 referenced in function _HB_FUN_DSHOWCAMERA
dshow.obj : error LNK2019: unresolved external symbol _IID_IMediaControl referenced in function _HB_FUN_DSHOWCAMERA
dshow.obj : error LNK2019: unresolved external symbol _MEDIATYPE_Video referenced in function _HB_FUN_DSHOWCAMERA
dshow.obj : error LNK2019: unresolved external symbol _MEDIASUBTYPE_RGB24 referenced in function _HB_FUN_DSHOWCAMERA
dshow.obj : error LNK2019: unresolved external symbol _CLSID_CaptureGraphBuilder2 referenced in function _HB_FUN_DSHOWCAMERA
dshow.obj : error LNK2019: unresolved external symbol _CLSID_FilterGraph referenced in function _HB_FUN_DSHOWCAMERA
dshow.obj : error LNK2019: unresolved external symbol _CLSID_SystemDeviceEnum referenced in function _HB_FUN_DSHOWCAMERA
dshow.obj : error LNK2019: unresolved external symbol _CLSID_VideoInputDeviceCategory referenced in function _HB_FUN_DSHOWCAMERA
dshow.obj : error LNK2019: unresolved external symbol _PIN_CATEGORY_CAPTURE referenced in function _HB_FUN_DSHOWCAMERA
dshow.obj : error LNK2019: unresolved external symbol _PIN_CATEGORY_PREVIEW referenced in function _HB_FUN_DSHOWCAMERA
dshow.exe : fatal error LNK1120: 10 unresolved externals
* Linking errors *

C:\fwh\samples>
Fivewin 16.11
Harbour 3.2.0
Visual Studio 2015 community
MariaDb/MySql

Ing. MSc. Luis Duque
http://www.accasoft.net
luisduque
 
Posts: 133
Joined: Mon May 12, 2008 4:13 pm
Location: Venezuela

Re: Tomando fotos con la webcam

Postby Antonio Linares » Sat Aug 27, 2016 6:16 am

Luis,

Tienes que enlazar strmiids.lib
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Tomando fotos con la webcam

Postby luisduque » Sun Aug 28, 2016 4:19 am

Maestro Antonio

Actualicé AL Update3 de microsoft vihsual studio porque no tenia la libreria busque y había que actualizar para obtener strmiids.lib


probé con buildh32 dshow y perfecto sin errores

ahora en 64 bits me dio estos errores

┌────────────────────────────────────────────────────────────────────────────┐
│ FWH 64 for Harbour 16.06 (MSVC++) Jun.2016 Harbour development power │▄
│ (c) FiveTech 1993-2016 for Microsoft Windows 9X/NT/200X/ME/XP/Vista/7/8/10 │█
└────────────────────────────────────────────────────────────────────────────┘█
  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Compiling...
Harbour 3.2.0dev (r1603082110)
Copyright (c) 1999-2016, http://harbour-project.org/
Compiling 'dshow.prg' and generating preprocessed output to 'dshow.ppo'...
Lines 4905, Functions/Procedures 2
Generating C source output to 'dshow.c'... Done.
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24213.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

dshow.c
dshow.prg(48): error C2773: #import and #using available only in C++ compiler
dshow.prg(57): error C2039: 'Run': is not a member of 'IMediaControl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\control.h(473): note: see declaration of 'IMediaControl'
dshow.prg(64): error C2039: 'Stop': is not a member of 'IMediaControl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\control.h(473): note: see declaration of 'IMediaControl'
dshow.prg(86): error C2143: syntax error: missing ';' before ':'
dshow.prg(95): error C2440: 'function': cannot convert from 'const GUID' to 'const IID *const '
dshow.prg(95): warning C4024: 'CoCreateInstance': different types for formal and actual parameter 1
dshow.prg(96): error C2440: 'function': cannot convert from 'const IID' to 'const IID *const '
dshow.prg(96): warning C4024: 'CoCreateInstance': different types for formal and actual parameter 4
dshow.prg(102): error C2440: 'function': cannot convert from 'const GUID' to 'const IID *const '
dshow.prg(102): warning C4024: 'CoCreateInstance': different types for formal and actual parameter 1
dshow.prg(103): error C2440: 'function': cannot convert from 'const IID' to 'const IID *const '
dshow.prg(103): warning C4024: 'CoCreateInstance': different types for formal and actual parameter 4
dshow.prg(109): error C2039: 'SetFiltergraph': is not a member of 'ICaptureGraphBuilder'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\strmif.h(6854): note: see declaration of 'ICaptureGraphBuilder'
dshow.prg(114): error C2440: 'function': cannot convert from 'const GUID' to 'const IID *const '
dshow.prg(114): warning C4024: 'CoCreateInstance': different types for formal and actual parameter 1
dshow.prg(115): warning C4013: 'IID_PPV_ARGS' undefined; assuming extern returning int
dshow.prg(115): warning C4047: 'function': 'const IID *const ' differs in levels of indirection from 'int'
dshow.prg(115): warning C4024: 'CoCreateInstance': different types for formal and actual parameter 4
dshow.prg(115): error C2198: 'CoCreateInstance': too few arguments for call
dshow.prg(120): error C2039: 'CreateClassEnumerator': is not a member of 'ICreateDevEnum'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\strmif.h(1124): note: see declaration of 'ICreateDevEnum'
dshow.prg(129): error C2039: 'Next': is not a member of 'IEnumMoniker'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\objidl.h(8758): note: see declaration of 'IEnumMoniker'
dshow.prg(139): error C2039: 'BindToStorage': is not a member of 'IMoniker'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\objidl.h(9582): note: see declaration of 'IMoniker'
dshow.prg(144): error C2039: 'Read': is not a member of 'IPropertyBag'
c:\program files (x86)\windows kits\10\include\10.0.14393.0\um\oaidl.h(5259): note: see declaration of 'IPropertyBag'
dshow.prg(149): error C2039: 'Release': is not a member of 'IPropertyBag'
c:\program files (x86)\windows kits\10\include\10.0.14393.0\um\oaidl.h(5259): note: see declaration of 'IPropertyBag'
dshow.prg(167): error C2039: 'BindToStorage': is not a member of 'IMoniker'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\objidl.h(9582): note: see declaration of 'IMoniker'
dshow.prg(169): error C2039: 'Read': is not a member of 'IPropertyBag'
c:\program files (x86)\windows kits\10\include\10.0.14393.0\um\oaidl.h(5259): note: see declaration of 'IPropertyBag'
dshow.prg(174): error C2039: 'BindToObject': is not a member of 'IMoniker'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\objidl.h(9582): note: see declaration of 'IMoniker'
dshow.prg(181): error C2039: 'AddFilter': is not a member of 'IGraphBuilder'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\strmif.h(6628): note: see declaration of 'IGraphBuilder'
dshow.prg(187): error C2440: 'function': cannot convert from 'const CLSID' to 'const IID *const '
dshow.prg(187): warning C4024: 'CoCreateInstance': different types for formal and actual parameter 1
dshow.prg(188): error C2440: 'function': cannot convert from 'const IID' to 'const IID *const '
dshow.prg(188): warning C4024: 'CoCreateInstance': different types for formal and actual parameter 4
dshow.prg(195): error C2039: 'QueryInterface': is not a member of 'IBaseFilter'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\strmif.h(2321): note: see declaration of 'IBaseFilter'
dshow.prg(196): error C2065: 'DexterLib': undeclared identifier
dshow.prg(196): error C2143: syntax error: missing ')' before ':'
dshow.prg(202): error C2065: 'pSampleGrabber': undeclared identifier
dshow.prg(202): error C2223: left of '->SetBufferSamples' must point to struct/union
dshow.prg(212): error C2065: 'pSampleGrabber': undeclared identifier
dshow.prg(212): error C2223: left of '->SetMediaType' must point to struct/union
dshow.prg(212): error C2065: 'DexterLib': undeclared identifier
dshow.prg(212): error C2143: syntax error: missing ')' before ':'
dshow.prg(212): error C2059: syntax error: ')'
dshow.prg(218): error C2039: 'AddFilter': is not a member of 'IGraphBuilder'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\strmif.h(6628): note: see declaration of 'IGraphBuilder'
dshow.prg(224): error C2440: 'function': cannot convert from 'const CLSID' to 'const IID *const '
dshow.prg(224): warning C4024: 'CoCreateInstance': different types for formal and actual parameter 1
dshow.prg(225): error C2440: 'function': cannot convert from 'const IID' to 'const IID *const '
dshow.prg(225): warning C4024: 'CoCreateInstance': different types for formal and actual parameter 4
dshow.prg(232): error C2039: 'AddFilter': is not a member of 'IGraphBuilder'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\strmif.h(6628): note: see declaration of 'IGraphBuilder'
dshow.prg(238): error C2039: 'RenderStream': is not a member of 'ICaptureGraphBuilder2'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\strmif.h(7190): note: see declaration of 'ICaptureGraphBuilder2'
dshow.prg(245): error C2039: 'RenderStream': is not a member of 'ICaptureGraphBuilder2'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\strmif.h(7190): note: see declaration of 'ICaptureGraphBuilder2'
dshow.prg(253): error C2039: 'QueryInterface': is not a member of 'IGraphBuilder'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\strmif.h(6628): note: see declaration of 'IGraphBuilder'
dshow.prg(262): error C2039: 'Run': is not a member of 'IMediaControl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\control.h(473): note: see declaration of 'IMediaControl'
LINK : fatal error LNK1181: cannot open input file 'dshow.obj'
* Linking errors *

C:\fwh64\samples>
Fivewin 16.11
Harbour 3.2.0
Visual Studio 2015 community
MariaDb/MySql

Ing. MSc. Luis Duque
http://www.accasoft.net
luisduque
 
Posts: 133
Joined: Mon May 12, 2008 4:13 pm
Location: Venezuela

Re: Tomando fotos con la webcam

Postby Antonio Linares » Sun Aug 28, 2016 6:21 am

Luis,

en FWH\samples\build64.bat modifica esta línea asi:

cl -TP -W3 -O2 -c -I%hdir%\include %1.c

para que compile en modo C++

y añade esta línea:

echo strmiids.lib >> msvc.tmp
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Tomando fotos con la webcam

Postby luisduque » Sun Aug 28, 2016 5:29 pm

Maestro Antonio

Solucionado en 32bits y 64 bits

Perfecto y util, en mi caso lo uso como control de horario con foto, y tenia el problema con twebcam que no me funcionaba con win 8 ni win10

Gracias muy buen aporte
Fivewin 16.11
Harbour 3.2.0
Visual Studio 2015 community
MariaDb/MySql

Ing. MSc. Luis Duque
http://www.accasoft.net
luisduque
 
Posts: 133
Joined: Mon May 12, 2008 4:13 pm
Location: Venezuela

Re: Tomando fotos con la webcam

Postby Antonio Linares » Sun Aug 28, 2016 7:58 pm

muy bien
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Tomando fotos con la webcam

Postby karinha » Wed Jan 18, 2017 12:39 pm

Si no hay una camera instalada:

Code: Select all  Expand view  RUN

Application Internal Error - C:\DOWNLOAD\dshow\dshow.exe
Terminated at: 2016-08-25 16:16:02
Unrecoverable error 6005: Exception error:

    Exception Code:C0000005 ACCESS_VIOLATION
    Exception Address:013A276B
    EAX:001DFD34  EBX:00000000  ECX:00000000  EDX:00000001
    ESI:00000000  EDI:015124CC  EBP:001DFD44
    CS:EIP:001B:013A276B  SS:ESP:0023:001DFBDC
    DS:0023  ES:0023  FS:003B  GS:0000
    Flags:00010202
    Exception Parameters: 00000000 00000000
    CS:EIP: 8B 11 8B 45 D4 50 8B 4A 0C FF D1 89 45 FC 83 7D
    SS:ESP: 00000001 001DFD34 00000000 00000000 00000001 001DFC48 00000000 00000000 00000000 0000000F 01BF4758 00000000 731C5776 00000000 0000000F 00000000

    C stack:
    EIP:     EBP:       Frame: OldEBP, RetAddr, Params...
    013A276B 001DFD44   01646000 0145922D 00000020 00000000 00000000 00000000 00000000 014572C9 00000000 002F38AC


Modules:
013A0000 0037B000 C:\DOWNLOAD\dshow\dshow.exe
77B80000 00143000 C:\Windows\SYSTEM32\ntdll.dll
6D2E0000 0002F000 C:\Program Files\AVG\Av\avghookx.dll
760D0000 000D5000 C:\Windows\system32\kernel32.dll
74D60000 0004B000 C:\Windows\system32\KERNELBASE.dll
76250000 000C9000 C:\Windows\system32\USER32.dll
76320000 0004E000 C:\Windows\system32\GDI32.dll
765F0000 0000A000 C:\Windows\system32\LPK.dll
761B0000 0009D000 C:\Windows\system32\USP10.dll
750F0000 000AC000 C:\Windows\system32\msvcrt.dll
73F70000 00051000 C:\Windows\system32\WINSPOOL.DRV
73FD0000 00084000 C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18837_none_ec86b8d6858ec0bc\COMCTL32.dll
74EA0000 000A1000 C:\Windows\system32\ADVAPI32.dll
75410000 00019000 C:\Windows\SYSTEM32\sechost.dll
75300000 000A2000 C:\Windows\system32\RPCRT4.dll
76690000 0007B000 C:\Windows\system32\COMDLG32.dll
753B0000 00057000 C:\Windows\system32\SHLWAPI.dll
75480000 00C4C000 C:\Windows\system32\SHELL32.dll
751A0000 0015D000 C:\Windows\system32\ole32.dll
76A10000 0008F000 C:\Windows\system32\OLEAUT32.dll
740E0000 00009000 C:\Windows\system32\VERSION.dll
74060000 00005000 C:\Windows\system32\MSIMG32.dll
73F50000 0001C000 C:\Windows\system32\oledlg.dll
73980000 00191000 C:\Windows\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7601.23508_none_5c028c09a01213b0\gdiplus.dll
769F0000 0001F000 C:\Windows\system32\IMM32.DLL
764D0000 000CC000 C:\Windows\system32\MSCTF.dll
6CD70000 00003000 C:\Windows\system32\api-ms-win-core-synch-l1-2-0.DLL
731C0000 00040000 C:\Windows\system32\uxtheme.dll
73390000 00013000 C:\Windows\system32\dwmapi.dll
74A60000 0000C000 C:\Windows\system32\CRYPTBASE.dll
76600000 00083000 C:\Windows\system32\CLBCatQ.DLL
57DB0000 00177000 C:\Windows\system32\quartz.dll
73F00000 00032000 C:\Windows\system32\WINMM.dll
58A40000 00032000 C:\Windows\system32\qcap.dll
58A10000 00021000 C:\Windows\system32\MSVFW32.dll
65EB0000 00014000 C:\Windows\system32\devenum.dll
74F50000 0019D000 C:\Windows\system32\setupapi.dll
74E30000 00027000 C:\Windows\system32\CFGMGR32.dll
74E70000 00012000 C:\Windows\system32\DEVOBJ.dll
73EA0000 00021000 C:\Windows\system32\ntmarta.dll
75430000 00045000 C:\Windows\system32\WLDAP32.dll
74DE0000 0002F000 C:\Windows\system32\WINTRUST.dll
74B90000 00121000 C:\Windows\system32\CRYPT32.dll
74B80000 0000C000 C:\Windows\system32\MSASN1.dll
65E90000 0000B000 C:\Windows\system32\msdmo.dll

Called from DSHOWCAMERA(0)
Called from (b)MAIN(20) in dshow.prg
Called from TWINDOW:ACTIVATE(1028) in .\source\classes\WINDOW.PRG
Called from MAIN(20) in dshow.prg
------------------------------------------------------------------------
Application Internal Error - C:\DOWNLOAD\dshow\dshow.exe
Terminated at: 2017-01-18 10:35:15
Unrecoverable error 6005: Exception error:

    Exception Code:C0000005 ACCESS_VIOLATION
    Exception Address:0128276B
    EAX:0028FA24  EBX:00000000  ECX:00000000  EDX:00000001
    ESI:00000000  EDI:013F24CC  EBP:0028FA34
    CS:EIP:001B:0128276B  SS:ESP:0023:0028F8CC
    DS:0023  ES:0023  FS:003B  GS:0000
    Flags:00010202
    Exception Parameters: 00000000 00000000
    CS:EIP: 8B 11 8B 45 D4 50 8B 4A 0C FF D1 89 45 FC 83 7D
    SS:ESP: 00000001 0028FA24 00000000 7294B100 0000001A 00000001 0028F93C 00000000 00000000 00000000 0000000F 01C14758 00000000 72915776 00000000 0000000F

    C stack:
    EIP:     EBP:       Frame: OldEBP, RetAddr, Params...
    0128276B 0028FA34   01526000 0133922D 00000020 00000000 00000000 00000000 00000000 013372C9 00000000 003E38A4


Modules:
01280000 0037B000 C:\DOWNLOAD\dshow\dshow.exe
76D70000 00142000 C:\Windows\SYSTEM32\ntdll.dll
6C8A0000 0004E000 C:\Program Files\AVG\Av\avghookx.dll
74E50000 000D5000 C:\Windows\system32\kernel32.dll
73EF0000 0004B000 C:\Windows\system32\KERNELBASE.dll
747B0000 000C9000 C:\Windows\system32\USER32.dll
74E00000 0004E000 C:\Windows\system32\GDI32.dll
74300000 0000A000 C:\Windows\system32\LPK.dll
74240000 0009D000 C:\Windows\system32\USP10.dll
74630000 000AC000 C:\Windows\system32\msvcrt.dll
70320000 00051000 C:\Windows\system32\WINSPOOL.DRV
72950000 00084000 C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18837_none_ec86b8d6858ec0bc\COMCTL32.dll
75D30000 000A1000 C:\Windows\system32\ADVAPI32.dll
742E0000 00019000 C:\Windows\SYSTEM32\sechost.dll
75E00000 000A2000 C:\Windows\system32\RPCRT4.dll
74D70000 0007B000 C:\Windows\system32\COMDLG32.dll
75CD0000 00057000 C:\Windows\system32\SHLWAPI.dll
75080000 00C4C000 C:\Windows\system32\SHELL32.dll
74C10000 0015D000 C:\Windows\system32\ole32.dll
74B70000 00091000 C:\Windows\system32\OLEAUT32.dll
732C0000 00009000 C:\Windows\system32\VERSION.dll
732D0000 00005000 C:\Windows\system32\MSIMG32.dll
6B290000 0001C000 C:\Windows\system32\oledlg.dll
72650000 00191000 C:\Windows\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7601.23545_none_5c06d189a00e2c29\gdiplus.dll
75DE0000 0001F000 C:\Windows\system32\IMM32.DLL
746E0000 000CD000 C:\Windows\system32\MSCTF.dll
6B420000 00003000 C:\Windows\system32\api-ms-win-core-synch-l1-2-0.DLL
72910000 00040000 C:\Windows\system32\uxtheme.dll
72450000 00013000 C:\Windows\system32\dwmapi.dll
73C60000 0000C000 C:\Windows\system32\CRYPTBASE.dll
74880000 00083000 C:\Windows\system32\CLBCatQ.DLL
5FB50000 00177000 C:\Windows\system32\quartz.dll
72010000 00032000 C:\Windows\system32\WINMM.dll
75F10000 00032000 C:\Windows\system32\qcap.dll
71F10000 00021000 C:\Windows\system32\MSVFW32.dll
63340000 00014000 C:\Windows\system32\devenum.dll
740A0000 0019D000 C:\Windows\system32\setupapi.dll
73F40000 00027000 C:\Windows\system32\CFGMGR32.dll
73F70000 00012000 C:\Windows\system32\DEVOBJ.dll
72BD0000 00021000 C:\Windows\system32\ntmarta.dll
74360000 00045000 C:\Windows\system32\WLDAP32.dll
73FA0000 0002F000 C:\Windows\system32\WINTRUST.dll
73DB0000 00121000 C:\Windows\system32\CRYPT32.dll
73D80000 0000C000 C:\Windows\system32\MSASN1.dll
6EC70000 0000B000 C:\Windows\system32\msdmo.dll

Called from DSHOWCAMERA(0)
Called from (b)MAIN(20) in dshow.prg
Called from TWINDOW:ACTIVATE(1028) in .\source\classes\WINDOW.PRG
Called from MAIN(20) in dshow.prg
------------------------------------------------------------------------
 


Gracias, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Tomando fotos con la webcam

Postby MGA » Wed Jan 18, 2017 3:43 pm

Comprovado aqui também o problema mencionado por KARINHA!
ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1252
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: Tomando fotos con la webcam

Postby Antonio Linares » Wed Jan 18, 2017 4:45 pm

Estais usando Visual Studio 2015 o simplemente ejecutando el EXE ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Tomando fotos con la webcam

Postby karinha » Wed Jan 18, 2017 5:14 pm

Code: Select all  Expand view  RUN

 Pasta de C:\DOWNLOAD\dshow

18/01/2017  15:12    <DIR>          .
18/01/2017  15:12    <DIR>          ..
25/08/2016  20:49         3.617.280 dshow.exe
25/08/2016  20:49             8.059 dshow.prg
18/01/2017  10:37             7.306 HB_OUT.LOG
 
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Tomando fotos con la webcam

Postby armando.lagunas » Fri Jan 20, 2017 6:23 pm

gracias a Karinha, adapte una clase para que funcionase con bcc7 y xHarbour y la comparto con ustedes.


un ejemplo como se usa

Code: Select all  Expand view  RUN


STATIC FUNCTION FotoCamara()
LOCAL xWnd, xImg, oWC, lClick := .f., oBtn, cFile

    oWC           :=  tWebCamPhoto():New()
    cFile         := ".\fotos\Capturawebcam.bmp"
 
    DEFINE WINDOW xWnd FROM 2,2 TO 25, 75 TITLE "Capturar Fotografia por WebCam" NOZOOM NOMINIMIZE

           @ 25, 350 IMAGE xImg OF xWnd SIZE 200,160 PIXEL ADJUST UPDATE
                           xImg:nProgress := 0

           @ 280,  25 BUTTON oBtn PROMPT "Capturar" OF xWnd SIZE 85, 22 PIXEL UPDATE FONT xFont ACTION ( oWC:Clipboard( xImg, cFile ), lClick := .t., xWnd:Update())
           @ 280, 120 BUTTON oBtn PROMPT "Traspasa" OF xWnd SIZE 85, 22 PIXEL UPDATE FONT xFont ACTION ( LeerClipBoard( oImg ), oWC:End(), xWnd:End(),  ) WHEN lClick
           @ 280, 215 BUTTON oBtn PROMPT "Salir"    OF xWnd SIZE 85, 22 PIXEL UPDATE FONT xFont ACTION ( oWC:End()    , xWnd:End())
           @ 200, 360 BUTTON oBtn PROMPT "Opciones" OF xWnd SIZE 85, 22 PIXEL UPDATE FONT xFont ACTION oWC:Source()
           @ 200, 460 BUTTON oBtn PROMPT "Formato"  OF xWnd SIZE 85, 22 PIXEL UPDATE FONT xFont ACTION oWC:Formato()

    ACTIVATE WINDOW xWnd ON INIT ( xWnd:Center(), oWC:CreateWnd( xWnd , 25, 10, 300, 220), oWC:Connect() )

RETURN Nil

 


este es el resultado

Image

Esta es la clase

Code: Select all  Expand view  RUN


#Include "FiveWin.ch"
#include "Struct.ch"

#define WM_CAP_START             WM_USER
#define WM_CAP_DRIVER_CONNECT    WM_CAP_START + 10
#define WM_CAP_DRIVER_DISCONNECT WM_CAP_START + 11
#define WM_CAP_SET_PREVIEW       WM_CAP_START + 50
#define WM_CAP_SET_PREVIEWRATE   WM_CAP_START + 52
#define WM_CAP_SET_SCALE         WM_CAP_START + 53

#define WM_CAP_EDIT_COPY         WM_CAP_START + 30
#define WM_CAP_FILE_SAVEDIB      WM_CAP_START + 25

#define WM_CAP_DLG_VIDEOFORMAT   WM_CAP_START + 41
#define WM_CAP_DLG_VIDEOSOURCE   WM_CAP_START + 42
#define WM_CAP_GET_STATUS        WM_CAP_START + 54

#define HWND_BOTTOM   1
#define SWP_NOMOVE    2
#define SWP_NOSIZE    1
#define SWP_NOZORDER  4

STATIC _oWebcam_      :=  Nil

//------------------------------------------------

EXIT Procedure WebcamDisconnect()
  if _oWebcam_  <>  nil
     _oWebcam_:Disconnect()
     _owebcam_:=nil
  endif
return

//------------------------------------------------

CREATE CLASS tWebCamPhoto

  DATA nFrameRate                    INIT 66      // Velocidad de actualización de la WebCam
  DATA nJpgQuality                   INIT 75      // Calidad de los JPG

  DATA hWnd                                       // Handle de la centana de la imagen
  DATA aDrivers                                   // Drivers de captura disponibles
  DATA nDriver                                    // número del driver instalado + 1
  DATA lConnected                    INIT .F.     // ¿Está conectada>
  DATA cWebCamDriver                 INIT "Microsoft WDM Image Capture (Win32)"

  METHOD New( cDriver, lSelect )     CONSTRUCTOR  // Construye el objeto. cDriver es el nombre del driver a usar, recomendado guardar en ini. Si lSelect=.T. muestra la lista para escogerlo

  METHOD CreateWnd( oWnd1, nLeft, nTop, nWidth, nHeight, nStyle, cTitle )
                                                  // Crea la ventana para la cámara en oWnd1.

  METHOD Connect                                  // Conecta la cámara
  METHOD Disconnect                               // Desconecta la cámara
  METHOD Clipboard( oImg, cFile )                 // Captura la imagen en clipboard actualiza a oImg con la imagen capturada y guarda un archivo bmp
  METHOD Source()                                 // Configura la fuente de la webcam
  METHOD Formato()                                // Configura el formato de la imagen
  METHOD GetStatus()                              // Status de la imagen
  METHOD Resize()                                 // Redimensiona la ventana de la imagen
  METHOD End() INLINE ::Disconnect()              // Finaliza el objeto

ENDCLASS

//------------------------------------------------

METHOD New( cDriver, lSelect ) CLASS tWebCamPhoto

  DEFAULT cDriver :=   ::cWebCamDriver
  DEFAULT lSelect :=   .f.

  LoadLibrary("avicap32.dll")

  ::aDrivers      :=   WebCamList()
  ::nDriver       :=   aScan(::aDrivers,{|u| Upper(StrTran(cDriver,' '))==Upper(StrTran(u,' '))})

  IF ::nDriver    ==   0 .or. lSelect
     ::nDriver    :=   WebCamSelect( ::nDriver, ::aDrivers )
  ENDIF

  _oWebCam_       :=   Self

return Self

//------------------------------------------------

METHOD CreateWnd( oWnd1, nTop, nLeft, nWidth, nHeight, nStyle, cTitle ) CLASS tWebCamPhoto

  DEFAULT nTop    :=   0, ;
          nLeft   :=   0, ;
          nWidth  := 160, ;
          nHeight := 120
  DEFAULT nStyle  := nOr( WS_VISIBLE, WS_CHILD, WS_BORDER )

  IF    ::nDriver  > 0
        ::hWnd    := wCamCreaWnd( ::aDrivers[ ::nDriver ], nStyle, nLeft, nTop, nWidth, nHeight, oWnd1:hWnd, 0 )
  ENDIF

return  ::hWnd

//------------------------------------------------

METHOD Connect() CLASS tWebCamPhoto

   if   ::hWnd    <>  nil
        if SendMessage( ::hWnd, WM_CAP_DRIVER_CONNECT, ::nDriver-1, 0) = 1

           ::cWebCamDriver :=  ::aDrivers[ ::nDriver ]
           SendMessage(::hWnd, WM_CAP_SET_SCALE, 1, 0)
           SendMessage(::hWnd, WM_CAP_SET_PREVIEWRATE, ::nFrameRate, 0)
           SendMessage(::hWnd, WM_CAP_SET_PREVIEW, 1, 0)

           ::lConnected    :=  .T.
           ::Resize()

        else

           ::lConnected    :=  .F.
           ::hWnd          :=  Nil

        endif
   endif
return ::lConnected

//------------------------------------------------

METHOD Disconnect CLASS tWebCamPhoto

   IF  ::hWnd     <>  Nil .and. ::lConnected
       if SendMessage( ::hWnd, WM_CAP_DRIVER_DISCONNECT, 0, 0) = 1

          ::lConnected     :=  .F.
          _oWebCam_        :=  nil
       endif
   ENDIF
return nil

//------------------------------------------------

METHOD Clipboard( oImg, cFile ) CLASS tWebCamPhoto
  Local lSucc     :=.F.

  if   ::hWnd     <>   nil

      lSucc       :=  (  SendMessage( ::hWnd, WM_CAP_EDIT_COPY, 0, 0) = 1 )
      IF lSucc .and. oImg <> nil
         SendMessage( ::hWnd, WM_CAP_FILE_SAVEDIB, 0, cFile )
         oImg:LoadFromClipboard()
         oImg:Refresh()
      ENDIF

  endif
return lSucc

//------------------------------------------------

METHOD Source() CLASS tWebCamPhoto

  if  ::hWnd<>nil .and. ::lConnected
        SendMessage( ::hWnd, WM_CAP_DLG_VIDEOSOURCE, 0, 0 )
  endif

return nil

//------------------------------------------------

METHOD Formato() CLASS tWebCamPhoto

  if  ::hWnd<>nil .and. ::lConnected
        SendMessage( ::hWnd, WM_CAP_DLG_VIDEOFORMAT, 0, 0 )
        ::Resize()
  endif

return nil

//------------------------------------------------

METHOD GetStatus()
  Local oPoint, oStatus, cBuffer

  STRUCT oPoint
    MEMBER X AS LONG
    MEMBER Y AS LONG
  ENDSTRUCT

  STRUCT oStatus
    MEMBER nWidth         AS LONG                   // Width of the image
    MEMBER nHeight        AS LONG                   // Height of the image
    MEMBER lLive          AS LONG                   // Now Previewing video?
    MEMBER lOverlay       AS LONG                   // Now Overlaying video?
    MEMBER lScale         AS LONG                   // Scale image to client?
    MEMBER oXYScroll      AS STRING LEN 8           // AS POINTAPI     // Scroll position
    MEMBER lDefPalette    AS LONG                   // Using default driver palette?
    MEMBER lAudHardware   AS LONG                   // Audio hardware present?
    MEMBER lCapFile       AS LONG                   // Does capture file exist?
    MEMBER nCurVidFrm     AS LONG                   // # of video frames cap'td
    MEMBER nCurVidDropped AS LONG                   // # of video frames dropped
    MEMBER nCurWavSamples AS LONG                   // # of wave samples cap'td
    MEMBER nCurTimeEl     AS LONG                   // Elapsed capture duration
    MEMBER hPalCur        AS LONG                   // Current palette in use
    MEMBER lCapturing     AS LONG                   // Capture in progress?
    MEMBER nReturn        AS LONG                   // Error value after any operation
    MEMBER nVidAlloc      AS LONG                   // Actual number of video buffers
    MEMBER wAudAlloc      AS LONG                   // Actual number of audio buffers
  ENDSTRUCT

  oPoint:x           :=  0
  OPoint:y           :=  0
  oStatus:oXYScroll  :=  oPoint:cBuffer

  cBuffer            :=  oStatus:cBuffer

  SendMessage( ::hWnd, WM_CAP_GET_STATUS, Len(cBuffer), @cBuffer)

  oStatus:cBuffer    := cBuffer
return oStatus

//------------------------------------------------

METHOD Resize() CLASS tWebCamPhoto
  Local oStatus

  if ::hWnd<>nil .and. ::lConnected
    SysRefresh()
    oStatus   := ::GetStatus()
    SetWindowPos(::hWnd,HWND_BOTTOM,0,0,oStatus:nWidth,oStatus:nHeight,;
                 nOr(SWP_NOMOVE,SWP_NOZORDER ) )
    SysRefresh()
  endif

return nil

//------------------------------------------------

Function WebcamList()
   Local aDrivers    := {}, ;
         nDriver     := 0 , ;
         cName            , ;
         cVersion         , ;
         nLen        := 255

   DO WHILE .T.
      cName     :=  space(nLen)
      cVersion  :=  space(nLen)
      IF !wCamGetDrvDesc(nDriver, @cName, nLen, @cVersion, nLen)
         EXIT
      ENDIF
      if chr(0)$cName
         cName       :=  Left(cName,At(chr(0),cName)-1)
      endif
      if chr(0)$cVersion
         cVersion    :=  Left(cVersion,At(chr(0),cVersion)-1)
      endif
      aAdd( aDrivers ,  cName)
      nDriver++
   ENDDO

return aDrivers

//------------------------------------------------

STATIC Function WebcamSelect( nDriver, aDrivers )
  Local oDlg, oCbx
  Local cDriver
  Local lSelect    := .F.

  DEFAULT nDriver  := 0 , aDrivers  :=  WebcamList()
  IF Empty(aDrivers)
    MsgAlert('No Webcams')
    return 0
  ELSE
    cDriver  :=  aDrivers[Max(1,nDriver)]
    DEFINE DIALOG oDlg FROM 0,0 to 6,40 TITLE "Select webcam"
        @ 0,0 COMBOBOX oCbx VAR cDriver OF oDlg ITEMS aDrivers;
          SIZE 160,50 PIXEL
        @ 1.5, 4 BUTTON "Select" OF oDlg SIZE 40,12;
           ACTION (nDriver:=oCbx:nAt ,oDlg:End())
        @ 1.5,16 BUTTON "Cancel" OF oDlg SIZE 40,12;
           ACTION oDlg:End()
    ACTIVATE DIALOG oDlg CENTERED
  ENDIF

return nDriver

//------------------------------------------------

Function WebCamVersion(nDriver)
  Local cName, cVersion, nLen:=255
  DEFAULT nDriver:=0
  IF nDriver>0
    cName:=space(nLen); cVersion:=space(nLen)
    IF wCamGetDrvDesc(nDriver-1, @cName, nLen, @cVersion, nLen)
      if chr(0)$cVersion
        cVersion:=Left(cVersion,At(chr(0),cVersion)-1)
      endif
    ELSE
      cVersion:=nil
    ENDIF
  ENDIF
return cVersion

//------------------------------------------------

DLL32 STATIC FUNCTION wCamGetDrvDesc( nDriver AS _INT, cName AS STRING, nName AS LONG, cVersion AS STRING, nVersion AS LONG) AS BOOL PASCAL FROM "capGetDriverDescriptionA" LIB "avicap32.dll"

//------------------------------------------------

DLL32 STATIC FUNCTION wCamCreaWnd   ( cTitle AS STRING, nStyle AS LONG, x AS LONG, y AS LONG, nWidth AS LONG, nHeight AS LONG, hWndParent AS LONG, nID AS LONG) AS LONG PASCAL FROM "capCreateCaptureWindowA" LIB "avicap32.dll"

//------------------------------------------------


 
SkyPe: armando.lagunas@hotmail.com
Mail: armando.lagunas@gmail.com
User avatar
armando.lagunas
 
Posts: 346
Joined: Mon Oct 05, 2009 3:35 pm
Location: Curico-Chile

Re: Tomando fotos con la webcam

Postby karinha » Fri Jan 20, 2017 7:57 pm

Marabilloso Armando!! Congratulations!! Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Tomando fotos con la webcam

Postby karinha » Mon Mar 13, 2017 12:49 pm

Buén dia Armando. Donde está la FUNCTION LeerClipBoard() ?

Gracias, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Next

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 57 guests