def ImgDetect(img_path, net, meta, darknet_data, save_path='./', noshow_img=True, save_img=False): import YoloObj img = cv2.imread(img_path) results = DFUNC.detect(net, meta, bytes(img_path, encoding='utf-8'), thresh=float(args.thresh)) objs = [] for result in results: obj = YoloObj.DetectedObj(result) objs.append(obj) for obj in objs: print(obj.obj_string, obj.cx, obj.cy) print('Number of objects: ', len(objs), '\n') YoloObj.DrawBBox(objs, img, show=not noshow_img, save=save_img, save_path=save_path) return objs
def ImgDetect(net, meta, img_np, thresh=0.25): # net: DFUNC.load_net(bytes(darknet_cfg, 'utf-8'), # bytes(darknet_weights, 'utf-8'), 0) # meta: DFUNC.load_meta(bytes(darknet_data, 'utf-8')) # img_np: image in numpy array results = DFUNC.detect(net, meta, img_np, thresh) objs = [] for result in results: obj = YoloObj.DetectedObj(result) objs.append(obj) # sort the objects by confidence objs = sorted(objs, key=lambda x: x.conf, reverse=True) return objs