Sign in to follow this  
Followers 0
nullschritt

Help sending webcam image over network

11 posts in this topic

#1 ·  Posted (edited)

So I saw this script on the forums to send webcam over network (I want to add this feature to a project I am working on)

But I was wondering if anyone knew a way to get the control to return the actual binary data of a frame to a variable rather than save it to a file, then load from file.

So I could just

get frame -> convert to jpg -> send over network (without writing to the hdd)

Here is the code and a link to the post. Thanks

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.6.1
Author: SYRAU3


#ce ----------------------------------------------------------------------------


#include
#include

$WM_CAP_START = 0x400
$WM_CAP_UNICODE_START = $WM_CAP_START + 100
$WM_CAP_PAL_SAVEA = $WM_CAP_START + 81
$WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81
$WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW
$WM_CAP_ABORT = $WM_CAP_START + 69
$WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46
$WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43
$WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41
$WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42
$WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10
$WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11
$WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14
$WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12
$WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12
$WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13
$WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13
$WM_CAP_EDIT_COPY = $WM_CAP_START + 30
$WM_CAP_END = $WM_CAP_UNICODE_END
$WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22
$WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21
$WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21
$WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23
$WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23
$WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25
$WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25
$WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20
$WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20
$WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24
$WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36
$WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1
$WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67
$WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67
$WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65
$WM_CAP_GET_STATUS = $WM_CAP_START + 54
$WM_CAP_GET_USER_DATA = $WM_CAP_START + 8
$WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44
$WM_CAP_GRAB_FRAME = $WM_CAP_START + 60
$WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61
$WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83
$WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84
$WM_CAP_PAL_OPENA = $WM_CAP_START + 80
$WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80
$WM_CAP_PAL_PASTE = $WM_CAP_START + 82
$WM_CAP_SEQUENCE = $WM_CAP_START + 62
$WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63
$WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35
$WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85
$WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2
$WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2
$WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5
$WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3
$WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3
$WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6
$WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7
$WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4
$WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66
$WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66
$WM_CAP_SET_OVERLAY = $WM_CAP_START + 51
$WM_CAP_SET_PREVIEW = $WM_CAP_START + 50
$WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52
$WM_CAP_SET_SCALE = $WM_CAP_START + 53
$WM_CAP_SET_SCROLL = $WM_CAP_START + 55
$WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64
$WM_CAP_SET_USER_DATA = $WM_CAP_START + 9
$WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45
$WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72
$WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71
$WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70
$WM_CAP_STOP = $WM_CAP_START + 68



$avi = DllOpen("avicap32.dll")
$user = DllOpen("user32.dll")
$snapfile = @ScriptDir & "\scrshot.bmp"
$Main = GUICreate("Camera", 350, 270)
$cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD, $WS_VISIBLE), "int", 15, "int", 15, "int", 320, "int", 240, "hwnd", $Main, "int", 1)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0)
GUISetState(@SW_SHOW)
HotKeySet("{TAB}", "SnapShot")
HotKeySet("{ALT}", "Refresh")
OnAutoItExitRegister("ExitFunc")
Local $szIPADDRESS = @IPAddress1
Local $nPORT = 6965
TCPStartup()
$ConnectedSocket = -1
$ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT)



While 1
_FileSend(@ScriptDir & "\Image.jpg", $ConnectedSocket)
SnapShot()

Sleep(500)
If GUIGetMsg() = -3 Then ExitFunc()
Sleep(1)
WEnd

Func SnapShot()
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $snapfile)
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($snapfile)
$sCLSID = _GDIPlus_EncodersGetCLSID("JPG")
_GDIPlus_ImageSaveToFileEx($hImage, @ScriptDir & "\Image.jpg", $sCLSID)
_GDIPlus_ImageDispose($hImage)
_WinAPI_DeleteObject($hImage)
_GDIPlus_Shutdown()
EndFunc ;==>SnapShot


Func Refresh()
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0)
EndFunc ;==>Refresh

Func _FileSend($sFile, $iMainSocket)
Local $sBuff, $iFileOp, $sRecv

$iFileOp = FileOpen($sFile, 16)
If @error Then Return 0
$sBuff = Binary(StringTrimLeft($sFile, StringInStr($sFile, "\", -1, -1)) & ",") & FileRead($iFileOp)
FileClose($iFileOp)

While BinaryLen($sBuff)
$iSendReturn = TCPSend($iMainSocket, $sBuff)
If @error Then Return 0

$sBuff = BinaryMid($sBuff, $iSendReturn + 1, BinaryLen($sBuff) - $iSendReturn)
WEnd

Return 1
EndFunc ;==>_FileSend

Func ExitFunc()
Local $hImage
_GDIPlus_ImageDispose($hImage)
_WinAPI_DeleteObject($hImage)
_GDIPlus_Shutdown()
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_END, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)
DllClose($user)
FileDelete($snapfile)
FileDelete(@ScriptDir & "\Image.jpg")
Exit
EndFunc ;==>ExitFunc
Edited by nullschritt

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

I have just made it for you, so here it is.

Server side :

#include <Memory.au3>
#include <ScreenCapture.au3> ;includes GDIPlus.au3

_GDIPlus_Startup() ;don't forget ;-)
$HBITMAP = _ScreenCapture_Capture("", 0, 0, 100, 100)
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($HBITMAP)
$s = Bitmap2BinaryString($hBitmap)

$szIPADDRESS = "127.0.0.1"
$nPORT = 65432

TCPStartup()

$MainSocket = TCPListen($szIPADDRESS, $nPORT)
If $MainSocket = -1 Then Exit

Do
$ConnectedSocket = TCPAccept($MainSocket)
Until $ConnectedSocket <> -1

TCPSend($ConnectedSocket, $s)

TCPCloseSocket($ConnectedSocket)
TCPShutdown()

_WinAPI_DeleteObject($HBITMAP)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_ShutDown()

Exit

;GDIPlus.au3 must be included; JPG quality: 0 - 100 (worst - best)
;$hBitmap must be a GDI+ compatible bitmap format!!!
Func Bitmap2BinaryString($hBitmap, $JPEG_Quality = 90) ;code by Andreik, modified by UEZ
    Local $declared = True
    If Not $ghGDIPDll Then
        _GDIPlus_Startup()
        $declared = False
    EndIf
    Local $STREAM = DllCall("ole32.dll", "uint", "CreateStreamOnHGlobal", "ptr", 0, "bool", 1, "ptr*", 0)
    $STREAM = $STREAM[3]
    Local $JPG_ENCODER = _GDIPlus_EncodersGetCLSID("JPG")
    Local $TAG_ENCODER = _WinAPI_GUIDFromString($JPG_ENCODER)
    Local $PTR_ENCODER = DllStructGetPtr($TAG_ENCODER)
    Local $tParams = _GDIPlus_ParamInit (1)
    Local $tData = DllStructCreate("int Quality")
    DllStructSetData($tData, "Quality", $JPEG_Quality)
    Local $pData = DllStructGetPtr($tData)
    _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData)
    Local $pParams = DllStructGetPtr($tParams)
    DllCall($ghGDIPDll, "uint", "GdipSaveImageToStream", "ptr", $hBitmap, "ptr", $STREAM, "ptr", $PTR_ENCODER, "ptr", $pParams)
    $tData = 0
    $tParams = 0
    Local $MEMORY = DllCall("ole32.dll", "uint", "GetHGlobalFromStream", "ptr", $STREAM, "ptr*", 0)
    $MEMORY = $MEMORY[2]
    Local $MEM_SIZE = _MemGlobalSize($MEMORY)
    Local $MEM_PTR = _MemGlobalLock($MEMORY)
    Local $DATA_STRUCT = DllStructCreate("byte[" &amp;amp; $MEM_SIZE &amp;amp; "]", $MEM_PTR)
    Local $DATA = DllStructGetData($DATA_STRUCT, 1)
    Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    Local $aCall = DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $STREAM, "dword", 8 + 8 * @AutoItX64, "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT))
    _MemGlobalFree($MEMORY)
    If Not $declared Then _GDIPlus_Shutdown()
    Return $DATA
EndFunc

Client side :

$szIPADDRESS = "127.0.0.1"
$nPORT = 65432

TCPStartup()

$ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT)
If @error Then Exit -1

$h = FileOpen("mypic.jpg", 16 + 1)

While 1
$b = TCPRecv($ConnectedSocket, 2048)
If @error Then ExitLoop

If $b <> "" Then
FileWrite($h, $B)
EndIf
WEnd

FileClose($h)

TCPCloseSocket($ConnectedSocket)
TCPShutdown()

Edit : This example works for your own computer, change the ip address. (server side: local ip; client side: server ip)

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Or here: (which is similar to what FireFox has posted).

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Hi,

I have just made it for you, so here it is.

Server side :

#include <Memory.au3>
#include <ScreenCapture.au3> ;includes GDIPlus.au3

_GDIPlus_Startup() ;don't forget ;-)
$HBITMAP = _ScreenCapture_Capture("", 0, 0, 100, 100)
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($HBITMAP)
$s = Bitmap2BinaryString($hBitmap)

$szIPADDRESS = "127.0.0.1"
$nPORT = 65432

TCPStartup()

$MainSocket = TCPListen($szIPADDRESS, $nPORT)
If $MainSocket = -1 Then Exit

Do
$ConnectedSocket = TCPAccept($MainSocket)
Until $ConnectedSocket <> -1

TCPSend($ConnectedSocket, $s)

TCPCloseSocket($ConnectedSocket)
TCPShutdown()

_WinAPI_DeleteObject($HBITMAP)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_ShutDown()

Exit

;GDIPlus.au3 must be included; JPG quality: 0 - 100 (worst - best)
;$hBitmap must be a GDI+ compatible bitmap format!!!
Func Bitmap2BinaryString($hBitmap, $JPEG_Quality = 90) ;code by Andreik, modified by UEZ
Local $declared = True
If Not $ghGDIPDll Then
_GDIPlus_Startup()
$declared = False
EndIf
Local $STREAM = DllCall("ole32.dll", "uint", "CreateStreamOnHGlobal", "ptr", 0, "bool", 1, "ptr*", 0)
$STREAM = $STREAM[3]
Local $JPG_ENCODER = _GDIPlus_EncodersGetCLSID("JPG")
Local $TAG_ENCODER = _WinAPI_GUIDFromString($JPG_ENCODER)
Local $PTR_ENCODER = DllStructGetPtr($TAG_ENCODER)
Local $tParams = _GDIPlus_ParamInit (1)
Local $tData = DllStructCreate("int Quality")
DllStructSetData($tData, "Quality", $JPEG_Quality)
Local $pData = DllStructGetPtr($tData)
_GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData)
Local $pParams = DllStructGetPtr($tParams)
DllCall($ghGDIPDll, "uint", "GdipSaveImageToStream", "ptr", $hBitmap, "ptr", $STREAM, "ptr", $PTR_ENCODER, "ptr", $pParams)
$tData = 0
$tParams = 0
Local $MEMORY = DllCall("ole32.dll", "uint", "GetHGlobalFromStream", "ptr", $STREAM, "ptr*", 0)
$MEMORY = $MEMORY[2]
Local $MEM_SIZE = _MemGlobalSize($MEMORY)
Local $MEM_PTR = _MemGlobalLock($MEMORY)
Local $DATA_STRUCT = DllStructCreate("byte[" &amp;amp; $MEM_SIZE &amp;amp; "]", $MEM_PTR)
Local $DATA = DllStructGetData($DATA_STRUCT, 1)
Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
Local $aCall = DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $STREAM, "dword", 8 + 8 * @AutoItX64, "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT))
_MemGlobalFree($MEMORY)
If Not $declared Then _GDIPlus_Shutdown()
Return $DATA
EndFunc

Client side :

$szIPADDRESS = "127.0.0.1"
$nPORT = 65432

TCPStartup()

$ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT)
If @error Then Exit -1

$h = FileOpen("mypic.jpg", 16 + 1)

While 1
$b = TCPRecv($ConnectedSocket, 2048)
If @error Then ExitLoop

If $b <> "" Then
FileWrite($h, $B)
EndIf
WEnd

FileClose($h)

TCPCloseSocket($ConnectedSocket)
TCPShutdown()

Edit : This example works for your own computer, change the ip address. (server side: local ip; client side: server ip)

Br, FireFox.

Thank you, but I am wondering, how to get this binary directly from the cam control, like a snapshot of the camera, without actually snapshotting the screen (just a frame from the camera) (so that this would work even if the window containing the webcam control was minimized) I hope I explained what I mean properly

Share this post


Link to post
Share on other sites

And for what reason do you wish to spy on someone?


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

And for what reason do you wish to spy on someone?

Actually, I am making an encrypted instant message/video client, kind of like skype. (it would be annoying to have to have the window on top to broadcast cam)

This says more about you, than it does me, that you were automatically the one assuming it's use was for spying on people. :thumbsdown:

Edited by nullschritt

Share this post


Link to post
Share on other sites

Is there maybe a way to use GDI Plus to read the data from the control directly, or a way to get a dllcall to return the image binary instead of save it to a file?

Just ideas for minds more intelligent than mine on this subject.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Is there maybe a way to use GDI Plus to read the data from the control directly, or a way to get a dllcall to return the image binary instead of save it to a file?

Just ideas for minds more intelligent than mine on this subject.

I assume it's not possible to have a good webcam stream with autoit, unless you have a dll made especially for this.

I don't know If you searched on the forum, but with this one you will be able to send frames by frames (which is not a real stream or you need a good connection) :

So you will need to search for a dll over internet I presume.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I assume it's not possible to have a good webcam stream with autoit, unless you have a dll made especially for this.

I don't know If you searched on the forum, but with this one you will be able to send frames by frames (which is not a real stream or you need a good connection) :

So you will need to search for a dll over internet I presume.

Br, FireFox.

I think perhaps there is a solution here

this is code I found on a russian website (perhaps this with another gdi function in the _DrawPoint function) [maybe _GDIPlus_BitmapCreateFromGraphics]

$WM_CAP_START = 0x400
$WM_CAP_UNICODE_START = $WM_CAP_START +100
$WM_CAP_PAL_SAVEA = $WM_CAP_START + 81
$WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81
$WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW
$WM_CAP_ABORT = $WM_CAP_START + 69
$WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46
$WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43
$WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41
$WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42
$WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10
$WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11
$WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14
$WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12
$WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12
$WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13
$WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13
$WM_CAP_EDIT_COPY = $WM_CAP_START + 30
$WM_CAP_END = $WM_CAP_UNICODE_END
$WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22
$WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21
$WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21
$WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23
$WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23
$WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25
$WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25
$WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20
$WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20
$WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24
$WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36
$WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1
$WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67
$WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67
$WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65
$WM_CAP_GET_STATUS = $WM_CAP_START + 54
$WM_CAP_GET_USER_DATA = $WM_CAP_START + 8
$WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44
$WM_CAP_GRAB_FRAME = $WM_CAP_START + 60
$WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61
$WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83
$WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84
$WM_CAP_PAL_OPENA = $WM_CAP_START + 80
$WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80
$WM_CAP_PAL_PASTE = $WM_CAP_START + 82
$WM_CAP_SEQUENCE = $WM_CAP_START + 62
$WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63
$WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35
$WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85
$WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2
$WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2
$WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5
$WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3
$WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3
$WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6
$WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7
$WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4
$WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66
$WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66
$WM_CAP_SET_OVERLAY = $WM_CAP_START + 51
$WM_CAP_SET_PREVIEW = $WM_CAP_START + 50
$WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52
$WM_CAP_SET_SCALE = $WM_CAP_START + 53
$WM_CAP_SET_SCROLL = $WM_CAP_START + 55
$WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64
$WM_CAP_SET_USER_DATA = $WM_CAP_START + 9
$WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45
$WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72
$WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71
$WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70
$WM_CAP_STOP = $WM_CAP_START + 68

#include
#include
#include
#include
#include
#include
#include

Opt('MustDeclareVars', 1)

Global $hAvi = DllOpen('avicap32.dll')
Global $hUser = DllOpen('user32.dll')

Global $hMainWin = GUICreate('Main', 230, 225)
Global $hVideoWin = GUICreate('Camera', 230, 225, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP), -1, $hMainWin)

GUISetState(@SW_SHOW, $hMainWin)
GUISetState(@SW_SHOW, $hVideoWin)

Global $hCap1 = DllCall($hAvi, 'int', 'capCreateCaptureWindow', 'str', 'cap', 'int', BitOR($WS_CHILD, $WS_VISIBLE), 'int', 15, 'int', 10, 'int', 200, 'int', 200, 'hwnd', $hVideoWin, 'int', 1)

DllCall($hUser, 'int', 'SendMessage', 'hWnd', $hCap1[0], 'int', $WM_CAP_DRIVER_CONNECT, 'int', 0, 'int', 0)
DllCall($hUser, 'int', 'SendMessage', 'hWnd', $hCap1[0], 'int', $WM_CAP_SET_SCALE, 'int', 1, 'int', 1)
DllCall($hUser, 'int', 'SendMessage', 'hWnd', $hCap1[0], 'int', $WM_CAP_SET_OVERLAY, 'int', 1, 'int', 1)
DllCall($hUser, 'int', 'SendMessage', 'hWnd', $hCap1[0], 'int', $WM_CAP_SET_PREVIEW, 'int', 1, 'int', 1)
DllCall($hUser, 'int', 'SendMessage', 'hWnd', $hCap1[0], 'int', $WM_CAP_SET_PREVIEWRATE, 'int', 1, 'int', 1)

_DrawPoint($hMainWin, 40, 40, 2, '00d119')
_DrawPoint($hMainWin, 58, 64, 8, 'ff0000', 85)
_DrawPoint($hMainWin, 97, 84, 16, 'fffc00', 70)

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
DllClose($hUser)
Exit
EndSwitch
Wend

Func _DrawPoint($hWin, $iX, $iY, $iWidth=2, $sRGB='000000', $sAlpha='100')
Local $hGraphic, $hPen

; Draw a polygon
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWin)
$hPen = _GDIPlus_PenCreate('0x' & Hex((255*$sAlpha)/100, 2) & $sRGB, $iWidth)

_GDIPlus_GraphicsDrawLine ($hGraphic, $iX, $iY, $iX+$iWidth, $iY, $hPen)

; Clean up resources
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
EndFunc

This is what I have tried, but it just returns black, I feel like I might be close to something, but this is the first I have ever used gdi+

So I don't know if maybe I am using the functions wrong?

func _snapshot()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hMainWin)
$bitmap = _GDIPlus_BitmapCreateFromGraphics(200, 200, $hGraphic)
$s = Bitmap2BinaryString($Bitmap)
FileWrite("test.jpg", $s)
_GDIPlus_GraphicsDispose($hGraphic)
EndFunc
Edited by nullschritt

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Okay also I found another DLL that does return the bitmap data of the current frame.

But to be honest I have no idea at all how to call the method(GetCurrentImage) in autoit? (could someone please explain)

http://touchless.codeplex.com/sourcecontrol/list/changesets?ProjectName=touchless

Also, I am not entirely sure, if the method is in "TouchlessLib.dll" or "WebCamLib.dll" (I would assume it's the later of the two)

Could someone perhaps explain?

Edited by nullschritt

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I don't have a web cam to test but can you try to use Windows Screenshooter to see whether it can be captured with built-in functions.

If you can capture it with Windows Screenshooter (there are some different ways of capturing) then it should also be possible to capture it with AutoIt and send it over network.

Please try and tell me whether it is working or not.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0