def gl_draw_frame(self,img_size,color = (1.0,0.2,0.6,1.0),highlight=False,surface_mode=False,marker_mode=False):
"""
draw surface and markers
"""
if self.detected:
r,g,b,a = color
frame = np.array([[[0,0],[1,0],[1,1],[0,1],[0,0]]],dtype=np.float32)
hat = np.array([[[.3,.7],[.7,.7],[.5,.9],[.3,.7]]],dtype=np.float32)
hat = cv2.perspectiveTransform(hat,self.m_to_screen)
frame = cv2.perspectiveTransform(frame,self.m_to_screen)
alpha = min(1,self.build_up_status/self.required_build_up)
if highlight:
draw_polyline_norm(frame.reshape((5,2)),1,RGBA(r,g,b,a*.1),line_type=GL_POLYGON)
draw_polyline_norm(frame.reshape((5,2)),1,RGBA(r,g,b,a*alpha))
draw_polyline_norm(hat.reshape((4,2)),1,RGBA(r,g,b,a*alpha))
text_anchor = frame.reshape((5,-1))[2]
text_anchor[1] = 1-text_anchor[1]
text_anchor *=img_size[1],img_size[0]
text_anchor = text_anchor[0],text_anchor[1]-75
surface_edit_anchor = text_anchor[0],text_anchor[1]+25
marker_edit_anchor = text_anchor[0],text_anchor[1]+50
if self.defined:
if marker_mode:
draw_points([marker_edit_anchor],color=RGBA(0,.8,.7))
else:
draw_points([marker_edit_anchor])
if surface_mode:
draw_points([surface_edit_anchor],color=RGBA(0,.8,.7))
else:
draw_points([surface_edit_anchor])
self.glfont.set_blur(3.9)
self.glfont.set_color_float((0,0,0,.8))
self.glfont.draw_text(text_anchor[0]+15,text_anchor[1]+6,self.marker_status())
self.glfont.draw_text(surface_edit_anchor[0]+15,surface_edit_anchor[1]+6,'edit surface')
self.glfont.draw_text(marker_edit_anchor[0]+15,marker_edit_anchor[1]+6,'add/remove markers')
self.glfont.set_blur(0.0)
self.glfont.set_color_float((0.1,8.,8.,.9))
self.glfont.draw_text(text_anchor[0]+15,text_anchor[1]+6,self.marker_status())
self.glfont.draw_text(surface_edit_anchor[0]+15,surface_edit_anchor[1]+6,'edit surface')
self.glfont.draw_text(marker_edit_anchor[0]+15,marker_edit_anchor[1]+6,'add/remove markers')
else:
progress = (self.build_up_status/float(self.required_build_up))*100
progress_text = '%.0f%%'%progress
self.glfont.set_blur(3.9)
self.glfont.set_color_float((0,0,0,.8))
self.glfont.draw_text(text_anchor[0]+15,text_anchor[1]+6,self.marker_status())
self.glfont.draw_text(surface_edit_anchor[0]+15,surface_edit_anchor[1]+6,'Learning affiliated markers...')
self.glfont.draw_text(marker_edit_anchor[0]+15,marker_edit_anchor[1]+6,progress_text)
self.glfont.set_blur(0.0)
self.glfont.set_color_float((0.1,8.,8.,.9))
self.glfont.draw_text(text_anchor[0]+15,text_anchor[1]+6,self.marker_status())
self.glfont.draw_text(surface_edit_anchor[0]+15,surface_edit_anchor[1]+6,'Learning affiliated markers...')
self.glfont.draw_text(marker_edit_anchor[0]+15,marker_edit_anchor[1]+6,progress_text)
评论列表
文章目录