WEBCAM : optimisation possible ?

Le
free
bonjour ,

j'ai trouvé ce bout de code qui permet de capturer une photo à partir

d'une WEBCAM. Associé à un Timer ca permet un Preview à la fréquence

qu'on veut. Peut_on se passer de l'étape de sauvegarde , couteuse en

BMP ?

merci.

Public Function MakePreview()
Call capGrabFrameNoStop(FrmMain.capwnd)
Call capFileSaveDIB(FrmMain.capwnd, App.path & "picture.bmp")
picturebox = LoadPicture(App.path & "picture.bmp")
Buffer.Picture = picturebox.Picture
End Function
Vidéos High-Tech et Jeu Vidéo
Téléchargements
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
LE TROLL
Le #15389901
Bonjour,

Tiens, j'ai fait une webcam de surveillance,
(sans enregistrement), mais je n'arrive pas à
modifier la taille de l'image...

Si tu arrives à enregistrer, ou à faire une
alerte de mouvement (par comparaison d'image), ou
à modifier la taille, fais-moi signe par email (en
bas)...
---------------------------------
ci-joint aussi fichiers...
---------------------------------

' surveillance Webcam : 1 objet = picture 1 :
form 1
'
Private Declare Function SetWindowPos Lib
"User32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As
Long, ByVal X As Long, _
ByVal Y As Long, ByVal cx As Long, ByVal cy As
Long, ByVal wFlags As Long) As Long
'
Private Declare Function capCreateCaptureWindow
Lib "avicap32.dll" Alias "capCreateCaptureWindowA"
( _
ByVal lpszWindowName As String, _
ByVal dwStyle As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal hwndParent As Long, _
ByVal nID As Long) As Long
'
Private Declare Function SendMessage Lib
"user32.dll" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByRef lParam As Any) As Long
'
Private Declare Sub ReleaseCapture Lib "User32"
()
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
'
Const WM_USER As Long = &H400
Const WM_CAP_DRIVER_CONNECT As Long = WM_USER +
10
Const WM_CAP_DRIVER_DISCONNECT As Long = WM_USER
+ 11
Const WM_CAP_GRAB_FRAME As Long = WM_USER + 60
Const WM_CAP_EDIT_COPY As Long = WM_USER + 30
Const Flags = &H2 Or &H1 Or &H40 Or &H10
'
Dim iResult As Long
Dim Resultat As Long
'

Sub Form_Load() ' lancement
m_pp.Checked = False
m_ap.Checked = True
Timer1.Interval = 40
iResult = capCreateCaptureWindow("Capture", 0,
0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight,
Me.hwnd, 0)
SendMessage iResult, WM_CAP_DRIVER_CONNECT, 0, 0
End Sub

Sub Picture1_MouseDown(Button As Integer, Shift As
Integer, X As Single, Y As Single)
If Button = 1 Then ' commande souris
Call ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN,
HTCAPTION, 0&
End If
If Button = 2 Then: PopupMenu m_pop
End Sub

Sub Timer1_Timer() ' balayage image
Clipboard.Clear
SendMessage iResult, WM_CAP_GRAB_FRAME, 0, 0
SendMessage iResult, WM_CAP_EDIT_COPY, 0, 0
Picture1.Picture = Clipboard.GetData
End Sub

Sub m_pp_Click() ' 1er plan
m_pp.Checked = True
m_ap.Checked = False
Resultat = SetWindowPos(Form1.hwnd, -1, 0, 0, 0,
0, Flags)
End Sub

Sub m_ap_Click() ' arrière plan
m_pp.Checked = False
m_ap.Checked = True
Resultat = SetWindowPos(Form1.hwnd, -2, 0, 0, 0,
0, Flags)
End Sub

Sub m_close_Click() ' fermer l'écran
Dim cancel As Integer
Call Form_Unload(cancel)
End Sub

Sub Form_Unload(cancel As Integer) ' terminer
SendMessage iResult, WM_CAP_DRIVER_DISCONNECT,
0, 0
Resultat = SetWindowPos(Form1.hwnd, -2, 0, 0, 0,
0, Flags)
Timer1.Enabled = False
Unload Form1
End
End Sub


--
Romans, logiciels, email, site personnel
http://irolog.free.fr/joe.htm
------------------------------------------------------------------------------------
"free" le message de news:
472d7db5$0$20095$
| bonjour ,
|
| j'ai trouvé ce bout de code qui permet de
capturer une photo à partir
|
| d'une WEBCAM. Associé à un Timer ca permet un
Preview à la fréquence
|
| qu'on veut. Peut_on se passer de l'étape de
sauvegarde , couteuse en
|
| BMP ?
|
| merci.
|
| Public Function MakePreview()
| Call capGrabFrameNoStop(FrmMain.capwnd)
| Call capFileSaveDIB(FrmMain.capwnd, App.path
& "picture.bmp")
| picturebox = LoadPicture(App.path &
"picture.bmp")
| Buffer.Picture = picturebox.Picture
| End Function
|
|


begin 666 Form1.frm
M5D524TE/3B U+C P#0I"96=I;B!60BY&;W)M($9O<FTQ( T*(" @075T;U)E
M9')A=R @(" @(#T@(" M,2 @)U1Rd-"B @($)O<F1E<E-T>6QE(" @(" ]
M(" @," @)TYO;F4-"B @($-L:65N=$AE:6=H=" @(" ](" @-#,P-0T*(" @
M0VQI96YT3&5F=" @(" @(#T@(" U-#,P#0H@("!#;&EE;G14;W @(" @(" @
M/2 @(#8Q-0T*(" @0VQI96YT5VED=&@@(" @(#T@(" U,C8U#0H@("!#;VYT
M<F]L0F]X(" @(" @/2 @(# @(" G1F%L<V4-"B @($EC;VX@(" @(" @(" @
M(" ](" @(D9O<FTQ+F9R>"(Z,# P, T*(" @3&EN:U1O<&EC(" @(" @(#T@
M(" B1F]R;3$B#0H@("!-87A"qT;VX@(" @(" @/2 @(# @(" G1F%L<V4-
M"B @($UI;D)U='1O;B @(" @(" ](" @," @("=&86QS90T*(" @4V-A;&5(
M96EG:'0@(" @(#T@(" R.#<-"B @(%-C86QE36]D92 @(" @(" ](" @," @
M)U5S97(-"B @(%-C86QE5VED=&@@(" @(" ](" @,S4Q#0H@("!3:&]W26Y4
M87-K8F%R(" @/2 @(# @(" G1F%L<V4-"B @($)E9VEN(%9"+E!I8W1U<F5"
M;W@@4&EC='5R93$@#0H@(" @("!!qO4F5D<F%W(" @(" @/2 @("TQ(" G
M5')U90T*(" @(" @075T;U-I>F4@(" @(" @(#T@(" M,2 @)U1Rd-"B @
M(" @($AE:6=H=" @(" @(" @(" ](" @-#(W-0T*(" @(" @3&5F=" @(" @
M(" @(" @(#T@(" P#0H@(" @("!-;W5S94EC;VX@(" @(" @/2 @(")&;W)M
M,2YF P,$,-"B @(" @($UO=7-E4&]I;G1E<B @(" ](" @.3D@("=#
M=7-T;VT-"B @(" @(%-C86QE2&5I9VAT(" @(" ](" @-#(Q-0T*(" @(" @
M4V-A;&57:61T:" @(" @(#T@(" U,3<U#0H@(" @("!486));F1E>" @(" @
M(" @/2 @(# -"B @(" @(%1O<" @(" @(" @(" @(" ](" @, T*(" @(" @
M5VED=&@@(" @(" @(" @(#T@(" U,C,U#0H@("!%;F0-"B @($)E9VEN(%9"
M+E1I;65R(%1I;65R,2 -"B @(" @($QE9G0@(" @(" @(" @(" ](" @-3(X
M, T*(" @(" @5&]P(" @(" @(" @(" @(#T@(" P#0H@("!%;F0-"B @($)E
M9VEN(%9"+DUE;G4@;5]P;W @#0H@(" @("!#87!T:6]N(" @(" @(" @/2 @
M("(B#0H@(" @("!6:7-I8FQE(" @(" @(" @/2 @(# @(" G1F%L<V4-"B @
M(" @($)E9VEN(%9"+DUE;G4@;5]P<" -"B @(" @(" @($-A<'1I;VX@(" @
M(" @(" ](" @(E!R96UI97(@<&QA;B(-"B @(" @(" @($-H96-K960@(" @
M(" @(" ](" @+3$@("=4<G5E#0H@(" @("!%;F0-"B @(" @($)E9VEN(%9"
M+DUE;G4@;5]A<" -"B @(" @(" @($-A<'1I;VX@(" @(" @(" ](" @(D%R
M<FGH<F4@<&QA;B(-"B @(" @(" @($-H96-K960@(" @(" @(" ](" @+3$@
M("=4<G5E#0H@(" @("!%;F0-"B @(" @($)E9VEN(%9"+DUE;G4@;5]C;&]S
M92 -"B @(" @(" @($-A<'1I;VX@(" @(" @(" ](" @(D9E<FUE<B!L)^EC
M<F%N(@T*(" @(" @16YD#0H@(" @("!"96=I;B!60BY-96YU(&U?<W1O<" -
M"B @(" @(" @($-A<'1I;VX@(" @(" @(" ](" @(D%B86YD;VXB#0H@(" @
M("!%;F0-"B @($5N9 T*16YD#0I!='1R:6)U=&)?3F%M92 ](")&;W)M
M,2(-"D%T=')I8G5T92!60E]';&]B86Q.86UE4W!A8V4@/2!&86QS90T*071T
M<FEBqE(%9"7T-R96%T86)L92 ]($9A;'-E#0I!='1R:6)U=&)?4')E
M9&5C;&%R961)9" ](%1Rd-"D%T=')I8G5T92!60E]%>'!O<V5D(#%L
M<V4-"@T*(" G('-U<G9E:6QL86YC92!796) Q(&]B:F5T(#T@<&EC
M='5R92 Q(#]R;2 Q#0H@(" @)PT*("!0<FEV871E($1E8VQA
M8W1I;&]W4&]S($QI8B B57-E<C,R(B!?#0H@(" @*$)Y5F%L
M(&AW;,@3&]@:%=N9$EN<V5R=$%F=&5R($%S($QO;F<L
M($)Y5F%L(%@@07,@3&]*(" @($)Y5F%L(%,@3&]
@@07,@3&]@,@3&]@=T9L86=S
M($%S($QO;F<I($%S($QO;F<-"B @(" G#0H@(%!R:79A=&&5C;&%R92!&
M=6YC=&EO;B!C87!#<F5A=&5#87!T=7)E5VEN9&]W($QI8B B879I8V%P,S(N
M9&QL(B!!;&EA<R B8V%P0W)E871E0V%P='5R95=I;F1O=T$B("@@7PT*(" @
M($)Y5F%L(&QP<WI7:6YD;W=.86UE($%S(%-T*(" @($)Y5F%L
M(&1W4W1Y;&,@3&]*(" @($)Y5F%L(%@@07,@3&]*
M(" @($)Y5F%L(%,@3&]*(" @($)Y5F%L(&Y7:61T:"!!<R!,
M;VYG+"!?#0H@(" @0GE686P@;DAE:6=H="!!<R!,;VYG+"!?#0H@(" @0GE6
M86P@:'=N9%!A<F5N="!!<R!,;VYG+"!?#0H@(" @0GE686P@;DE$($%S($QO
M;F<I($%S($QO;F<-"B @(" G#0H@(%!R:79A=&&5C;&%R92!&=6YC=&EO
M;B!396YD365S<V%G92!,:6(@(G5S97(S,BYD;&PB($%L:6%S(")396YD365S
M<V%G94$B("@@7PT*(" @($)Y5F%L(&AW;,@3&]*(" @($)Y
M5F%L('=-<V<@07,@3&]*(" @($)Y5F%L('7)A;2!!<R!,;VYG
M+"!?#0H@(" @0GE2968@;%!A<F%M($%S($%N>,@3&]N9PT*(" @("<-
M"B @4')I=F%T92!$96-L87)E(%-U8B!296QE87-E0V%P='5R92!,:6(@(E5S
M97(S,B(@*"D-"B @0V]N?3D-,0E545$].1$]73B ]("9(03$-"B @
M0V]N%1#05!424].(#T@,@T*(" G#0H@($-O;G-T(%=-7U5315(@07,@
M3&]N9R ]("9(-# P#0H@($-O;G-T(%=-7T-!4%]$4DE615)?0T].3D5#5"!!
M<R!,;VYG(#?55-%4B K(#$P#0H@($-O;G-T(%=-7T-!4%]$4DE615)?
M1$E30T].3D5#5"!!<R!,;VYG(#?55-%4B K(#$Q#0H@($-O;G-T(%=-
M7T-!4%]'4D%"7T9204U%($%S($QO;F<@/2!735]54T52(" -"B @0V]N
M?0T%07T5$251?0T]062!!<R!,;VYG(#?55-%4B K(#,P#0H@
M($-O;G-T($9L86=S(#T@)($]R("9(,2!/<B F2#0P($]R("9(,3 -"B @
M)PT*("!$:6T@:5)E<W5L="!!<R!,;VYG#0H@($1I;2!297-U;'1A="!!<R!,
M;VYG#0H@("<-"B @#0H@( T*4W5B($9O<FU?3&]A9"@I("<@;&%N8V5M96YT
M#0H@(&U?<' N0VAE8VME9" ]($9A;'-E#0H@(&U?87 N0VAE8VME9" ](%1R
Md-"B @5&EM97(Q+DEN=&5R=F%L(## -"B @:5)E<W5L=" ](&-A<$-R
M96%T94-A<'1U<F57:6YD;W<H(D-A<'1U<F4B+" P+" P+" P+"!0:6-T=7)E
M,2Y38V%L95=I9'1H+"!0:6-T=7)E,2Y38V%L94AE:6=H=":'=N9"P@
M,"D-"B @4V5N9$UE<W-A9V4@:5)E<W5L="?0T%07T12259%4E]#3TY.
M14-4+" P+" P#0I%;#0H-"@T*4W5B(%!I8W1U<F4Q7TUO=7-E1&]W
M;BA"qT;,@26YT96=,@26YT96=E"!!<R!3
M:6YG;&4L(%,@4VEN9VQE*0T*("!)9B!"qT;VX@/2 Q(%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QT870@/2!39717:6YD;W=0
M;W,H1F]R;3$N:'=N9"P@+3(L(# L(# L(# L(# L($9L86=S*0T*("!4:6UE
M<C$N16YA8FQE9" ]($9A;'-E#0H@(%5N;&]A9"!&;W)M,0T*("!%;F0-"D5N
'9"!3=6(-"@``
`
end

begin 666 webcam.vbp
M5'EP93U%>&4-"D9O<FT]1F]R;3$N9G)M#0I2969E<F5N8V4]*EQ'>S P,#(P
M-#,P+3 P,# M,# P,"U#,# P+3 P,# P,# P,# T-GTC,BXP(S C+BY<+BY<
M+BY M3$;VUA=&EO;@T*26-O;D9O<FT](D9O<FTQ(@T*4W1A<G1U<#TB1F]R
M;3$B#0I%>&5.86UE,S(](GèF-A;2YE>&4B#0I#;VUM86YD,S(](B(-"DYA
M;64](E!R;VIE=#$B#0I(96QP0V]N=&5X=$E$/2(P(@T*0V]M<&%T:6)L94UO
M9&4](C B#0I-86IO<E9E<CTQ#0I-:6YO<E9E<CTP#0I2979I<VEO;E9E<CTP
M#0I!qO26YC<F5M96YT5F5R/3 -"E-E<G9E<E-U<'!O<G1&:6QE<STP#0I6
M97)S:6]N0V]M<&%N>4YA;64](EA04U R(@T*0V]M<&EL871I;VY4>7!E/3 -
M"D]P=&EM:7IA=&EO;E1Y<&4], T*1F%V;W)096YT:75M4')O*'1M*3TP#0I#
M;V1E5FEE=T1E8G5G26YF;STP#0I.;T%L:6%S:6YG/3 -"D)O=6YD<T-H96-K
M/3 -"D]V97)F;&]W0VAE8VL], T*1FQ0;VEN=$-H96-K/3 -"D9$259#:&5C
M:STP#0I5;G)O=6YD961&4#TP#0I3=&%R=$UO9&4], T*56YA='1E;F1E9#TP
M#0I2971A:6YE9#TP#0I4:')E861097)/8FIE8W0], T*36%X3G5M8F5R3V94
M:')E861S/3$-"@T*6TU3(%1R86YS86-T:6]N(%-E<G9E<ET-"D%U=&]2969R
'97-H/3$-"@``
`
end

begin 666 Form1.frx
M" ```&QT````````!@,``&QT``#^`@`````"``$`(" ``! `$ #H`@``%@``
M`"@````@````0 ````$`! ````````(`````````````````````````````
M``" ``" ````@( `@ ```( `@ " @ ``P,# `(" @ ```/``/```#__P#_
M````_P#_`/__``#___`````````````````````````````````````````
M```````````````````````````````````````````````````````` ``
M````````````````#_``````````````````/__ ````````````````__
M__``````````````````/ ```````````````````#P````````````````
M```` ```````````````````/ ``````````````/ ```#P```` ``````
M``_P```` ```/```````#_ ```/ ```#_ `````/______________`
M`````/_P```` ```/_P```````/ ```/ ```#_`````````/ ```#P````
M `````````````` ```````````````````/ ```````````````````#P
M```````````````````` `````````````````/____````````````````
M`/__ `````````````````/_P```````````````````/ `````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````````#_________________
M_W____Z____]W___^^____?W___PA____K____Z___^OG_^OKZ__;Z^W_N
^X" [_V^OM_^OKZ__SZ^?__^O____K____"'___W]___^^____W?
9___^O____W_______________________P``
`
end

begin 666 webcam.vbw
M1F]R;3$@/2 T-"@L(# R+"!:+" M,C L(#$P+" U.3$L(#0U
&-"*
`
end
Publicité
Poster une réponse
Anonyme