Alexxander Posted February 9, 2014 Share Posted February 9, 2014 (edited) hi all can i compare 2 images without being 100% identical ? i have taken this 2 pic from my laptop without moving it (with 2 seconds delay between the 2 pics) if u focused in them you will find that they are not 100 identical (i don't know whey) i used an image compare script i found it here expandcollapse popup#include <GDIPlus.au3> _GDIPlus_Startup() $fname1=FileOpenDialog("First image","","All images(*.bmp;*.jpg;*.png;)") If $fname1="" Then Exit $fname2=FileOpenDialog("Second image image","","All images(*.bmp;*.jpg;*.png;)") If $fname2="" Then Exit $bm1 = _GDIPlus_ImageLoadFromFile($fname1) $bm2 = _GDIPlus_ImageLoadFromFile($fname2) MsgBox(0, "bm1==bm2", CompareBitmaps($bm1, $bm2)) _GDIPlus_ImageDispose($bm1) _GDIPlus_ImageDispose($bm2) _GDIPlus_Shutdown() Func CompareBitmaps($bm1, $bm2) $Bm1W = _GDIPlus_ImageGetWidth($bm1) $Bm1H = _GDIPlus_ImageGetHeight($bm1) $BitmapData1 = _GDIPlus_BitmapLockBits($bm1, 0, 0, $Bm1W, $Bm1H, $GDIP_ILMREAD, $GDIP_PXF32RGB) $Stride = DllStructGetData($BitmapData1, "Stride") $Scan0 = DllStructGetData($BitmapData1, "Scan0") $ptr1 = $Scan0 $size1 = ($Bm1H - 1) * $Stride + ($Bm1W - 1) * 4 $Bm2W = _GDIPlus_ImageGetWidth($bm2) $Bm2H = _GDIPlus_ImageGetHeight($bm2) $BitmapData2 = _GDIPlus_BitmapLockBits($bm2, 0, 0, $Bm2W, $Bm2H, $GDIP_ILMREAD, $GDIP_PXF32RGB) $Stride = DllStructGetData($BitmapData2, "Stride") $Scan0 = DllStructGetData($BitmapData2, "Scan0") $ptr2 = $Scan0 $size2 = ($Bm2H - 1) * $Stride + ($Bm2W - 1) * 4 $smallest = $size1 If $size2 < $smallest Then $smallest = $size2 $call = DllCall("msvcrt.dll", "int:cdecl", "memcmp", "ptr", $ptr1, "ptr", $ptr2, "int", $smallest) _GDIPlus_BitmapUnlockBits($bm1, $BitmapData1) _GDIPlus_BitmapUnlockBits($bm2, $BitmapData2) Return ($call[0]=0) EndFunc ;==>CompareBitmaps im getting false (which means they are not identical) is their is a way to compare 2 images with ignoring this very tiny difference ? or maybe i can chose how much % identical the compare is ? this is the udf i used to take the pics expandcollapse popup#include-once ;#include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Date.au3> ;~ ##################################################### ;~ ### ### ;~ ### Webcam UDF ### ;~ ### ### ;~ ### Functions : _WebcamInit() ### ;~ ### _Webcam() ### ;~ ### _WebcamStop() ### ;~ ### _WebcamSnapShot() ### ;~ ### ### ;~ ### Made by L|M|TER ### ;~ ### --------------------------------------------- ### ;~ ### ### ;~ ### Copyright ?008 - L|M|TER ### ;~ ### ### ;~ ##################################################### ;~ Declaring Variables $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 $cap = "" $avi = "" $user = "" $snapfile = @ScriptDir & "\snapshot.bmp" ;~ ########################################################## ;~ Function Name : _WebcamInit() ;~ Description : Starts the webcam image capturing session ;~ Author : L|M|TER ;~ ########################################################## Func _WebcamInit() $avi = DllOpen("avicap32.dll") $user = DllOpen("user32.dll") EndFunc ;==>_WebcamInit ;~ ########################################################## ;~ Function Name : _Webcam($gui,$h,$w,$l,$t) ;~ Description : Creates a webcam preview window ;~ Parameter(s): ;~ $gui - The gui where the webcam window should be created ;~ $h - The height of the webcam window ;~ $w - The width of the webcam window ;~ $l - The left position of the webcam window ;~ $t - The top position of the webcam window ;~ NOTE : All parameters required ! ;~ Author : L|M|TER ;~ ########################################################## Func _Webcam($gui, $w, $h, $l, $t) $cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD, $WS_VISIBLE), "int", $l, "int", $t, "int", $w, "int", $h, "hwnd", $gui, "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) EndFunc ;==>_Webcam ;~ ########################################################## ;~ Function Name : _WebcamStop() ;~ Description : Closes the webcam image capturing session ;~ Author : L|M|TER ;~ ########################################################## Func _WebcamStop() 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) DllClose($avi) EndFunc ;==>_WebcamStop ;~ ########################################################## ;~ Function Name : _WebcamSnapShot($file) ;~ Description : Takes a snapshot ;~ Parameter(s): ;~ $file (Optional) - The path to the file where the snapshot will be saved (Default : @ScriptDir & "\snapshot.bmp") ;~ Author : L|M|TER ;~ ########################################################## Func _WebcamSnapShot($Dest = $snapfile, $AddTimeStamp = false) $RandomFileName = Random(9000, 99999, 1) & ".bmp" 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", $RandomFileName) _ConvertImage($RandomFileName, $Dest, $AddTimeStamp) FileDelete($RandomFileName) EndFunc ;==>_WebcamSnapShot Func _ConvertImage($Src, $Dest, $AddTimeStamp = False) _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($Src) If $AddTimeStamp Then $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 16, 1) $tLayout = _GDIPlus_RectFCreate(500, 415, 150, 100) _GDIPlus_GraphicsDrawStringEx($hGraphic, _NowDate() & @CRLF & _NowTime(), $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) EndIf _GDIPlus_ImageSaveToFile($hImage, $Dest) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndFunc ;==>_ConvertImage any ideas to make that script show true ? Edited February 9, 2014 by Alexxander Link to comment Share on other sites More sharing options...
Gianni Posted February 9, 2014 Share Posted February 9, 2014 ..... maybe the tiger has moved a bit in the second image.... Alexxander 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Alexxander Posted February 9, 2014 Author Share Posted February 9, 2014 ..... maybe the tiger has moved a bit in the second image.... i thought it was dead .. run for ur life's LOL Link to comment Share on other sites More sharing options...
JohnOne Posted February 9, 2014 Share Posted February 9, 2014 You will find the answer to why they change, in your other thread. Alexxander 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Somerset Posted February 9, 2014 Share Posted February 9, 2014 Natural light is effected by atmospheric conditions and artificial light(bulbs) is effect by acdc strobing. You moving in the room can effect the light play on objects. Alexxander 1 Link to comment Share on other sites More sharing options...
Alexxander Posted February 9, 2014 Author Share Posted February 9, 2014 You will find the answer to why they change, in your other thread. Natural light is effected by atmospheric conditions and artificial light(bulbs) is effect by acdc strobing. You moving in the room can effect the light play on objects. ok now i know why it change how can u ignore the change and get true ? Link to comment Share on other sites More sharing options...
Somerset Posted February 9, 2014 Share Posted February 9, 2014 i have always liked this.http://www.imagemagick.org/script/compare.php Link to comment Share on other sites More sharing options...
Alexxander Posted February 9, 2014 Author Share Posted February 9, 2014 i have found this http://phash.org/demo/ it is awesome it gaved me that the 2 images are 0.99 identical i had downloaded it bit i have no idea how to deal with its api he wrotes in his site "provides a C-like API to use those functions in your own programs. pHash itself is written in C++." any 1 can help me check images with autoit through this api ? Link to comment Share on other sites More sharing options...
nullschritt Posted February 10, 2014 Share Posted February 10, 2014 Look at both of my recommendations in this thread. '?do=embed' frameborder='0' data-embedContent>> The first idea could isolate which pixels changed, and what percent of pixels is different. The second idea could isolate which pixels changed, and by how much. If you need help I can maybe write a short script later as an example? Link to comment Share on other sites More sharing options...
nullschritt Posted February 10, 2014 Share Posted February 10, 2014 (edited) If you can get the pixels here's a script to compare them. I wrote this up in my spare time, seems to work pretty well.ConsoleWrite(_colorcompare('ffffff', 'eeeeee')&@CRLF) func _colorcompare($color1, $color2) Local $difference $color1 = StringSplit($color1, "") $color2 = StringSplit($color2, "") $difference = 0 for $i=1 to $color1[0] if $color1[$i] <> $color2[$i] Then $difference += Abs(_hextonum($color1[$i]) - _hextonum($color2[$i])) EndIf Next $difference = (($difference/$color1[0])/15)*100 Return $difference EndFunc func _hextonum($info) if $info+0 > 0 Then Return $info $info = StringLower($info) $return = asc($info)-87 switch $return Case -39 Return 0 Case Else Return $return EndSwitch EndFuncEdit: Updated function to support strings of any length. Should be faster to pass the pixels to the function as one big string than through a loop. Edited February 10, 2014 by nullschritt Link to comment Share on other sites More sharing options...
Somerset Posted February 10, 2014 Share Posted February 10, 2014 Here are the differences. Link to comment Share on other sites More sharing options...
UEZ Posted February 10, 2014 Share Posted February 10, 2014 (edited) Here a script which displays the difference between 2 images:expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() _WinAPI_BitmapsGetDiff(@ScriptDir & "\Filled.bmp", @ScriptDir & "\Logo4.bmp", @ScriptDir & "\Diff.png") ;change the file names here! ShellExecute(@ScriptDir & "\Diff.png") _GDIPlus_Shutdown() Func _WinAPI_BitmapsGetDiff($sFile1, $sFile2, $sSave, $iROP = $MERGEPAINT) ;coded by UEZ 2014-02-10 Local Const $hBitmap1 = _GDIPlus_BitmapCreateFromFile($sFile1) If @error Then Return SetError(1, 0, 0) Local Const $hBitmap2 = _GDIPlus_BitmapCreateFromFile($sFile2) If @error Then _GDIPlus_BitmapDispose($hBitmap1) Return SetError(2, 0, 0) EndIf Local Const $iW = _GDIPlus_ImageGetWidth($hBitmap1), $iH = _GDIPlus_ImageGetHeight($hBitmap1) If _GDIPlus_ImageGetWidth($hBitmap2) <> $iW Or _GDIPlus_ImageGetHeight($hBitmap2) <> $iH Then _GDIPlus_BitmapDispose($hBitmap1) _GDIPlus_BitmapDispose($hBitmap2) Return SetError(3, 0, 0) EndIf Local Const $hHBitmap1 = _WinAPI_CreateDIB($iW, $iH) Local Const $hD1 = _WinAPI_GetWindowDC(0) Local Const $hDC_backbuffer1 = _WinAPI_CreateCompatibleDC($hD1) Local Const $DC_obj1 = _WinAPI_SelectObject($hDC_backbuffer1, $hHBitmap1) Local Const $hGraphic1 = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer1) _GDIPlus_GraphicsSetInterpolationMode($hGraphic1, 5) _GDIPlus_GraphicsDrawImageRect($hGraphic1, $hBitmap1, 0, 0, $iW, $iH) Local Const $hHBitmap2 = _WinAPI_CreateDIB($iW, $iH) Local Const $hD2 = _WinAPI_GetWindowDC(0) Local Const $hDC_backbuffer2 = _WinAPI_CreateCompatibleDC($hD2) Local Const $DC_obj2 = _WinAPI_SelectObject($hDC_backbuffer2, $hHBitmap2) Local Const $hGraphic2 = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer2) _GDIPlus_GraphicsSetInterpolationMode($hGraphic2, 5) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hBitmap2, 0, 0, $iW, $iH) Local Const $hHBitmap3 = _WinAPI_CreateDIB($iW, $iH) Local Const $hD3 = _WinAPI_GetWindowDC(0) Local Const $hDC_backbuffer3 = _WinAPI_CreateCompatibleDC($hD3) Local Const $DC_obj3 = _WinAPI_SelectObject($hDC_backbuffer3, $hHBitmap3) _WinAPI_BitBlt($hDC_backbuffer3, 0, 0, $iW, $iH, $hDC_backbuffer1, 0, 0, $SRCCOPY) _WinAPI_BitBlt($hDC_backbuffer3, 0, 0, $iW, $iH, $hDC_backbuffer2, 0, 0, $iROP) _GDIPlus_BitmapDispose($hBitmap1) _GDIPlus_BitmapDispose($hBitmap2) $hBitmap3 = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap3) _GDIPlus_ImageSaveToFile($hBitmap3, $sSave) _GDIPlus_BitmapDispose($hBitmap3) _GDIPlus_GraphicsDispose($hGraphic1) _WinAPI_SelectObject($hD1, $DC_obj1) _WinAPI_DeleteDC($hDC_backbuffer1) _WinAPI_DeleteObject($hHBitmap1) _WinAPI_ReleaseDC(0, $hD1) _GDIPlus_GraphicsDispose($hGraphic2) _WinAPI_SelectObject($hD2, $DC_obj2) _WinAPI_DeleteDC($hDC_backbuffer2) _WinAPI_DeleteObject($hHBitmap2) _WinAPI_ReleaseDC(0, $hD2) _WinAPI_SelectObject($hD3, $DC_obj3) _WinAPI_DeleteDC($hDC_backbuffer3) _WinAPI_DeleteObject($hHBitmap3) _WinAPI_ReleaseDC(0, $hD3) Return 1 EndFuncResult: Edit: visually the images are the same and the question is how to recognize this....Br,UEZ Edited February 10, 2014 by UEZ robertocm, JohnOne, Parsix and 1 other 4 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
junkew Posted February 10, 2014 Share Posted February 10, 2014 '?do=embed' frameborder='0' data-embedContent>>'?do=embed' frameborder='0' data-embedContent>> FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
JohnOne Posted February 10, 2014 Share Posted February 10, 2014 Here a script which displays the difference between 2 images: expandcollapse popupFunc _WinAPI_BitmapsGetDiff($sFile1, $sFile2, $sSave, $iROP = $MERGEPAINT) ;coded by UEZ 2014-02-10 Local Const $hBitmap1 = _GDIPlus_BitmapCreateFromFile($sFile1) If @error Then Return SetError(1, 0, 0) Local Const $hBitmap2 = _GDIPlus_BitmapCreateFromFile($sFile2) If @error Then _GDIPlus_BitmapDispose($hBitmap1) Return SetError(2, 0, 0) EndIf Local Const $iW = _GDIPlus_ImageGetWidth($hBitmap1), $iH = _GDIPlus_ImageGetHeight($hBitmap1) If _GDIPlus_ImageGetWidth($hBitmap2) <> $iW Or _GDIPlus_ImageGetHeight($hBitmap2) <> $iH Then _GDIPlus_BitmapDispose($hBitmap1) _GDIPlus_BitmapDispose($hBitmap2) Return SetError(3, 0, 0) EndIf Local Const $hHBitmap1 = _WinAPI_CreateDIB($iW, $iH) Local Const $hD1 = _WinAPI_GetWindowDC(0) Local Const $hDC_backbuffer1 = _WinAPI_CreateCompatibleDC($hD1) Local Const $DC_obj1 = _WinAPI_SelectObject($hDC_backbuffer1, $hHBitmap1) Local Const $hGraphic1 = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer1) _GDIPlus_GraphicsSetInterpolationMode($hGraphic1, 5) _GDIPlus_GraphicsDrawImageRect($hGraphic1, $hBitmap1, 0, 0, $iW, $iH) Local Const $hHBitmap2 = _WinAPI_CreateDIB($iW, $iH) Local Const $hD2 = _WinAPI_GetWindowDC(0) Local Const $hDC_backbuffer2 = _WinAPI_CreateCompatibleDC($hD2) Local Const $DC_obj2 = _WinAPI_SelectObject($hDC_backbuffer2, $hHBitmap2) Local Const $hGraphic2 = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer2) _GDIPlus_GraphicsSetInterpolationMode($hGraphic2, 5) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hBitmap2, 0, 0, $iW, $iH) Local Const $hHBitmap3 = _WinAPI_CreateDIB($iW, $iH) Local Const $hD3 = _WinAPI_GetWindowDC(0) Local Const $hDC_backbuffer3 = _WinAPI_CreateCompatibleDC($hD3) Local Const $DC_obj3 = _WinAPI_SelectObject($hDC_backbuffer3, $hHBitmap3) _WinAPI_BitBlt($hDC_backbuffer3, 0, 0, $iW, $iH, $hDC_backbuffer1, 0, 0, $SRCCOPY) _WinAPI_BitBlt($hDC_backbuffer3, 0, 0, $iW, $iH, $hDC_backbuffer2, 0, 0, $iROP) _GDIPlus_BitmapDispose($hBitmap1) _GDIPlus_BitmapDispose($hBitmap2) $hBitmap3 = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap3) _GDIPlus_ImageSaveToFile($hBitmap3, $sSave) _GDIPlus_BitmapDispose($hBitmap3) _GDIPlus_GraphicsDispose($hGraphic1) _WinAPI_SelectObject($hD1, $DC_obj1) _WinAPI_DeleteDC($hDC_backbuffer1) _WinAPI_DeleteObject($hHBitmap1) _WinAPI_ReleaseDC(0, $hD1) _GDIPlus_GraphicsDispose($hGraphic2) _WinAPI_SelectObject($hD2, $DC_obj2) _WinAPI_DeleteDC($hDC_backbuffer2) _WinAPI_DeleteObject($hHBitmap2) _WinAPI_ReleaseDC(0, $hD2) _WinAPI_SelectObject($hD3, $DC_obj3) _WinAPI_DeleteDC($hDC_backbuffer3) _WinAPI_DeleteObject($hHBitmap3) _WinAPI_ReleaseDC(0, $hD3) Return 1 EndFunc Br, UEZ Pretty good that. 100ms for a full screen check for me. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Alexxander Posted February 10, 2014 Author Share Posted February 10, 2014 thank you so much guys you are awesome Link to comment Share on other sites More sharing options...
nullschritt Posted February 10, 2014 Share Posted February 10, 2014 (edited) @UEZ "Edit: visually the images are the same and the question is how to recognize this...." This is what my script I posted above does, sort of. It can return the actual % of change that occurred overall. So if the image is completely the same visually, but the lighting has changed, there will only be a small % in the difference. Edit: With modification it can even visually display where the difference occurred and by how much, similar to yours, though I suspect using my method would take twice as long per amount of data, as it has to compare every byte of the color data. Edited February 10, 2014 by nullschritt Link to comment Share on other sites More sharing options...
JohnOne Posted February 10, 2014 Share Posted February 10, 2014 (edited) Forgive me if I'm wrong, but what you posted is not even close to comparing two images of hundreds of thousands millions of pixels in anywhere near 100 miliseconds. It's a string compare function or something. Edited February 10, 2014 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
nullschritt Posted February 11, 2014 Share Posted February 11, 2014 (edited) Forgive me if I'm wrong, but what you posted is not even close to comparing two images of hundreds of thousands millions of pixels in anywhere near 100 miliseconds. It's a string compare function or something. No you dont fully understand what it doess, Firstly it is not a compare function, it is a difference function. is a hex color has changed by a shade, this script detects that different shade. My tool is not basic compare two string get the comparative difference script. My script gets the relative amount of data that has been changed, and by how much. All I would have to do is make a third image, and populate it with the array containing the differences, and amounts of difference, as represented by shades, simmilar to your result. Please dont assume that I'm ignorant, you my find I am not. You could look here if you need a better explanations of what exactly my simple and efficient script does. '?do=embed' frameborder='0' data-embedContent>> 7 And as you haven;t run my code, since you obviously dont comprehend what it does, and since you say there's no way it does that that fast. If you would run the script in my incuded link, it has an example comparing two 1000x1000px images in 200 milliseconds. I'm actually going to make a visual version that displays the difference, just because it seems like a cool concept. ps: Please don't judge a book by it's cover mate. Edit: though you're right about the speed, it does take around 30 seconds for a 1000x1000 image, my test code wasnt generating all the pixels to be evaluated, still though it's a pretty effective tool. Edited February 13, 2014 by nullschritt Link to comment Share on other sites More sharing options...
nullschritt Posted February 13, 2014 Share Posted February 13, 2014 Though I would add that I release an imagecompare library based on my datadifference udf. My udf was able to detect there was an average of 10.19% difference in your images. (this means it got 10% brighter in the room in these 2 seconds. (probably due to the skylight in your room) See the below images. The shades of blue represent the amount of change that has occurred. Lighter blue = more change. black= no change. (this image excludes changes of less than 10%) (notice how the black areas are either 1)full white/black and thus cannot appear any brighter OR 2)are under objects (shadows)) (image with all changes displayed) Alexxander 1 Link to comment Share on other sites More sharing options...
Alexxander Posted February 13, 2014 Author Share Posted February 13, 2014 nice found bro but it was at 1 AM at the middle of the night i was using neon lamps to lighten the room on other difference finder programs the difference was 2 % but thanks for sharing us your results 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