-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #2
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,8 +54,8 @@ def on_column_count_change(self, emitter, value, table): | |
table.set_column_count(int(value)) | ||
|
||
def fill_table(self, emitter, table): | ||
for ri in range(0, table.row_count()): | ||
for ci in range(0, table.column_count()): | ||
for ri in range(table.row_count()): | ||
for ci in range(table.column_count()): | ||
Comment on lines
-57
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
table.item_at(ri, ci).set_text("row:%s,column:%s"%(str(ri),str(ci))) | ||
|
||
def on_use_title_change(self, emitter, value, table): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
class untitled(App): | ||
def __init__(self, *args, **kwargs): | ||
#DON'T MAKE CHANGES HERE, THIS METHOD GETS OVERWRITTEN WHEN SAVING IN THE EDITOR | ||
if not 'editing_mode' in kwargs.keys(): | ||
if 'editing_mode' not in kwargs.keys(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
super(untitled, self).__init__(*args, static_file_path={'my_res':'./res/'}) | ||
|
||
def idle(self): | ||
|
@@ -43,7 +43,6 @@ def construct_ui(self): | |
|
||
def onclick_button(self, emitter): | ||
self.mainContainer.children['label'].set_text('hello world') | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
class untitled(App): | ||
def __init__(self, *args, **kwargs): | ||
#DON'T MAKE CHANGES HERE, THIS METHOD GETS OVERWRITTEN WHEN SAVING IN THE EDITOR | ||
if not 'editing_mode' in kwargs.keys(): | ||
if 'editing_mode' not in kwargs.keys(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
super(untitled, self).__init__(*args, static_file_path={'my_res':'./res/'}) | ||
|
||
def idle(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,28 +10,28 @@ def main(): | |
|
||
fcount=0 | ||
start = time.time() | ||
|
||
while True: | ||
sleep(30) | ||
img =cvs.read() | ||
|
||
if img is None : | ||
continue | ||
fcount=fcount+1 | ||
|
||
fcount += 1 | ||
# global lbs | ||
lbs = 'Average FPS: '+ str(fcount / (time.time() - start)) | ||
cvs.setLbs(lbs) | ||
|
||
if camid==1: | ||
img=cv2.flip(img,1) | ||
|
||
#img=cv2.resize(img,(112,112)) | ||
image_char = img.astype(np.uint8).tostring() | ||
rets = facerecog.getfacepose(img.shape[0], img.shape[1], image_char) | ||
|
||
#print 'rets:',rets | ||
for ret in rets: | ||
for ret in rets: | ||
Comment on lines
-13
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
#for ret in each: | ||
print ('draw bounding box for the face') | ||
#cvs.infoshow('draw bounding box for the face') | ||
|
@@ -45,10 +45,10 @@ def main(): | |
#print keypoint | ||
p1 = (int(rect[0]), int(rect[1])) | ||
p2 = (int(rect[0]+rect[2]), int(rect[1]+rect[3])) | ||
|
||
#draw_name(img, rect, ret['name']) | ||
cvs.rectangle(img, p1,p2, (0, 255, 0) , 3, 1) | ||
for p in range(0,106): | ||
for p in range(106): | ||
#print p*2,' = ',keypoint[p*2] | ||
#print p*2+1,' = ',keypoint[p*2+1] | ||
k1=int(rect[0]+keypoint[p*2]) | ||
|
@@ -65,7 +65,6 @@ def __init__(self, *args): | |
def idle(self): | ||
#idle function called every update cycle | ||
self.lbl.set_text(cvs.getLbs()) | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
def main(self): | ||
#creating a container VBox type, vertical (you can use also HBox or Widget) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,9 +67,7 @@ def draw_box_on_image(num_hands_detect, score_thresh, scores, boxes, classes, im | |
id ='closed' | ||
avg_width = 3.0 # To compensate bbox size change | ||
|
||
if i == 0: color = color0 | ||
else: color = color1 | ||
|
||
color = color0 if i == 0 else color1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
(left, right, top, bottom) = (boxes[i][1] * im_width, boxes[i][3] * im_width, | ||
boxes[i][0] * im_height, boxes[i][2] * im_height) | ||
p1 = (int(left), int(top)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ def main(): | |
continue | ||
frame = cv2.resize(frame, (640, 480)) | ||
|
||
if im_height == None: | ||
if im_height is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
im_height, im_width = frame.shape[:2] | ||
|
||
# Convert image to rgb since opencv loads images in bgr, if not accuracy will decrease | ||
|
@@ -50,8 +50,8 @@ def main(): | |
# Run image through tensorflow graph | ||
boxes, scores, classes = detector_utils.detect_objects( | ||
frame, detection_graph, sess) | ||
|
||
|
||
# Draw bounding boxeses and text | ||
detector_utils.draw_box_on_image( | ||
num_hands_detect, score_thresh, scores, boxes, classes, im_width, im_height, frame) | ||
|
@@ -61,21 +61,21 @@ def main(): | |
elapsed_time = (datetime.datetime.now() - | ||
start_time).total_seconds() | ||
fps = num_frames / elapsed_time | ||
|
||
# Display FPS on frame | ||
lbs = "FPS : " + str("{0:.2f}".format(fps)) | ||
cvs.setLbs(lbs) | ||
|
||
if args['display']: | ||
|
||
detector_utils.draw_text_on_image("FPS : " + str("{0:.2f}".format(fps)), frame) | ||
|
||
cvs.imshow(cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)) | ||
|
||
|
||
print("Average FPS: ", str("{0:.2f}".format(fps))) | ||
|
||
|
||
|
||
except KeyboardInterrupt: | ||
print("Average FPS: ", str("{0:.2f}".format(fps))) | ||
|
@@ -88,7 +88,6 @@ def __init__(self, *args): | |
def idle(self): | ||
#idle function called every update cycle | ||
self.lbl.set_text(cvs.getLbs()) | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
def main(self): | ||
# initcv(process) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,4 @@ | |
|
||
def load_config(config_name='config.yaml'): | ||
cfg_f = open(os.path.join(BASE_DIR, config_name), "r+") | ||
cfg = yaml.load(cfg_f) | ||
return cfg | ||
return yaml.load(cfg_f) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,10 @@ | |
|
||
|
||
def within_nms_radius(poses, squared_nms_radius, point, keypoint_id): | ||
for _, _, pose_coord in poses: | ||
if np.sum((pose_coord[keypoint_id] - point) ** 2) <= squared_nms_radius: | ||
return True | ||
return False | ||
return any( | ||
np.sum((pose_coord[keypoint_id] - point) ** 2) <= squared_nms_radius | ||
for _, _, pose_coord in poses | ||
) | ||
Comment on lines
-8
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def within_nms_radius_fast(pose_coords, squared_nms_radius, point): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,11 +25,10 @@ def load_config(model_ord): | |
output_stride = converter_cfg['outputStride'] | ||
checkpoint_name = checkpoints[model_ord] | ||
|
||
model_cfg = { | ||
return { | ||
'output_stride': output_stride, | ||
'checkpoint_name': checkpoint_name, | ||
} | ||
return model_cfg | ||
Comment on lines
-28
to
-32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def load_model(model_id, sess, model_dir=MODEL_DIR): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,8 +48,7 @@ def draw_keypoints( | |
if ks < min_part_confidence: | ||
continue | ||
cv_keypoints.append(cv2.KeyPoint(kc[1], kc[0], 10. * ks)) | ||
out_img = cv2.drawKeypoints(img, cv_keypoints, outImage=np.array([])) | ||
return out_img | ||
return cv2.drawKeypoints(img, cv_keypoints, outImage=np.array([])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def get_adjacent_keypoints(keypoint_scores, keypoint_coords, min_confidence=0.1): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,6 @@ def __init__(self, *args): | |
def idle(self): | ||
#idle function called every update cycle,we show the FPS | ||
self.lbl.set_text(cvs.getLbs()) | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
def main(self): | ||
#creating a container VBox type, vertical (you can use also HBox or Widget) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ def main(): | |
displacementFwd=detection_graph.get_tensor_by_name('displacement_fwd_2:0') | ||
displacementBwd=detection_graph.get_tensor_by_name('displacement_bwd_2:0') | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
fcount=-1 | ||
start = time.time() | ||
while True: | ||
|
@@ -50,8 +50,8 @@ def main(): | |
sleep(50) | ||
continue | ||
|
||
fcount=fcount+1 | ||
|
||
fcount += 1 | ||
# global lbs | ||
lbs = 'Average FPS: '+ str(fcount / (time.time() - start)) | ||
cvs.setLbs(lbs) | ||
|
@@ -60,8 +60,8 @@ def main(): | |
input_image = resizeimg(img,width,height) | ||
tmpimg = img | ||
tmpimg = cv2.resize(tmpimg, (width,height)) | ||
|
||
|
||
input_image = np.array(input_image,dtype=np.float32) | ||
input_image = input_image.reshape(1,width,height,3) | ||
heatmaps_result,offsets_result,displacementFwd_result,displacementBwd_result = sess.run( | ||
|
@@ -71,7 +71,7 @@ def main(): | |
[255, 0, 255], [255, 0, 255]] | ||
|
||
|
||
|
||
pairs = [[5,6],[5,7],[6,8],[7,9],[8,10],[5,11],[6,12],[11,12],[11,13],[12,14],[13,15],[14,16]] | ||
keypoint = [] | ||
ckeypoint = [] | ||
|
@@ -81,18 +81,18 @@ def main(): | |
offsets_result=offsets_result[0] | ||
bbb= np.transpose(offsets_result,(2, 0, 1)) | ||
|
||
for k in range(0,17): | ||
for k in range(17): | ||
heatmaps_result=aaaa[k] | ||
maxheat=np.max(heatmaps_result) | ||
re=np.where(heatmaps_result==maxheat) | ||
|
||
ry=re[0][0] | ||
rx=re[1][0] | ||
offsets_resulty=bbb[0+k] | ||
offsets_resultx=bbb[17+k] | ||
ofx=int(offsets_resultx[ry][rx]+0.5) | ||
ofy=int(offsets_resulty[ry][rx]+0.5) | ||
|
||
px=(rx)*16+ofx | ||
py=(ry)*16+ofy | ||
if maxheat>0.7 : | ||
|
@@ -102,7 +102,7 @@ def main(): | |
else : | ||
keypoint.append(-1); | ||
keypoint.append(-1); | ||
|
||
ckeypoint.append(keypoint[0]) | ||
ckeypoint.append(keypoint[1]) | ||
|
||
|
@@ -118,11 +118,11 @@ def main(): | |
ckeypoint.append(keypoint[2*i+1]) | ||
ckeypoint.append(keypoint[2*i+2]) | ||
ckeypoint.append(keypoint[2*i+2+1]) | ||
|
||
for pair in pairs: | ||
if ckeypoint[2*pair[0]]>0 and ckeypoint[2*pair[1]]>0 : | ||
cvs.line(tmpimg,(ckeypoint[2*pair[0]],ckeypoint[2*pair[0]+1]),(ckeypoint[2*pair[1]],ckeypoint[2*pair[1]+1]),(0,0,255),1) | ||
|
||
cvs.imshow(tmpimg) | ||
print ('frames:',fcount) | ||
|
||
|
@@ -134,8 +134,7 @@ def __init__(self, *args): | |
|
||
def idle(self): | ||
#idle function called every update cycle | ||
self.lbl.set_text(cvs.getLbs()) | ||
pass | ||
self.lbl.set_text(cvs.getLbs()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
def main(self): | ||
#creating a container VBox type, vertical (you can use also HBox or Widget) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
MyApp.main
refactored with the following changes:inline-immediately-returned-variable
)