diff --git a/SimpleCV/tests/test_vimba_manyshots.py b/SimpleCV/tests/test_vimba_manyshots.py index 3c11d7385..f6f58c1d9 100644 --- a/SimpleCV/tests/test_vimba_manyshots.py +++ b/SimpleCV/tests/test_vimba_manyshots.py @@ -27,19 +27,14 @@ def _takeShots(cam, numPics, filename): print "Taking %d photos..." % numPics for i in range(numPics): img = cam.getImage() - img.save("%s_%d.png" % (filename, i)) + if (i % 100 == 0): + print "At %d" % i + #img.save("%s_%d.png" % (filename, i)) end = time.time() elapsed = end - start print "Took %f seconds" % elapsed """ -def test_takeManyShots(): - c = VimbaCamera() - printPrettyHeader("Test takeManyShots") - - _takeShots(c, 50, "vimba") -""" - def test_oneGrayShot(): c = VimbaCamera(properties={"mode":"gray"}) printPrettyHeader("Test oneGrayShot") @@ -53,11 +48,32 @@ def test_oneShot(): img = c.getImage() img.save("test_oneShot.png") +""" + +""" +def test_takeManyShots(): + c = VimbaCamera() + printPrettyHeader("Test takeManyShots") + + _takeShots(c, 100, "vimba") +""" + +def test_makeLotsOfCamera(): + numIter = 1000 + print "Creating %d cameras..." % numIter + start = time.time() + for i in range(numIter): + print "At camera=%d" % i + cam = VimbaCamera() + img = cam.getImage() + end = time.time() + elapsed = end - start + print "Took %f seconds" % elapsed """ def test_AVT_takeManyShots(): c = AVTCamera() printPrettyHeader("Test AVT_takeManyShots") - _takeShots(c, 50, "avtnative") -""" + _takeShots(c, 10, "avtnative") +""" \ No newline at end of file diff --git a/SimpleCV/tests/test_vimba_memory.py b/SimpleCV/tests/test_vimba_memory.py new file mode 100644 index 000000000..4e5efe3fc --- /dev/null +++ b/SimpleCV/tests/test_vimba_memory.py @@ -0,0 +1,63 @@ +import gc +# From bytes.com/topic/python/answers/22097-hunting-memory-leak + +import time +from SimpleCV.Camera import VimbaCamera, AVTCamera + +""" +# at the beginning of code +gc.enable() +gc.set_debug(gc.DEBUG_LEAK) +""" + +def printPrettyHeader(msg): + print "*"*80 + "\n* %s *\n" % msg + "*"*80 + +def _takeShots(cam, numPics, filename): + start = time.time() + #print "Taking %d photos..." % numPics + for i in range(numPics): + img = cam.getImage() + #if (i % 1000 == 0): + # img.save("%s_%d.png" % (filename, i)) + end = time.time() + elapsed = end - start + print "Took %f seconds" % elapsed + +def test_takeManyShots(idx): + c = VimbaCamera() + #printPrettyHeader("Test takeManyShots %d" % idx) + print "Test takeManyShots %d" % idx + + _takeShots(c, 1, "vimba%d" % idx) + +def test_takeAVTManyShots(idx): + c = AVTCamera() + printPrettyHeader("Test takeAVTShots %d" % idx) + + _takeShots(c, 1, "avtnative%d" % idx) + +#test_takeAVTManyShots(1) +#test_takeAVTManyShots(2) +#test_takeManyShots(1) +#test_takeManyShots(2) + +def test_createManyCameras(): + printPrettyHeader("Test createManyCameras") + numIter = 1000 + for i in range(numIter): + test_takeManyShots(i) + +test_createManyCameras() + +""" +########################################################################3 +# at the end of code: +print "\nGARBAGE:" +gc.collect() + +print "\nGARBAGE OBJECTS:" +for x in gc.garbage: + s = str(x) + print type(x),"\n",s +""" \ No newline at end of file