Belini Posted December 28, 2015 Share Posted December 28, 2015 (edited) I'm trying to adapt the script posted here https://www.autoitscript.com/forum/topic/150536-simple-webcam-access-using-escapi/#comment-1136331 by mylise to display the webcam video and then save the picture .jpg but do not want to use the _ScreenCapture_Capture () does anyone know how to capture the specific area of the GUI and save to jpg?Changes I've ever done:expandcollapse popup;Font ==> https://www.autoitscript.com/forum/topic/150536-simple-webcam-access-using-escapi/#comment-1136331 #include <GDIplus.au3> #include <GUIConstantsEx.au3> Global $Width = 640 ;Escapi seems to use 640x480 (or lower) as webcam resolution and will Global $Height = 480 ; adjust the image size to $Width by $Height ;-------------------------------------------------------------------------- ; variables required for dshow escapi Local $tagSimpleCapParams = _ "ptr mTargetBuf;" & _ "int mWidth;" & _ "int mHeight;" Local $tSimpleCapParams = DllStructCreate($tagSimpleCapParams) Local $tTargetBuf = DllStructCreate("BYTE[" & $Width * $Height * 4 & "]") Global $pTargetBuf = DllStructGetPtr($tTargetBuf) DllStructSetData($tSimpleCapParams, 1, $pTargetBuf) DllStructSetData($tSimpleCapParams, 2, $Width) DllStructSetData($tSimpleCapParams, 3, $Height) Local $pSimpleCapParams = DllStructGetPtr($tSimpleCapParams) ;-------------------------------------------------------------------------- ;--------------------------------------------------------------------------- ;Escapi init Local $_escapi_Dll = DllOpen("escapi.dll") DllCall($_escapi_Dll, "int:cdecl", "initCapture", "int", 0, "ptr", $pSimpleCapParams) ;--------------------------------------------------------------------------- ;--------------------------------------------------------------------------- ; GUI create Global $hwnd = GUICreate("EscApi WebCam", 680, 520) GUISetBkColor(0x000000, $hwnd) GUISetState(@SW_SHOW, $hwnd) ;--------------------------------------------------------------------------- ;--------------------------------------------------------------------------- ; GDI init _GDIPlus_Startup() Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) ;--------------------------------------------------------------------------- While 1 video() Local $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Clean_up() ExitLoop EndIf Sleep(50) WEnd Func Clean_up() $return = DllCall($_escapi_Dll, "none:cdecl", "deinitCapture", "int", 0) DllClose($_escapi_Dll) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hwnd) EndFunc ;==>Clean_up Func video() ;--------------------------------------------------------------------------- ;Get frame DllCall($_escapi_Dll, "none:cdecl", "doCapture", "int", 0) Do $return = DllCall($_escapi_Dll, "int:cdecl", "isCaptureDone", "int", 0) Sleep(50) Until $return[0] = 1 ;--------------------------------------------------------------------------- ;Display frame $hBMP = _WinAPI_CreateBitmap($Width, $Height, 1, 32, $pTargetBuf) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 20, 20, $Width, $Height) _GDIPlus_BitmapDispose($hImage) _WinAPI_DeleteObject($hBMP) ;--------------------------------------------------------------------------- EndFunc ;==>video Edited December 28, 2015 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
computergroove Posted December 28, 2015 Share Posted December 28, 2015 My first thought is to use the UDF to open in the 0,0 axis and take a full screen shot. Save the image as whatever and open it in paint and resize it and save as jpeg. Why dont you want to use screen capture? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
Danyfirex Posted December 28, 2015 Share Posted December 28, 2015 (edited) You can save your bitmap instead make a screen capture._WinAPI_SaveHBITMAPToFile bitmap_GDIPlus_ImageSaveToFile ObjectBitmapSaludos Edited December 28, 2015 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Belini Posted December 28, 2015 Author Share Posted December 28, 2015 (edited) @Computergroove Full screen I can capture and also can resize but I want to put the webcam image as a control and I want to save the image to appear in the GUI without having to hide gui or having to put the gui in full screen!@Danyfirex I'll experiment with these commands you posted! Edited December 28, 2015 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now