statusSever_socket.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:VGG 作者: jackfan00 项目源码 文件源码
def drawbbox(self, img, xx, testmodel, confid_thresh, w, h, c):
    ttimg, x0_list, y0_list, x1_list, y1_list, classprob_list, class_id_list, confid_value_list = utils.predict(preprocess_input(np.asarray([xx])), testmodel, confid_thresh,w,h,c)
    for x0,y0,x1,y1,classprob,class_id,confid_value in zip(x0_list, y0_list, x1_list, y1_list, classprob_list, class_id_list, confid_value_list):
        # draw bounding box
        cv2.rectangle(img, (x0, y0), (x1, y1), (255,255,255), 2)
        # draw classimg
        classimg = cv2.imread(cfgconst.label_names[class_id])
                if y0-classimg.shape[0] <= 0:
            yst =0
                        yend =classimg.shape[0]
                elif y0 >= img.shape[0]:
                        yst = img.shape[0]-classimg.shape[0]-1
                        yend = img.shape[0]-1
                else:
                        yst = y0 - classimg.shape[0]
                        yend = y0

                if x0+classimg.shape[1] >= img.shape[1]:
                        xst = img.shape[1]-classimg.shape[1]-1
                        xend = img.shape[1]-1
                elif x0 <=0:
                        xst = 0
                        xend = classimg.shape[1]
                else:
                        xst = x0
                        xend = x0+classimg.shape[1]

                #

                img[yst:yend, xst:xend] = classimg
                # draw text
                font = cv2.FONT_HERSHEY_SIMPLEX
                cv2.putText(img, str(classprob), (x0,y0+classimg.shape[0]-1), font, 0.5,(255,255,255),2,cv2.LINE_AA)
                cv2.putText(img, str(confid_value), (x0,y1), font, 0.5,(128,255,255),1,cv2.LINE_AA)
                #
    cv2.imshow('frame',img)
    cv2.waitKey(1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号