mary Posted November 29, 2007 Share Posted November 29, 2007 here is a link: http://www.imagemagick.org/script/compare.phpthere are also COM and dll library to compare 2 jpg.The idea is: you take 2 jpg from your webcam and compare them with imagemagick. If the difference is more than $tolerance value ==> there is motionsorry i have no code to help you but i'll do so if i succeed Link to comment Share on other sites More sharing options...
DirtDBaK Posted November 30, 2007 Share Posted November 30, 2007 nice idea, try making some code! And when you do, I'd love to check it out... [center][/center] Link to comment Share on other sites More sharing options...
KeCe Posted May 5, 2008 Share Posted May 5, 2008 goddamit why did you post something without code? make us some code If you fool around with a thing for very long you will screw it up Link to comment Share on other sites More sharing options...
PartyPooper Posted May 5, 2008 Share Posted May 5, 2008 goddamit why did you post something without code? make us some codeOh, now that's really going to get results - NOT. Link to comment Share on other sites More sharing options...
C2C Posted May 5, 2008 Share Posted May 5, 2008 gotta love borat ----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win Link to comment Share on other sites More sharing options...
JellyFish666 Posted May 5, 2008 Share Posted May 5, 2008 (edited) 1 year old topic, ducks for cover eeek! Edited May 5, 2008 by JellyFish666 Link to comment Share on other sites More sharing options...
PartyPooper Posted May 5, 2008 Share Posted May 5, 2008 More like 6 months Link to comment Share on other sites More sharing options...
Yorn Posted May 5, 2008 Share Posted May 5, 2008 Yes, the only way I've come close to doing motion detection is to use third party software and just monitor the size of the images folder to see if things change. When they do, I have events trigger, but it's not the best at all. In fact, it kind of sucks. I really wish there was a DLL out there that someone could use to make a *good* motion detection program. Link to comment Share on other sites More sharing options...
jpam Posted May 5, 2008 Share Posted May 5, 2008 (edited) prospeed.dll can. it has a CompareBytes() function its not in the udf, but i can put it in if you want don't ask me to write a complete motion detection program. i will only include it in the udf , with 1 example. Edited May 5, 2008 by jpam Link to comment Share on other sites More sharing options...
Skrip Posted May 5, 2008 Share Posted May 5, 2008 Zerocool made a very nice one awhile back. I cannot seem to find it now, but it worked nicely. Although, I cannot remember if he actually used AutoIt to make it.. [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
james3mg Posted May 5, 2008 Share Posted May 5, 2008 (edited) If ImageMagickObject.dll is registered on your machine, the code should be something along these lines:(note that the default threshold may be an inappropriate value-I'm not currently on a computer with ImageMagickObject registered, so I'm not sure what range the MAE metric could return).#include <ImageMagickObject.dll.au3> Func _MotionDetected($_Pic1,$_Pic2,$_Threshold=15) Local $oIM=ObjCreate("ImageMagickObject.MagickImage") Local $_ReturnVal=$oIM.Compare("-metric","MAE",$_Pic1,$_Pic2) If $_ReturnVal>=$_Threshold Then Return 1 Else Return 0 EndIf $oIM=0 EndFuncYou could get my ImageMagickObject.dll.au3 include file here (thanks again GeoSoft for hosting this, originally from this thread), but if I remember right, I didn't include the .Compare functions in that dll...you'd be better off installing ImageMagick yourself, and choosing to register the dll in the installation routine. If you do try my include, note that because it registers a COM dll on your system, you'll need administrative privileges the first time you run it (#requireadmin on vista). After it's registered the first time, it will run at any privilege level. Edited May 5, 2008 by james3mg "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110 Link to comment Share on other sites More sharing options...
Yorn Posted May 5, 2008 Share Posted May 5, 2008 jpam, that sounds interesting. I wouldn't expect a complete motion detection program or UDF, but if there's a way to compare two images of a captured webcam image, that would be interesting. If it's comparing bytes of a file or filesize, however, I wouldn't bother. I've already tried doing that method and it's not a very useful method for motion detection. Link to comment Share on other sites More sharing options...
NELyon Posted May 5, 2008 Share Posted May 5, 2008 jpam, that sounds interesting. I wouldn't expect a complete motion detection program or UDF, but if there's a way to compare two images of a captured webcam image, that would be interesting. If it's comparing bytes of a file or filesize, however, I wouldn't bother. I've already tried doing that method and it's not a very useful method for motion detection.A long time ago I used the PixelXXXX Functions to make my mouse follow a highlighter. If you have a good enough quality camera and a viewer, you could use the pixel functions to monitor non-discreet changes (As in all likely hood, the image will change every second, but subtlety) Link to comment Share on other sites More sharing options...
jpam Posted May 5, 2008 Share Posted May 5, 2008 it compares 2 bitmap array data's with a user definded tolerance the tolerance is the amount off bytes that may diiffer from the 2 pictures something like this ; $result = CompareBytes($array1, $array2, $bytesSize, 50) $array1 = bitmap array data $array2 = bitmap array data $bytesSize = byteSize of the bitmap 50 = tolerance , how many bytes may different from the 2 bitmaps $return value = 0 if the bitmaps are the same ,else the total bytes that are different Link to comment Share on other sites More sharing options...
jpam Posted May 6, 2008 Share Posted May 6, 2008 I did some testing with CompareBytes() it works between 1 and 1.5 ms for a 400x400 pixel bitmap Link to comment Share on other sites More sharing options...
McGod Posted May 6, 2008 Share Posted May 6, 2008 Easy method: Have it take a base screenshot and MD5 it Every 5 seconds, take a screenshot and MD5 it then compare the two. If they aren't the same MD5 then something changed. [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u] Link to comment Share on other sites More sharing options...
james3mg Posted May 6, 2008 Share Posted May 6, 2008 (edited) Easy method:Have it take a base screenshot and MD5 itEvery 5 seconds, take a screenshot and MD5 it then compare the two.If they aren't the same MD5 then something changed.The problem is that you'll never get two pictures of something that are exactly the same. Note that the OP was looking for a tolerance of some kind, which is why the ImageMagick method is a good fit- it gives you the AMOUNT of change from one picture to another. Edited May 6, 2008 by james3mg "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110 Link to comment Share on other sites More sharing options...
spudw2k Posted May 6, 2008 Share Posted May 6, 2008 The compare would work great for simple motion/action, but I was wondering does Imagemagick support some sort of co-ord info for where in the motion is detected? (top right of picture, bottom left, etc..) Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF  Link to comment Share on other sites More sharing options...
Wus Posted May 7, 2008 Share Posted May 7, 2008 (edited) If you have access to the pixels then you could code up a simple mean-square error function (though it wouldn't really be an error, just a difference), and then threshold based on that error. I'm pretty sure it's one of the most common error measures there is. The only difficulty would probably be in determining an appropriate size for the threshold... but that is just a matter of experiment.http://en.wikipedia.org/wiki/Mean_square_errorEdit:And if you want information on where the motion occurred I would probably (1) create an error map(2) apply some smoothing (probably a blur or unsharp mask)(3) normalize it(4) fit a rectangle around the top x% of the error (this rect would tell you where the motion occurred) Edited May 7, 2008 by Wus Link to comment Share on other sites More sharing options...
jpam Posted May 7, 2008 Share Posted May 7, 2008 here's the script i did some testing withyou need prospeed3.0.dll and the prospeed3.0 udf for itdownload @ http://prospeed-jan.xprofan.com/i cannot anwser any questions for 10 days, holiday in spain expandcollapse popup#include <prospeed3.0.au3> GUICreate("Compare 2 images", 800, 400) GUISetState() $hdc = GetHDC() $clock1 = LoadFileImage("clock.png") $size = GetInfosImage($clock1,7) $clock2 = CreateImage(400,400) PaintImage($clock2,0,0,400,400,$clock1,0,0,0) ColorFillImage($clock2,398,398,400,400,0xFFFFFF) PaintImage($hdc,0,0,400,400,$clock1,0,0,0) PaintImage($hdc,400,0,400,400,$clock2,0,0,0) CreateBuffer(800,400) SetBuffer($hdc) $array1 = InitFX($clock1) $array2 = InitFX($clock2) $Struct1 = DllStructCreate("byte["&$size&"]") $Struct2 = DllStructCreate("byte["&$size&"]") $mem1 = SaveToMemoryFX($array1, DllStructGetPtr($Struct1)) $mem2 = SaveToMemoryFX($array2, DllStructGetPtr($Struct2)) $time = TimerInit() $chk2 = CompareBytes(DllStructGetPtr($Struct1), DllStructGetPtr($Struct2), $size, 0) $stop = TimerDiff($time) MsgBox(0,$stop,$chk2) While 1 $msg = GUIGetMsg() If $msg = -3 Then $Struct1 = "" $Struct2 = "" FreeAllImages() FreeFX($array1) FreeFX($array2) DestroyBuffer() Exit EndIf WEnd 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