Skip to content

Commit

Permalink
Restyled by yapf
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits committed Aug 9, 2020
1 parent ba6fe85 commit e1d3bd4
Show file tree
Hide file tree
Showing 11 changed files with 231 additions and 220 deletions.
19 changes: 11 additions & 8 deletions gui_cvs/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ def __init__(self, *args):
super(MyApp, self).__init__(*args)

def main(self):
wid = gui.VBox(
width=500, height=500, style={"margin": "5px auto", "padding": "10px"}
)

lbl_description = gui.Label(
"""Example about TableWidget usage.
wid = gui.VBox(width=500,
height=500,
style={
"margin": "5px auto",
"padding": "10px"
})

lbl_description = gui.Label("""Example about TableWidget usage.
Change rows and columns count in order to see the behaviour.
After changing the size, 'Fill the table' content by means of the button."""
)
)

wid.append(lbl_description)

Expand Down Expand Up @@ -62,7 +64,8 @@ def on_column_count_change(self, emitter, value, table):
def fill_table(self, emitter, table):
for ri in range(table.row_count()):
for ci in range(table.column_count()):
table.item_at(ri, ci).set_text("row:%s,column:%s" % (str(ri), str(ci)))
table.item_at(ri, ci).set_text("row:%s,column:%s" %
(str(ri), str(ci)))

def on_use_title_change(self, emitter, value, table):
value = value == "true"
Expand Down
117 changes: 53 additions & 64 deletions gui_wizard/helloworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class untitled(App):
def __init__(self, *args, **kwargs):
# DON'T MAKE CHANGES HERE, THIS METHOD GETS OVERWRITTEN WHEN SAVING IN THE EDITOR
if "editing_mode" not in kwargs.keys():
super(untitled, self).__init__(*args, static_file_path={"my_res": "./res/"})
super(untitled,
self).__init__(*args, static_file_path={"my_res": "./res/"})

def idle(self):
# idle function called every update cycle
Expand All @@ -20,72 +21,60 @@ def main(self):
def construct_ui(self):
# DON'T MAKE CHANGES HERE, THIS METHOD GETS OVERWRITTEN WHEN SAVING IN THE EDITOR
mainContainer = Widget()
mainContainer.attributes.update(
{
"editor_baseclass": "Widget",
"editor_tag_type": "widget",
"editor_newclass": "False",
"editor_constructor": "()",
"class": "Widget",
"editor_varname": "mainContainer",
}
)
mainContainer.style.update(
{
"width": "266px",
"position": "absolute",
"top": "61px",
"left": "16px",
"margin": "0px",
"overflow": "auto",
"height": "257px",
}
)
mainContainer.attributes.update({
"editor_baseclass": "Widget",
"editor_tag_type": "widget",
"editor_newclass": "False",
"editor_constructor": "()",
"class": "Widget",
"editor_varname": "mainContainer",
})
mainContainer.style.update({
"width": "266px",
"position": "absolute",
"top": "61px",
"left": "16px",
"margin": "0px",
"overflow": "auto",
"height": "257px",
})
button = Button("Say Hello")
button.attributes.update(
{
"editor_baseclass": "Button",
"editor_tag_type": "widget",
"editor_newclass": "False",
"editor_constructor": "('Say Hello')",
"class": "Button",
"editor_varname": "button",
}
)
button.style.update(
{
"width": "149px",
"position": "absolute",
"top": "80px",
"left": "37px",
"margin": "0px",
"overflow": "auto",
"height": "29px",
}
)
button.attributes.update({
"editor_baseclass": "Button",
"editor_tag_type": "widget",
"editor_newclass": "False",
"editor_constructor": "('Say Hello')",
"class": "Button",
"editor_varname": "button",
})
button.style.update({
"width": "149px",
"position": "absolute",
"top": "80px",
"left": "37px",
"margin": "0px",
"overflow": "auto",
"height": "29px",
})
mainContainer.append(button, "button")
label = Label("My label")
label.attributes.update(
{
"editor_baseclass": "Label",
"editor_tag_type": "widget",
"editor_newclass": "False",
"editor_constructor": "('My label')",
"class": "Label",
"editor_varname": "label",
}
)
label.style.update(
{
"width": "98px",
"position": "absolute",
"top": "20px",
"left": "20px",
"margin": "0px",
"overflow": "auto",
"height": "25px",
}
)
label.attributes.update({
"editor_baseclass": "Label",
"editor_tag_type": "widget",
"editor_newclass": "False",
"editor_constructor": "('My label')",
"class": "Label",
"editor_varname": "label",
})
label.style.update({
"width": "98px",
"position": "absolute",
"top": "20px",
"left": "20px",
"margin": "0px",
"overflow": "auto",
"height": "25px",
})
mainContainer.append(label, "label")
mainContainer.children["button"].onclick.do(self.onclick_button)

Expand Down
23 changes: 11 additions & 12 deletions src/cvs/webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ class untitled(App):
def __init__(self, *args, **kwargs):
# DON'T MAKE CHANGES HERE, THIS METHOD GETS OVERWRITTEN WHEN SAVING IN THE EDITOR
if "editing_mode" not in kwargs.keys():
super(untitled, self).__init__(*args, static_file_path={"my_res": "./res/"})
super(untitled,
self).__init__(*args, static_file_path={"my_res": "./res/"})

def idle(self):
# idle function called every update cycle
Expand All @@ -21,17 +22,15 @@ def construct_ui(self):
aidcam = OpencvVideoWidget(self)
# aidcam.attributes.update({"src":"/528175722896/get_image_data","editor_newclass":"False","editor_baseclass":"OpencvVideoWidget","editor_constructor":"()","class":"OpencvVideoWidget","editor_tag_type":"widget","editor_varname":"aidcam"})
aidcam.set_identifier("myimage_receiver")
aidcam.style.update(
{
"width": "190px",
"position": "absolute",
"top": "20px",
"left": "20px",
"margin": "0px",
"overflow": "auto",
"height": "177px",
}
)
aidcam.style.update({
"width": "190px",
"position": "absolute",
"top": "20px",
"left": "20px",
"margin": "0px",
"overflow": "auto",
"height": "177px",
})

self.aidcam = aidcam
return self.aidcam
Expand Down
11 changes: 9 additions & 2 deletions src/facencnn/facepose.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,21 @@ def idle(self):

def main(self):
# creating a container VBox type, vertical (you can use also HBox or Widget)
main_container = gui.VBox(width=360, height=680, style={"margin": "0px auto"})
main_container = gui.VBox(width=360,
height=680,
style={"margin": "0px auto"})

self.aidcam = OpencvVideoWidget(self, width=340, height=480)
self.aidcam.style["margin"] = "10px"

self.aidcam.set_identifier("myimage_receiver")
main_container.append(self.aidcam)
self.lbl = gui.Label("This show fps!", width=360, height=30, margin="50px",)
self.lbl = gui.Label(
"This show fps!",
width=360,
height=30,
margin="50px",
)
main_container.append(self.lbl)

return main_container
Expand Down
30 changes: 15 additions & 15 deletions src/handtf/utils/detector_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
# load label map using utils provided by tensorflow object detection api
label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
categories = label_map_util.convert_label_map_to_categories(
label_map, max_num_classes=NUM_CLASSES, use_display_name=True
)
label_map, max_num_classes=NUM_CLASSES, use_display_name=True)
category_index = label_map_util.create_category_index(categories)


Expand Down Expand Up @@ -54,14 +53,14 @@ def load_inference_graph():

# Drawing bounding boxes and distances onto image
def draw_box_on_image(
num_hands_detect,
score_thresh,
scores,
boxes,
classes,
im_width,
im_height,
image_np,
num_hands_detect,
score_thresh,
scores,
boxes,
classes,
im_width,
im_height,
image_np,
):
# Determined using a piece of paper of known length, code can be found in distance to camera
focalLength = 875
Expand Down Expand Up @@ -90,7 +89,8 @@ def draw_box_on_image(
p1 = (int(left), int(top))
p2 = (int(right), int(bottom))

dist = distance_to_camera(avg_width, focalLength, int(right - left))
dist = distance_to_camera(avg_width, focalLength,
int(right - left))

cv2.rectangle(image_np, p1, p2, color, 3, 1)

Expand Down Expand Up @@ -127,9 +127,8 @@ def draw_box_on_image(

# Show fps value on image.
def draw_text_on_image(fps, image_np):
cv2.putText(
image_np, fps, (20, 50), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (77, 255, 9), 2
)
cv2.putText(image_np, fps, (20, 50), cv2.FONT_HERSHEY_SIMPLEX, 0.75,
(77, 255, 9), 2)


# compute and return the distance from the hand to the camera using triangle similarity
Expand All @@ -150,7 +149,8 @@ def detect_objects(image_np, detection_graph, sess):
# Each score represent how level of confidence for each of the objects.
# Score is shown on the result image, together with the class label.
detection_scores = detection_graph.get_tensor_by_name("detection_scores:0")
detection_classes = detection_graph.get_tensor_by_name("detection_classes:0")
detection_classes = detection_graph.get_tensor_by_name(
"detection_classes:0")
num_detections = detection_graph.get_tensor_by_name("num_detections:0")

image_np_expanded = np.expand_dims(image_np, axis=0)
Expand Down
19 changes: 11 additions & 8 deletions src/handtf/webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
)
args = vars(ap.parse_args())


detection_graph, sess = detector_utils.load_inference_graph()


Expand Down Expand Up @@ -54,8 +53,7 @@ def main():

# Run image through tensorflow graph
boxes, scores, classes = detector_utils.detect_objects(
frame, detection_graph, sess
)
frame, detection_graph, sess)

# Draw bounding boxeses and text
detector_utils.draw_box_on_image(
Expand All @@ -71,7 +69,8 @@ def main():

# Calculate Frames per second (FPS)
num_frames += 1
elapsed_time = (datetime.datetime.now() - start_time).total_seconds()
elapsed_time = (datetime.datetime.now() -
start_time).total_seconds()
fps = num_frames / elapsed_time

# Display FPS on frame
Expand All @@ -81,8 +80,7 @@ def main():
if args["display"]:

detector_utils.draw_text_on_image(
"FPS : " + str("{0:.2f}".format(fps)), frame
)
"FPS : " + str("{0:.2f}".format(fps)), frame)

cvs.imshow(cv2.cvtColor(frame, cv2.COLOR_RGB2BGR))

Expand All @@ -103,7 +101,9 @@ def idle(self):
def main(self):
# initcv(process)
# creating a container VBox type, vertical (you can use also HBox or Widget)
main_container = gui.VBox(width=360, height=680, style={"margin": "0px auto"})
main_container = gui.VBox(width=360,
height=680,
style={"margin": "0px auto"})

self.aidcam = OpencvVideoWidget(self, width=340, height=480)
self.aidcam.style["margin"] = "10px"
Expand All @@ -112,7 +112,10 @@ def main(self):
main_container.append(self.aidcam)

# Display FPS on frame
self.lbl = gui.Label("This is a LABEL!", width=360, height=30, margin="10px")
self.lbl = gui.Label("This is a LABEL!",
width=360,
height=30,
margin="10px")
main_container.append(self.lbl)

return main_container
Expand Down
Loading

0 comments on commit e1d3bd4

Please sign in to comment.