idkhow2username Posted March 31, 2019 Share Posted March 31, 2019 Alright so here's the jest of it: I have a camera from Cox that I can use to view my front porch, the camera is supposed to have a motion sensor to let you know when someone's there and it doesn't record or anything; we only have it because we swapped it for the land line we never used and saved $5/month. But basically what I want to do is write a program to load the page with the video stream, extract that stream in a pretty little window and scan that stream for changes and setup notification and or recording options. I'm really rusty with AutoIt and have done all the Googling and help file exploring I can possibly do with little to no luck, so that brings me here. Can anyone help me figure out how to extract the video stream from the site? Thank you! Downloads.7z Link to comment Share on other sites More sharing options...
TheDcoder Posted April 1, 2019 Share Posted April 1, 2019 4 hours ago, idkhow2username said: scan that stream for changes I suspect that this is the hardest part, it would be tricky to do it efficiently. Is this your first AutoIt project? If yes, then this might be a complex start... EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
idkhow2username Posted April 1, 2019 Author Share Posted April 1, 2019 I just wanna load the webpage, use PixelChecksum to let me know when motion is detected. I've gotten most of it done, I just want to do it without loading the whole page, scrolling, waiting, then scanning for changes. expandcollapse popup#Include <GUIConstantsEx.au3> #Include <IE.au3> #Include <WindowsConstants.au3> Local $oIE = _IECreateEmbedded() $GUI = GUICreate('Camera Monitor / Motion Detector', 1000, 800, 100, 100, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) GUICtrlCreateObj($oIE, 0, 0, 1200, 1200) GUISetState(@SW_SHOW) $wInfo = WinGetPos ($GUI) MouseMove ($wInfo[0], $wInfo[1], 0) _IENavigate($oIE, 'https://portal.coxhomelife.com/sp/') _IELoadWait ($oIE) _IsLoaded ($wInfo[0], $wInfo[1], $wInfo[2], $wInfo[3]) ControlSend ($GUI, '', '', 'username') ControlSend ($GUI, '', '', '{TAB}') ControlSend ($GUI, '', '', 'password') ControlSend ($GUI, '', '', '{ENTER}') _IELoadWait ($oIE) Sleep (850) _IsLoaded ($wInfo[0] + 145, $wInfo[1] + 285, ($wInfo[2] - 405), ($wInfo[3] / 10)) Sleep (850) ControlClick ($GUI, '', '', 'Left', 1, $wInfo[0] + 200, $wInfo[1] + 200) Sleep (850) _IsLoaded ($wInfo[0] + 145, $wInfo[1] + 285, ($wInfo[2] - 405), ($wInfo[3] / 10)) Sleep (850) ControlClick ($GUI, '', '', 'Left', 1, $wInfo[0] + 200, $wInfo[1] + 200) Sleep (850) ControlSend ($GUI, '', '', '{TAB}') Sleep (850) ControlSend ($GUI, '', '', '{ENTER}') While 1 Local $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() Exit Func _IsLoaded ($A = 1, $B = 1, $C = 1, $D = 1) Sleep (2500) $OG = PixelChecksum ($A, $B, $C, $D) Do $New = PixelChecksum ($A, $B, $C, $D) Until $OG <> $New EndFunc Link to comment Share on other sites More sharing options...
idkhow2username Posted April 1, 2019 Author Share Posted April 1, 2019 So, any cleaner ways to do it? Thanks man! And I've been using AutoIt for a very long time. Just rusty. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 1, 2019 Moderators Share Posted April 1, 2019 Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
idkhow2username Posted April 1, 2019 Author Share Posted April 1, 2019 Sorry, haven't used these forums since 2009 at least, thanks though! Anyone happen to have any ideas? Link to comment Share on other sites More sharing options...
TheDcoder Posted April 1, 2019 Share Posted April 1, 2019 9 hours ago, idkhow2username said: I just want to do it without loading the whole page, scrolling, waiting, then scanning for changes. Try to find the source for the video feed, you can use a video player to directly stream the video and then use PixelChecksum on it... Most browser allow you to inspect elements by right clicking on them, you can also search for <video> elements in the DOM explorer and find the source Or maybe even your camera itself provides a way to get the video feed directly? -- Though I doubt PixelChecksum would work as it would detect any changes in pixels, so even a moving leaf could trigger the script... also it might not be the most efficient way to check for changes in a video stream EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Nine Posted April 1, 2019 Share Posted April 1, 2019 Well PixelCheckSum is not the perfect tool, but at least it will get you started, and it will work quite well if the image is not flickering too much. I suggest you use a small sleep inside the do loop to not overload your CPU. Also do an incremental screen capture on disk when your function triggers a change. It will help you understand what happened. You can enhance your code accordingly. As long as you don't start an alarm at each change, you will be fine. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
BrewManNH Posted April 1, 2019 Share Posted April 1, 2019 Don't forget, lighting changes will probably trigger it as well, especially because it's outside. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
idkhow2username Posted April 2, 2019 Author Share Posted April 2, 2019 The theory I'm using for motion detection is figuring out how to do x amount of quadrants on the video stream it's self and for each of those quadrants do a Pixelchecksum and from there determine how many quadrants changed in order to detect motion. Pixelchecksum allows you to skip pixels too, so that's what I'll be doing. Tinkering with amount of quadrants and pixels to skip to get accurate motion detection is the goal. How would I go about getting the quadrants? Here's my script so far. #Include <GUIConstantsEx.au3> #Include <WindowsConstants.au3> Opt ('GUIOnEventMode', 1) $GUI1 = GUICreate('Main', 100, 35, 100, 100) GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit', $GUI1) GUICtrlCreateButton ('Map Quadrants', 5, 5, 90, 25) GUICtrlSetOnEvent (-1, '_Map') GUISetState(@SW_SHOW) WinSetOnTop ($GUI1, '', 1) $GUI2 = GUICreate('Test', 350, 350, 205, 100, $WS_EX_TOOLWINDOW) GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit', $GUI2) GUISetState(@SW_SHOW) While 1 Sleep (50) WEnd Func _Map () Local $Pos = WinGetPos ($GUI2), $Quadrants = 10 ; From here how do I make my program draw 10 perfectly sized buttons bunched together on my test GUI? The purpose is I'm going to implment it into searching ; a video stream and each quadrant will allow me to see how much has changed in order to detect motion. EndFunc Func _Exit () Exit EndFunc Link to comment Share on other sites More sharing options...
idkhow2username Posted April 2, 2019 Author Share Posted April 2, 2019 So basically I'm trying to add motion detection to the camera on my front porch because the build in feature triggers at nothing. The theory I'm using for motion detection is figuring out how to do x amount of quadrants on the video stream it's self and for each of those quadrants do a Pixelchecksum and from there determine how many quadrants changed in order to detect motion. Pixelchecksum allows you to skip pixels too, so that's what I'll be doing. Tinkering with amount of quadrants and pixels to skip to get accurate motion detection is the goal. How would I go about getting the quadrants? Here's my code thus far, any help would be greatly appreciated. #Include <GUIConstantsEx.au3> #Include <WindowsConstants.au3> Opt ('GUIOnEventMode', 1) $GUI1 = GUICreate('Main', 100, 35, 100, 100) GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit', $GUI1) GUICtrlCreateButton ('Map Quadrants', 5, 5, 90, 25) GUICtrlSetOnEvent (-1, '_Map') GUISetState(@SW_SHOW) WinSetOnTop ($GUI1, '', 1) $GUI2 = GUICreate('Test', 350, 350, 205, 100, $WS_EX_TOOLWINDOW) GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit', $GUI2) GUISetState(@SW_SHOW) While 1 Sleep (50) WEnd Func _Map () Local $Pos = WinGetPos ($GUI2), $Quadrants = 10 ; From here how do I make my program draw 10 perfectly sized buttons bunched together on my test GUI? The purpose is I'm going to implment it into searching ; a video stream and each quadrant will allow me to see how much has changed in order to detect motion. EndFunc Func _Exit () Exit EndFunc Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 2, 2019 Moderators Share Posted April 2, 2019 Please stick to one thread; spamming the forum for the same question is not going to get people to answer you any more quickly (it will, in fact, have the opposite effect). "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
idkhow2username Posted April 2, 2019 Author Share Posted April 2, 2019 (edited) My bad. The question I'm asking is for this project, but it could also be used for other things. Sorry though, not trying to be annoying or anything. Just getting over some depressing; getting back into stuff I used to love. Wasn't trying to get the problem solved quicker, just thought it could use it's own post for anyone else who might need the functionality. Edited April 2, 2019 by idkhow2username Link to comment Share on other sites More sharing options...
Nine Posted April 2, 2019 Share Posted April 2, 2019 Try this (it is untested) but you will get the idea... #include <ScreenCapture.au3> Opt ("MustDeclareVars", 1) Global $aPix[3][3] ; Your code goes here ; you call map () repeatedly in your gui2 loop Func _Map () Local $Pos = WinGetPos ($GUI2), $Width = int($Pos[2]/Ubound($aPix,1)), $Height = int($Pos[3]/Ubound($aPix,2)) Local $Count = 0, $CS For $x = 0 to Ubound($aPix,1)-1 For $y = 0 to Ubound($aPix,2)-1 $CS = PixelCheckSum ($Pos[0]+($x*$Width),$Pos[1]+($y*$Height),$Pos[0]+(($x+1)*$Width),$Pos[1]+(($y+1)*$Height)) If $CS <> $aPix[$x][$y] $Count += 1 $aPix[$x][$y] = $CS EndIf Next Next If $Count > 4 then _ScreenCapture_CaptureWnd ("\capture\" & @YEAR & @MON & @MDAY & "-" & @HOUR & @MIN & @SEC & ".jpg", $GUI2) EndFunc “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
idkhow2username Posted April 2, 2019 Author Share Posted April 2, 2019 (edited) Thank you for the help! What I'm wondering now is the video stream opens in it's own Adobe window and the stream isn't taking up the entire screen, how do I go about scanning that window, but just where the camera stream is (and more logically only the walk way on my porch needs to be scanned for movement). Here's a screen shot of what the live feed looks like. I know it's simple enough to get the cords of that window, make it active, just don't really know where to go from there, I was it to be as effective as possible by only scanning the areas people could possibly walk. I would tinker with my script, but I'm not at home. Also if you don't mind, could you explain how your function works? I would love to have a better comprehension on how you're doing the math to scan the area. Here's the code I'm working with after the camera stream is opened. expandcollapse popup#Include <GUIConstantsEx.au3> #Include <IE.au3> #Include <WindowsConstants.au3> #Include <File.au3> #Include <ScreenCapture.au3> Opt ('GUIOnEventMode', 1) Opt ('WinTitleMatchMode', 2) Opt ('MostDeclareVars', 1) HotKeySet ('{F8}','_Start') Global $aPix[3][3] $GUI = GUICreate ('Motion Detection', 175, 175, 25, 50, $WS_SIZEBOX) GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit') GUICtrlCreateButton ('Start', 5, 5, 40, 20) GUICtrlSetOnEvent (-1, '_Start') $Console = GUICtrlCreateEdit ('', 0, 30, 175, 122) GUISetState (@SW_SHOW, $GUI) WinSetTrans ($GUI, '', 225) WinSetOnTop ($GUI, '', 1) While 1 Sleep (25) WEnd Func _Start () $HWnD = WinGetHandle ('My Home - Adobe Flash Player') WinActivate ($HWnD) EndFunc Func _Map ($Win) Local $Pos = WinGetPos ($Win), $Width = Int($Pos[2]/Ubound($aPix,1)), $Height = Int($Pos[3]/Ubound($aPix,2)) Local $Count = 0, $CS For $X = 0 to Ubound($aPix,1)-1 For $Y = 0 to Ubound($aPix,2)-1 $CS = PixelCheckSum ($Pos[0]+($X*$Width),$Pos[1]+($Y*$Height),$Pos[0]+(($X+1)*$Width),$Pos[1]+(($Y+1)*$Height)) If $CS <> $aPix[$X][$Y] $Count += 1 $aPix[$x][$y] = $CS EndIf Next Next If $Count > 4 Then _ScreenCapture_CaptureWnd ("\capture\" & @YEAR & @MON & @MDAY & "-" & @HOUR & @MIN & @SEC & ".jpg", $GUI2) EndIf EndFunc Func _Exit () Exit EndFunc Edited April 2, 2019 by idkhow2username Link to comment Share on other sites More sharing options...
idkhow2username Posted April 2, 2019 Author Share Posted April 2, 2019 Been doing some tinkering, could you possibly tell me how I can search just the walk way? It's being way too sensitive, in 4 seconds I got maybe 5 instances of no chances when there was no motion. Here's my updated code: expandcollapse popup#Include <GUIConstantsEx.au3> #Include <IE.au3> #Include <WindowsConstants.au3> #Include <File.au3> #Include <ScreenCapture.au3> #Include <GUIEdit.au3> FileDelete ('log.txt') Opt ('GUIOnEventMode', 1) Opt ('WinTitleMatchMode', 2) Opt ('MostDeclareVars', 1) HotKeySet ('{F8}','_Start') Global $aPix[3][3] $GUI = GUICreate ('Motion Detection', 175, 175, 25, 50, $WS_SIZEBOX) GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit') GUICtrlCreateButton ('Start', 5, 5, 40, 20) GUICtrlSetOnEvent (-1, '_Start') $Console = GUICtrlCreateEdit ('', 0, 30, 175, 122) GUISetState (@SW_SHOW, $GUI) WinSetTrans ($GUI, '', 225) WinSetOnTop ($GUI, '', 1) While 1 Sleep (25) WEnd Func _Start () $HWnD = WinGetHandle ('My Home - Adobe Flash Player') WinActivate ($HWnD) $Timer = TimerInit () Do _Scan ($HWnD) Sleep (10) Until TimerDiff ($Timer) >= 4000 EndFunc Func _Scan ($Win) Local $Pos = WinGetPos ($Win), $Width = Int($Pos[2]/Ubound($aPix, 1)), $Height = Int($Pos[3]/Ubound($aPix, 2)) Local $Count = 0, $CS For $X = 0 to Ubound($aPix,1)-1 For $Y = 0 to Ubound($aPix,2)-1 $CS = PixelCheckSum ($Pos[0]+($X*$Width), $Pos[1]+($Y*$Height), $Pos[0]+(($X+1)*$Width), $Pos[1]+(($Y+1)*$Height), 10, $Win) If $CS <> $aPix[$X][$Y] Then $Count += 1 $aPix[$x][$y] = $CS FileWriteLine ('log.txt','Motion:' & $Count) Else FileWriteLine ('log.txt','Still.') EndIf _Update () Next Next ;If $Count > 4 Then ; _ScreenCapture_CaptureWnd ("\capture\" & @YEAR & @MON & @MDAY & "-" & @HOUR & @MIN & @SEC & ".jpg", $GUI2) ;EndIf EndFunc Func _Update () $Str = FileRead ('log.txt') GUICtrlSetData ($Console, $Str) _GUICtrlEdit_Scroll ($Console, 4) EndFunc Func _Exit () FileDelete ('log.txt') Exit EndFunc I'm trying to just scan this region of the video feed: Link to comment Share on other sites More sharing options...
Nine Posted April 3, 2019 Share Posted April 3, 2019 You could divide your screen in regions, like you graphically did, by rows and columns, then choose the left, top, right, bottom, regions you want to scan. Global Const $NUMBER_ROWS = 8, $NUMBER_COLUMNS = 15, $LEFT_REGION = 3, $TOP_REGION = 1, $RIGHT_REGION = 9, $BOTTOM_REGION = 7 Use a similar algorithm as I showed you, but instead of scanning the whole screen you would scan between left to right, and top to bottom. Note that left/right/top/bottom are 0 based. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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