Merge branch 'master' of https://github.com/szmoore/MCTX3420.git
authorJeremy Tan <[email protected]>
Fri, 18 Oct 2013 13:57:49 +0000 (21:57 +0800)
committerJeremy Tan <[email protected]>
Fri, 18 Oct 2013 13:57:49 +0000 (21:57 +0800)
irc/log
testing/pygui/pygui.py [new file with mode: 0755]

diff --git a/irc/log b/irc/log
index 96e918e..d3c81ee 100644 (file)
--- a/irc/log
+++ b/irc/log
 21:56 -!- jtanx [[email protected]] has quit [Ping timeout]
 23:28 -!- jtanx_ [[email protected]] has quit ["ChatZilla 0.9.90.1 [Firefox 24.0/20130910160258]"]
 23:28 -!- MctxBot [[email protected]] has joined #mctxuwa_softdev
+--- Day changed Thu Oct 17 2013
+09:16 -!- jtanx [[email protected]] has joined #mctxuwa_softdev
+09:17 < jtanx> ....
+09:17 < jtanx> I just ran the bBB with ubuntu and used the usb microscope
+09:17 < jtanx> and it worked
+09:18 < jtanx> and so too does it work on the original os
+09:18 < jtanx> wtf
+09:33 < jtanx> hahahaa 
+09:33 < jtanx> it crashed because it ran out of memory 
+09:33 < jtanx> I tried having both cameras at once
+09:33 < jtanx> and switching between them 
+09:34 < jtanx> but other than that it works
+09:34 < jtanx> this is weird
+09:44 < jtanx> about 1/5 tries fails at 1600x1200 with 'select timeout'
+09:44 < jtanx> probably because it can't buffer that fast or something
+09:45 < jtanx> but definitely to run both cameras at once (or at least have them connected), you require an external power source, either for the beaglebone or for the usb hub
+09:47 < jtanx> yep
+09:47 < jtanx> if you do
+09:47 < jtanx> modprobe uvcvideo nodrop=1
+09:47 < jtanx> It will only display part of the image
+09:47 < jtanx> probably because it hasn't filled the buffer yet
+09:48 < jtanx> but if you load uvcvideo with normal settings
+09:48 < jtanx> it either displays the full image, or no image at all
+09:48 < jtanx> the problem is, I don't know how you detect this in opencv
+10:10 -!- jtanx [[email protected]] has quit ["ChatZilla 0.9.90.1 [Firefox 24.0/20130910160258]"]
+13:47 -!- jtanx [[email protected]] has joined #mctxuwa_softdev
+14:55 -!- MctxBot [[email protected]] has quit [Ping timeout]
+17:14 -!- MctxBot [[email protected]] has joined #mctxuwa_softdev
+17:20 -!- MctxBot [[email protected]] has quit ["leaving"]
+17:22 -!- MctxBot [[email protected]] has joined #mctxuwa_softdev
+22:38 -!- jtanx [[email protected]] has quit ["ChatZilla 0.9.90.1 [Firefox 24.0/20130910160258]"]
diff --git a/testing/pygui/pygui.py b/testing/pygui/pygui.py
new file mode 100755 (executable)
index 0000000..a27e003
--- /dev/null
@@ -0,0 +1,89 @@
+#!/usr/bin/python
+
+"""
+       Python has a different style of documentation which will break doxygen...
+"""
+
+import sys
+import os
+import matplotlib.pyplot as plt
+import numpy
+import requests
+import datetime
+import time
+
+#TODO: Replace with URL of testing server
+api_url = "https://daedalus/api"
+
+def log(message):
+       sys.stderr.write("%s: %s : %s\n" % (sys.argv[0], str(datetime.datetime.now()), message))
+
+def update_plot(plot, axes, data_x, data_y):
+       """
+               Update data to plot, allegedly this is faster than just replotting everything
+       """
+       plot.set_xdata(numpy.append(plot.get_xdata(), data_x))
+       plot.set_ydata(numpy.append(plot.get_ydata(), data_y))
+       axes.relim()
+       axes.autoscale_view()
+       plt.draw()      
+
+def main(argv):
+       if (len(argv) < 2):
+               sys.stderr.write("Usage: %s sensor_id\n" % argv[0])
+               sys.stderr.write("Identifying sensors...\n\n")
+               r = requests.get(api_url + "?sensors", verify=False)            
+               print r.text
+               return 1        
+       
+       plt.ion()
+
+       fig = plt.figure()
+       axes = fig.add_subplot(111)
+       #NOTE: Comma here is *not* a typo and is extremely important and some kind of mysterious python magical tuple thing
+       #               Do not remove the comma or things will break. Horribly.
+       plot, = axes.plot([],[])
+
+       start_time = 0
+       
+       while True:
+               params = { "id" : argv[1], "start_time" : "-1", "format" : "tsv"}
+               try:
+                       r = requests.get(api_url + "/sensors", params=params, verify=False)
+               except:
+                       log("Failed to make request for data");
+                       return 1
+
+               if r.status_code != 200:
+                       log("Bad status code %d" % r.status_code)
+                       print r.text
+                       return 1
+               
+               log("Got data")
+
+               data_x = []
+               data_y = []             
+
+               count = 0
+               for line in r.text.split("\n"):
+                       count += 1
+
+                       
+                       point = map(float, line.split("\t"))
+
+                       if point[0] > start_time:
+                               data_x.append(point[0])
+                               data_y.append(point[1])
+                               start_time = point[0]
+
+               if count > 0:
+                       update_plot(plot, axes, data_x, data_y)
+                       time.sleep(0.5)
+
+       return 0
+
+# ... This is how you make main work in python. With string comparisons.
+if __name__ == "__main__":
+       exit(main(sys.argv))
+
+

UCC git Repository :: git.ucc.asn.au