Example #1
0
def main(argv=None):
	try:
		if argv is None:
			argv = sys.argv[1:]
	
		parser = _mk_options_parser()
		options, args = parser.parse_args(argv)
	
		if len(args) == 0:
			parser.error("insufficient arguments, expected at least one path.")
			return 2

		res = parsing.parse(args, options.prune, options.mintime)
		if options.interactive or options.output == None:
			gui.show(res)
		else:
			filename = _get_filename(options.output)
			res_list = parsing.split_res(res, options.num)
			n = 1
			for r in res_list:
				if len(res_list) == 1:
					f = filename + "." + options.format
				else:
					f = filename + "_" + str(n) + "." + options.format
					n = n + 1
				batch.render(r, options.format, f)
				print "bootchart written to", f
		return 0
	except parsing.ParseError, ex:
		print("Parse error: %s" % ex)
		return 2
Example #2
0
    def pushedButton(event):
        conf_path = confPathVar.get()

        root.destroy()

        history_path = "history.json"
        history = data.History.loadFile(history_path)

        if conf_path == new_config_txt:
            new_config = True
            param = data.Parameter()
            param.game_title = "%d" % (time.time())
        else:
            new_config = False
            conf_path = os.path.join(conf_dir, urllib.parse.quote(conf_path))
            param = data.Parameter.loadFile(conf_path)

        gui.show(param, history)

        history.save(history_path)

        if new_config:
            title = urllib.parse.quote(param.game_title)
            conf_path = os.path.join(conf_dir, "%s.json" % (title))

        param.save(conf_path)
Example #3
0
def main(argv=None):
	try:
		if argv is None:
			argv = sys.argv[1:]
	
		parser = _mk_options_parser()
		options, args = parser.parse_args(argv)
		writer = _mk_writer(options)

		if len(args) == 0:
			print "No path given, trying /var/log/bootchart.tgz"
			args = [ "/var/log/bootchart.tgz" ]


		res = parsing.parse(writer, args, options.prune,
				    options.crop_after, options.annotate)
		
		if options.interactive or options.output == None:
			gui.show(res, options)
		elif options.boottime:
			import math
			proc_tree = res[3]
			if proc_tree.idle:
			    duration = proc_tree.idle
			else:
			    duration = proc_tree.duration
			dur = duration / 100.0
			print '%02d:%05.2f' % (math.floor(dur/60), dur - 60 * math.floor(dur/60))
		else:
			if options.annotate_file:
				f = open (options.annotate_file, "w")
				try:
					for time in res[4]:
						if time is not None:
							# output as ms
							print >> f, time * 10
						else:
							print >> f
				finally:
					f.close()
			filename = _get_filename(args, options)
			def render():
				batch.render(writer, res, options, filename)
			if options.profile:
				import cProfile
				import pstats
				profile = '%s.prof' % os.path.splitext(filename)[0]
				cProfile.runctx('render()', globals(), locals(), profile)
				p = pstats.Stats(profile)
				p.strip_dirs().sort_stats('time').print_stats(20)
			else:
				render()

		return 0
	except parsing.ParseError, ex:
		print("Parse error: %s" % ex)
		return 2
Example #4
0
def main(argv=None):
	try:
		if argv is None:
			argv = sys.argv[1:]
	
		parser = _mk_options_parser()
		options, args = parser.parse_args(argv)
		writer = _mk_writer(options)

		if len(args) == 0:
			print "No path given, trying /var/log/bootchart.tgz"
			args = [ "/var/log/bootchart.tgz" ]
			

		res = parsing.parse(writer, args, options.prune)
		
		if options.interactive or options.output == None:
			gui.show(res, options)
		else:
			filename = _get_filename(args, options)
			def render():
				batch.render(writer, res, options, filename)
			if options.profile:
				import cProfile
				import pstats
				profile = '%s.prof' % os.path.splitext(filename)[0]
				cProfile.runctx('render()', globals(), locals(), profile)
				p = pstats.Stats(profile)
				p.strip_dirs().sort_stats('time').print_stats(20)
			else:
				render()

		return 0
	except parsing.ParseError, ex:
		print("Parse error: %s" % ex)
		return 2
Example #5
0
	def login_submit(ev):
		if(challenge(sn_textbox.GetValue(),pw_textbox.GetValue())):
			frame.Close()
			gui.show()
Example #6
0
File: lps.py Project: Breq16/lps
cap = cv2.VideoCapture(int(sys.argv[1]))
cap.set(cv2.CAP_PROP_FPS, 15)

gui.init()

while True:
    gui.update()
    if gui.paused:
        continue

    _, image = cap.read()
    plot.clear()

    image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    gui.show(image_rgb, "camera_rgb")

    image_marker_view = image_rgb.copy()

    markers = scanner.scan(image)

    reference = None
    for marker in markers:
        if marker.type == "reference":
            reference = marker
            break

    image_ref_transform = image_rgb.copy()
    if reference is not None:
        reference.display(image_ref_transform)
    gui.show(image_ref_transform, "camera_ref_transform")
Example #7
0
def scan(image):
    "Scan an image for markers."
    image_blur = cv2.GaussianBlur(image, (15, 15), 0)

    image_hsv = cv2.cvtColor(image_blur, cv2.COLOR_BGR2HSV)
    gui.show(image_hsv, "camera_hsv")

    image_gray = cv2.cvtColor(image_blur, cv2.COLOR_BGR2GRAY)
    gui.show(image_gray, "camera_gray")

    mask = cv2.inRange(image_hsv, BLUE_MIN, BLUE_MAX)
    gui.show(mask, "mask_border")

    contours = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL,
                                cv2.CHAIN_APPROX_SIMPLE)
    contours = imutils.grab_contours(contours)

    markers = []

    mask_with_contours = cv2.cvtColor(mask, cv2.COLOR_GRAY2RGB)
    image_with_contours = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

    cv2.drawContours(mask_with_contours, contours, -1, (0, 255, 0), 2)
    cv2.drawContours(image_with_contours, contours, -1, (0, 255, 0), 2)

    gui.show(mask_with_contours, "mask_border_contours")
    gui.show(image_with_contours, "camera_border_contours")

    image_with_approx = image_with_contours.copy()

    for contour in contours:

        length = cv2.arcLength(contour, True)

        if length < 20:
            continue

        epsilon = 0.05 * length
        approx = cv2.approxPolyDP(contour, epsilon, True)

        if len(approx) != 4:
            continue

        distances = []

        for i in range(len(approx)):
            point = approx[i]
            next = approx[(i + 1) % 4]
            dist = scipy.spatial.distance.euclidean(point, next)
            distances.append(dist)

        maxDist = 0
        for dist in distances:
            if dist > maxDist:
                maxDist = dist

        for dist in distances:
            # Make sure polygons have reasonable dimensions
            if dist < 0.3 * maxDist:
                break
        else:
            new_marker = marker.Marker(image_gray,
                                       [[int(coord) for coord in column[0]]
                                        for column in approx])
            if new_marker.is_valid:
                markers.append(new_marker)
                cv2.polylines(image_with_approx, [approx], True, (255, 0, 0),
                              2)

    gui.show(image_with_approx, "camera_border_approx")
    return markers
Example #8
0
    except KeyboardInterrupt:
        for key in events:
            events[key] = list(set(events[key]))
        print("")
        print(events)


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='remapper')
    parser.add_argument('--cli', help='run application in gui mode')
    parser.add_argument('--debug', help='check events of a evdev')
    parser.add_argument('--run', help='run remapper')
    parser.add_argument('--capture', help='capture events from a device')
    args = parser.parse_args()

    if args.cli:
        print("Welcome to remapper!")
        print("--------------------")
        print("This software allows you to remap a evdev device to your needs!")
        print("")

        main()
    elif args.debug:
        debug()
    elif args.run:
        run()
    elif args.capture:
        capture()
    else:
        gui.show()
Example #9
0
 def showGui(self):
     gui.show()
Example #10
0
def translate():
    translator = goo.Translator()
    kbd.copy()
    time.sleep(0.5)
    res = translator.translate(kbd.read_clipboard(), dest='zh-tw').text
    gui.show(res)
Example #11
0
#!/usr/bin/python2
# coding: utf-8
import misskey
import wx
import login
import gui
import os.path
import os

os.chdir(os.path.abspath(os.path.dirname(__file__)))

app=wx.App()
if(login.load()):
	gui.show()
else:
	login.show()
app.MainLoop()
Example #12
0
def do_Image_recognition():
  global LIMIT_SELECTION, SELECTON_RATE, EXCHANGE_RATE, splitColumns, splitRows, answer, answer, zero4_answer
  ppmFile_content = communication.get_problem(sys.argv[1],TO_COMMUNICATION)
  ppmFile = ppmFile_content[:100]
  splitStrings = re.split("[\t\r\n ]+", ppmFile)
  splitColumns = int(splitStrings[2]) # 横の分割数
  splitRows = int(splitStrings[3]) # 縦の分割数
  LIMIT_SELECTION = int(splitStrings[5]) #選択上限、適宜変更
  SELECTON_RATE = int(splitStrings[7]) #選択コストレート、適宜変更
  EXCHANGE_RATE = int(splitStrings[8]) #交換コストレート、適宜変更
  print LIMIT_SELECTION
  print SELECTON_RATE
  print EXCHANGE_RATE

  # 画像の読み込み
  img = np.asarray(Image.open(StringIO(ppmFile_content)))

  # 画像を分割する
  splitImages = split(img, splitColumns, splitRows)

  resultAToBHeight = {}
  resultAToBWidth = {}
  # こうすることで、4重ループを簡単に書ける。
  for imgANum in itertools.product(range(splitColumns), range(splitRows)):
    #print "imgA=(%d, %d)" % imgANum
    resultsHeight = []
    resultsWidth = []
    for imgBNum in itertools.product(range(splitColumns), range(splitRows)):
      if imgANum == imgBNum:
        continue
      imgA = splitImages[imgANum[0]][imgANum[1]]
      imgB = splitImages[imgBNum[0]][imgBNum[1]]
      differenceHeight = compare(imgA, imgB, False)
      differenceWidth = compare(imgA, imgB, True)

      resultsHeight.append((imgBNum, differenceHeight))
      resultsWidth.append((imgBNum,differenceWidth))
    resultAToBHeight[imgANum] = sorted(resultsHeight, key=lambda a: a[1])
    resultAToBWidth[imgANum] = sorted(resultsWidth,key = lambda a: a[1])

    #print "H  imgB=%s" % ["%s %f" % a for a in resultAToBHeight[imgANum][0:3]]
    #print "W  imgB=%s" % ["%s %f" % a for a in resultAToBWidth[imgANum][0:3]]

  s = time.time()
  #rightBottom = findRightBottom(resultAToBWidth, resultAToBHeight)
  #print "右下はこいつだ!"
  #print rightBottom[0]
  # 逆引きリストを作る
  resultBToAWidth, resultBToAHeight = inverse.inverse2(resultAToBWidth, resultAToBHeight)

  #leftBottom = findRightBottom(resultBToAWidth, resultAToBHeight)
  #print "左下はこいつだ!"
  #print leftBottom[0]
  #leftTop = findRightBottom(resultBToAWidth, resultBToAHeight)
  #print "左上はこいつだ!"
  #print leftTop[0]
  #rightTop = findRightBottom(resultAToBWidth, resultBToAHeight)
  #print "右上はこいつだ!"
  #print rightTop[0]

  sortedImages = createArray(splitColumns, splitRows)
  sortImages2(resultAToBWidth, resultBToAWidth, resultAToBHeight, resultBToAHeight, sortedImages)
  print "ITME = %f" % (time.time() - s)

  zero4_answer = deepcopy(sortedImages)
  zero4_event.set()

  print sortedImages

  def retry(array, correctImages):
    sortImages2(resultAToBWidth, resultBToAWidth, resultAToBHeight, resultBToAHeight, array, correctImages=correctImages)

  def setter(array):
    global answer
    answer = deepcopy(array)
    event.set() # 画像認識の完了を通知する

  def wait():
    event.clear() # 画像認識が完了していないことにする

  gui.show(sortedImages, splitImages, retry=retry, setter=setter, wait=wait)
  #ここまで画像認識
  return sortedImages
Example #13
0
# dataMon2=greenPerformanceData.loc['2016-01-01':'2016-01-31']
# dataMon2=greenPerformanceData.loc['2016-02-01':'2016-02-29']
# dataMon3=greenPerformanceData.loc['2016-03-01':'2016-03-31']
# dataMon4=greenPerformanceData.loc['2016-04-01']

print(dataMon1)
print(dataMon2)
print(dataMon3)
print(dataMon4)

dataMon1Group=dataMon1.groupby(['Service','Status of Order'], as_index=False).agg({'# of Orders':'sum','Total CBV':'sum'})
dataMon1Group.insert(loc=0,column='Month',value='1')
# print(dataMon1Group)
dataMon2Group=dataMon2.groupby(['Service','Status of Order'], as_index=False).agg({'# of Orders':'sum','Total CBV':'sum'})
dataMon2Group.insert(loc=0,column='Month',value='2')
# print(dataMon2Group)
dataMon3Group=dataMon3.groupby(['Service','Status of Order'], as_index=False).agg({'# of Orders':'sum','Total CBV':'sum'})
dataMon3Group.insert(loc=0,column='Month',value='3')
# print(dataMon3Group)
dataMon4Group=dataMon4.groupby(['Service','Status of Order'], as_index=False).agg({'# of Orders':'sum','Total CBV':'sum'})
dataMon4Group.insert(loc=0,column='Month',value='4')
# print(dataMon4Group)
dataMonthly=pd.concat([dataMon1Group,dataMon2Group,dataMon3Group,dataMon4Group])
print(dataMonthly)

# dfgui.show(dataMon1Group)
# dfgui.show(dataMon2Group)
# dfgui.show(dataMon3Group)
# dfgui.show(dataMon4Group)
dfgui.show(dataMonthly)
Example #14
0
def show_app():
    import gui
    app = QtGui.QApplication(sys.argv)
    gui = gui.FarmDB_MainWindow()
    gui.show()
    app.exec_()