parameters: (args)
docstring: main
docstring_summary: main
docstring_tokens: main
function: def main(args):
      '''main '''
      # 定义一个检测器类
      detection = CaffeDetection(args.gpu_id,
                                 args.model_def, args.model_weights,
                                 args.image_resize, args.labelmap_file)
      # 检测并获取结果
      result = detection.detect(args.image_file)
      # 打印结果
      print result
      #结果显示
      img = Image.open(args.image_file)#打开图像
      draw = ImageDraw.Draw(img)#显示
      width, height = img.size#原来图像大小
      print width, height
      for item in result:
          # 获取坐标实际整数值
          xmin = int(round(item[0] * width))
          ymin = int(round(item[1] * height))
          xmax = int(round(item[2] * width))
          ymax = int(round(item[3] * height))
          draw.rectangle([xmin, ymin, xmax, ymax], outline=(255, 0, 0))#红色框
          #                      [6] label_name  [5] score   
          draw.text([xmin, ymin], item[-1] + str(item[-2]), (0, 0, 255))#显示文本标签 绿色
          print item
          print [xmin, ymin, xmax, ymax]
          print [xmin, ymin], item[-1]
      img.save('detect_result.jpg')
function_tokens: def main ( args ) : # 定义一个检测器类 detection = CaffeDetection ( args . gpu_id , args . model_def , args . model_weights , args . image_resize , args . labelmap_file ) # 检测并获取结果 result = detection . detect ( args . image_file ) # 打印结果 print result #结果显示 img = Image . open ( args . image_file ) #打开图像 draw = ImageDraw . Draw ( img ) #显示 width , height = img . size #原来图像大小 print width , height for item in result : # 获取坐标实际整数值 xmin = int ( round ( item [ 0 ] * width ) ) ymin = int ( round ( item [ 1 ] * height ) ) xmax = int ( round ( item [ 2 ] * width ) ) ymax = int ( round ( item [ 3 ] * height ) ) draw . rectangle ( [ xmin , ymin , xmax , ymax ] , outline = ( 255 , 0 , 0 ) ) #红色框 #                      [6] label_name  [5] score    draw . text ( [ xmin , ymin ] , item [ - 1 ] + str ( item [ - 2 ] ) , ( 0 , 0 , 255 ) ) #显示文本标签 绿色 print item print [ xmin , ymin , xmax , ymax ] print [ xmin , ymin ] , item [ - 1 ] img . save ( 'detect_result.jpg' )