Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Webcam UDF


  • Please log in to reply
40 replies to this topic

#1 LIMITER

LIMITER

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 482 posts

Posted 14 April 2008 - 02:17 PM

Thx rysiora for his awesome script :D (hope you don't get mad at me :D )

Original post (rysiora's version): http://www.autoitscript.com/forum/index.php?showtopic=27925

Just modified the script a little and made it an UDF ...

Example code :
#include <GUIConstants.au3> #include <Webcam.au3> $gui = GUICreate("Webcam UDF Test",640,480) _WebcamInit() _Webcam($gui,640,480,0,0) GUISetState(@SW_SHOW) Sleep(2000) ConsoleWrite("Taking snapshot ..." & @CRLF) _WebcamSnapShot() ConsoleWrite("Snapshot taken !" & @CRLF) While 1  $msg = GUIGetMsg()     If $msg = $GUI_EVENT_CLOSE Then   _WebcamStop()   Exit  EndIf  Sleep(1) WEnd



Webcam UDF
Attached File  Webcam.au3   6.68KB   5511 downloads

Edited by LIMITER, 10 May 2008 - 04:17 PM.








#2 ludocus

ludocus

    Possibly inventive crap going on right here

  • Active Members
  • PipPipPipPipPipPip
  • 668 posts

Posted 10 May 2008 - 10:37 AM

lol I made a webcam udf as well :)

#3 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 10 May 2008 - 10:48 AM

Link to the original topic. :( but otherwise good job converting it... I guess. :)

#4 Pain

Pain

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 627 posts

Posted 10 May 2008 - 10:56 AM

original post: http://www.autoitscript.com/forum/index.php?showtopic=27925

#5 goldenix

goldenix

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 738 posts

Posted 12 June 2008 - 08:21 PM

Why is it taking only 1 snapshot if I write the code like this? IT should Take 3 right?

For $sdf = 1 to 3     Sleep(2000)     ConsoleWrite("Taking snapshot ..." & @CRLF)     _WebcamSnapShot() Next


#6 LIMITER

LIMITER

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 482 posts

Posted 13 June 2008 - 07:32 AM

It should take 3 ....
I'll check the code later, cause now i don't have a webcam at this pc :)

#7 boomingranny

boomingranny

    Wayfarer

  • Active Members
  • Pip
  • 52 posts

Posted 18 July 2008 - 01:32 AM

any ideas on how you change the resolution of the output bmp file?
i can only ever get a 320x240 file, even though my web cam can do up to 1600x1200.

Any help would be much appreciated!

#8 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 18 July 2008 - 03:03 AM

Maybe....

#include <GUIConstants.au3> #include <Webcam.au3> $gui = GUICreate("Webcam UDF Test",1600,1200) _WebcamInit() _Webcam($gui,1600,120,0,0) GUISetState(@SW_SHOW) Sleep(2000) ConsoleWrite("Taking snapshot ..." & @CRLF) _WebcamSnapShot() ConsoleWrite("Snapshot taken !" & @CRLF) While 1  $msg = GUIGetMsg()     If $msg = $GUI_EVENT_CLOSE Then   _WebcamStop()   Exit  EndIf  Sleep(1) WEnd

Edited by Bert, 18 July 2008 - 03:07 AM.


#9 boomingranny

boomingranny

    Wayfarer

  • Active Members
  • Pip
  • 52 posts

Posted 18 July 2008 - 03:48 AM

thanks for your help Bert,
i should of mentioned, i had tried that - the visible image becomes pixulated, as if it is stretching the 320x240, and the output file is still 320x240 :muttley:

I am planning to use a webcam to do timelapse photos of a building being built, and then turn it into a video - but i need higher than 320x240...

EDIT:

Ok, worked it out
adding the line:
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DLG_VIDEOFORMAT, "int", 1, "int", 0)


triggers a dialog box which allows you to set resolution. once set, it will be remembered (i suspect thru the registry somewhere)

Cheers

Edited by boomingranny, 18 July 2008 - 05:12 AM.


#10 VAG

VAG

    Wayfarer

  • Active Members
  • Pip
  • 61 posts

Posted 24 July 2009 - 06:27 AM

May I know is it possible to adjust the quality settings of webcam (eg. brightness, contrast, gamma, etc) and is there any way of reading back the different settings from the current webcam before I set it?

#11 colafrysen

colafrysen

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 266 posts

Posted 05 August 2009 - 08:10 PM

Some thoughts on your UDF

First, is there a way to capture some output without having to open a GUI control. Because if I don't call _Webcam() the array $cap is never declared.
And as far as i understand, the _WebcamSnapShot() does read the output from the previously created controll.

And why open this DLL if it is never used?
$avi = DllOpen("avicap32.dll")


Edit: Saw that it was used...

Edited by colafrysen, 05 August 2009 - 08:54 PM.

Use the helpfile, It´s one of the best exlusive features of Autoit.http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCsScience flies us to the moon. Religion flies us into buildings.http://bit.ly/cAMPZV

#12 DJKMan

DJKMan

    Wayfarer

  • Active Members
  • Pip
  • 53 posts

Posted 06 August 2009 - 08:37 PM

Why is it taking only 1 snapshot if I write the code like this? IT should Take 3 right?

For $sdf = 1 to 3     Sleep(2000)     ConsoleWrite("Taking snapshot ..." & @CRLF)     _WebcamSnapShot() Next


The _WebcamSnapShot() function overwrites the default snapshot.bmp file. If you want three different shots then you must use a variable. Here's how you can achieve this. >_<

AutoIt         
#include <GUIConstants.au3> #include <Webcam.au3> #include <WindowsConstants.au3> $gui = GUICreate("Webcam UDF Test",640,480) _WebcamInit() _Webcam($gui,640,480,0,0) GUISetState(@SW_SHOW) Sleep(2000) For $sdf = 1 to 3     Sleep(2000)     ConsoleWrite("Taking snapshot ..." &$sdf& @CRLF)     _WebcamSnapShot(@DesktopDir & "\snapshot"&$sdf&".bmp") Next While 1  $msg = GUIGetMsg()     If $msg = $GUI_EVENT_CLOSE Then   _WebcamStop()   Exit  EndIf  Sleep(1) WEnd

My work in AutoIt (Not many yet):

Parse Large Text Files To 2D Array Quickly [With Chunk Size]

 

aliceround1.png

My artificial intelligence project coded entirely in AutoIt. Meet Alice Assistant: http://facebook.com/ProjectAliceAI

 


#13 IchBistTod

IchBistTod

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 257 posts

Posted 10 August 2009 - 08:55 AM

I dont really understand how this works, but could anyone show a small example of how this could be streamed over a network and displayed on a remote PC instead of on the local one? I think that would be reall cool.  I would try it but I am nto good in the area of DLL calls and such, as well as i dont understand how this works at all....

=]


#14 matwachich

matwachich

    Polymath

  • Active Members
  • PipPipPipPip
  • 222 posts

Posted 22 December 2009 - 12:52 PM

I've got a problem with te function _WebcamStop():
Every time i call it -> Autoit3.exe must close ..... error

I think the problem is on the $avi dll (avicap32.dll) because when I comment the line "DllClose($avi)" there is no problem!

but I want to close the webcam without exiting the script!

Anyone could help?!

#15 Zibit

Zibit

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 262 posts

Posted 06 January 2010 - 10:11 PM

get error variable not declared

#16 Splash

Splash

    Wayfarer

  • Active Members
  • Pip
  • 76 posts

Posted 21 January 2010 - 05:32 AM

With all webcam UDFs I get these errors:

C:\Documents and Settings\Gisele\Desktop\Nova pasta\webcam.au3(122,91) : WARNING: $WS_CHILD: possibly used before declaration.
$cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Gisele\Desktop\Nova pasta\webcam.au3(122,103) : WARNING: $WS_VISIBLE: possibly used before declaration.
$cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Gisele\Desktop\Nova pasta\webcam.au3(122,91) : ERROR: $WS_CHILD: undeclared global variable.
$cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Gisele\Desktop\Nova pasta\webcam.au3 - 1 error(s), 2 warning(s)


Why? I have tryed stable and beta.

Thanks in advance.

Edited by Splash, 21 January 2010 - 05:32 AM.


#17 Michel Claveau

Michel Claveau

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 352 posts

Posted 07 February 2010 - 08:30 AM

Hi!

I tested on four computers.
For the first, it's OK, whenever.
For other (three), if works only once. When I re-run the script, the webcam does not open, until I restart the computer.
I tried also to close/re-open a session, but the problem remains.

The first CPU is on W7
Other : W7 , W7 , XP

Any idea?

#18 stinson6016

stinson6016

    Seeker

  • Active Members
  • 41 posts

Posted 10 February 2010 - 09:46 PM

Nice, very nice
Gnatwork Networks

#19 galay

galay

    Seeker

  • New Members
  • 1 posts

Posted 05 April 2010 - 11:08 AM

I've got a problem with te function _WebcamStop():
Every time i call it -> Autoit3.exe must close ..... error

I think the problem is on the $avi dll (avicap32.dll) because when I comment the line "DllClose($avi)" there is no problem!

but I want to close the webcam without exiting the script!

Anyone could help?!


You need to destroy the gui used for webcam.
Call GUIDelete() before WebcamStop().

#20 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 05 April 2010 - 11:41 AM

You need to destroy the gui used for webcam.
Call GUIDelete() before WebcamStop().

Its April now. Useless first post.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users