Yes, I understand what a loop is, and there was a loop but I didn't write that code into my email because I didn't need commenting on it. <br>Here is the code so its clear incase you really care =P<br><br>from PIL import Image
<br>from PIL import ImageGrab<br>import time<br><br>capturedFrames = 100<br>count = 0<br><br>print "\nInitializing Engine..."<br>newView = ImageGrab.grab()<br>print "Engine Initilized Successfully!"<br>
<br>raw_input("Press any key to begin...")<br><br>print "\nInitializing capture cycle..."<br><br>startClock = time.clock()<br><br>for i in range(capturedFrames): # Here is the loop I was timing that I commented is extremely slow using the method you suggested. It does work however.
<br> oldView = newView<br> newView = ImageGrab.grab()<br> if oldView.tostring() != newView.tostring():<br> count = count + 1<br><br><br>endClock = time.clock()<br>totalTime = endClock - startClock<br>calculatedFPS = capturedFrames / totalTime
<br><br>horRes = str(newView.getbbox()[2])<br>verRes = str(newView.getbbox()[3])<br><br>print "Frame Resolution : %sx%s" % (horRes.rjust(4), verRes.rjust(4))<br>print "Frames Captured : %s" % str(capturedFrames).rjust(9)
<br>print "Capture Time (sec) : %s" % str(totalTime)[:4].rjust(9)<br>print "Calculated FPS : %s" % str(calculatedFPS)[:4].rjust(9)<br>print "Changes Registered : %s" % str(count).rjust(9)
<br>raw_input("\nPress Any Key...")<br><br><div><span class="gmail_quote">On 11/8/06, <b class="gmail_sendername">Luke Paireepinart</b> <<a href="mailto:rabidpoobear@gmail.com">rabidpoobear@gmail.com</a>> wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Chris Hengge wrote:<br>> alist = difference(image1,image2)<br>> a = [b for b in
alist.getdata() if b != (0,0,0)]<br>> if len(a) != 0:<br>> print "Not the same"<br>><br>> is much slower then (9x)<br>><br>> if im1.tostring() != im2.tostring()<br>> print "something changed!"
<br>><br>> This loop itself is fairly slow by itself though.. I'm going to try<br>> and see if there is a faster way.<br>Chris,<br>are you sure you know what a loop is?<br>The only loop here is in the list comprehension.
<br>'if' is not a loop.<br>'for' and 'while' are.<br>In computer science, it's important to be clear in your use of terminology.<br><br>It makes sense that my example was slow.<br>I didn't really think to try converting them to strings.
<br><br>Any time you're trying to compare pixel values, it's going to take a while,<br>cause remember, a 1024X768 image has 786,432 different pixels.<br>I think your tostring comparison may be your best bet.<br></blockquote>
</div><br>