parameters: (detection,withTranscription=False,withConfidence=False,imWidth=0,imHeight=0,validNumPoints=[],validate_cw=True)
return_statement: return points,confidence,transcription
docstring: Validate the format of the dictionary. If the dictionary is not valid an exception will be raised.
      If maxWidth and maxHeight are specified, all points must be inside the imgage bounds.
      Posible values:
      {"points":[[x1,y1],[x2,y2],[x3,x3],..,[xn,yn]]}
      {"points":[[x1,y1],[x2,y2],[x3,x3],..,[xn,yn]],"transcription":"###","confidence":0.4,"illegibility":false}
      {"points":[[x1,y1],[x2,y2],[x3,x3],..,[xn,yn]],"transcription":"###","confidence":0.4,"dontCare":false}
      Returns values from the dictionary. Points , [Confidences], [Transcriptions]
docstring_summary: Validate the format of the dictionary. If the dictionary is not valid an exception will be raised.
      If maxWidth and maxHeight are specified, all points must be inside the imgage bounds.
      Posible values:
      {"points":[[x1,y1],[x2,y2],[x3,x3],..,[xn,yn]]}
      {"points":[[x1,y1],[x2,y2],[x3,x3],..,[xn,yn]],"transcription":"###","confidence":0.4,"illegibility":false}
      {"points":[[x1,y1],[x2,y2],[x3,x3],..,[xn,yn]],"transcription":"###","confidence":0.4,"dontCare":false}
      Returns values from the dictionary. Points , [Confidences], [Transcriptions]
docstring_tokens: Validate the format of the dictionary . If the dictionary is not valid an exception will be raised . If maxWidth and maxHeight are specified all points must be inside the imgage bounds . Posible values : { points : [[ x1 y1 ] [ x2 y2 ] [ x3 x3 ] .. [ xn yn ]] } { points : [[ x1 y1 ] [ x2 y2 ] [ x3 x3 ] .. [ xn yn ]] transcription : ### confidence : 0 . 4 illegibility : false } { points : [[ x1 y1 ] [ x2 y2 ] [ x3 x3 ] .. [ xn yn ]] transcription : ### confidence : 0 . 4 dontCare : false } Returns values from the dictionary . Points [ Confidences ] [ Transcriptions ]
function: def get_tl_dict_values(detection,withTranscription=False,withConfidence=False,imWidth=0,imHeight=0,validNumPoints=[],validate_cw=True):
      """
      Validate the format of the dictionary. If the dictionary is not valid an exception will be raised.
      If maxWidth and maxHeight are specified, all points must be inside the imgage bounds.
      Posible values:
      {"points":[[x1,y1],[x2,y2],[x3,x3],..,[xn,yn]]}
      {"points":[[x1,y1],[x2,y2],[x3,x3],..,[xn,yn]],"transcription":"###","confidence":0.4,"illegibility":false}
      {"points":[[x1,y1],[x2,y2],[x3,x3],..,[xn,yn]],"transcription":"###","confidence":0.4,"dontCare":false}
      Returns values from the dictionary. Points , [Confidences], [Transcriptions]
      """
      confidence = 0.0
      transcription = "";
      points = []
      
      if isinstance(detection, dict) == False :
          raise Exception("Incorrect format. Object has to be a dictionary") 
  
      if not 'points' in detection:
          raise Exception("Incorrect format. Object has no points key)")
  
      if isinstance(detection['points'], list) == False :
          raise Exception("Incorrect format. Object points key have to be an array)") 
  
      num_points = len(detection['points'])
      
      if num_points<3 :
          raise Exception("Incorrect format. Incorrect number of points. At least 3 points are necessary. Found: " +  str(num_points))    
  
      if(len(validNumPoints)>0 and num_points in validNumPoints == False ):
          raise Exception("Incorrect format. Incorrect number of points. Only allowed 4,8 or 12 points)")
  
      for i in range(num_points):
          if isinstance(detection['points'][i], list) == False :
              raise Exception("Incorrect format. Point #" + str(i+1) + " has to be an array)")
  
          if len(detection['points'][i]) != 2 :
              raise Exception("Incorrect format. Point #" + str(i+1) + " has to be an array with 2 objects(x,y) )")     
  
          if isinstance(detection['points'][i][0], (int,float) ) == False or isinstance(detection['points'][i][1], (int,float) ) == False :
              raise Exception("Incorrect format. Point #" + str(i+1) + " childs have to be Integers)")
          
          if (imWidth>0 and imHeight>0):
              validate_point_inside_bounds(detection['points'][i][0],detection['points'][i][1],imWidth,imHeight);        
              
          points.append(float(detection['points'][i][0]))
          points.append(float(detection['points'][i][1]))
          
      if validate_cw :
          validate_clockwise_points(points)
      
      if withConfidence:
          if not 'confidence' in detection:
              raise Exception("Incorrect format. No confidence key)")
  
          if isinstance(detection['confidence'], (int,float)) == False :
              raise Exception("Incorrect format. Confidence key has to be a float)")
          
          if detection['confidence']<0 or detection['confidence']>1 :
              raise Exception("Incorrect format. Confidence key has to be a float between 0.0 and 1.0")
          
          confidence = detection['confidence']
      
      if withTranscription:
          if not 'transcription' in detection:
              raise Exception("Incorrect format. No transcription key)")
          
          if isinstance(detection['transcription'], str) == False :
              raise Exception("Incorrect format. Transcription has to be a string. Detected: " + type(detection['transcription']).__name__ )
          
          transcription = detection['transcription']
          
          if 'illegibility' in detection: #Ensures that if illegibility atribute is present and is True the transcription is set to ### (don't care)
              if detection['illegibility'] == True:
                  transcription = "###"
                  
          if 'dontCare' in detection: #Ensures that if dontCare atribute is present and is True the transcription is set to ### (don't care)
              if detection['dontCare'] == True:
                  transcription = "###"
                  
      return points,confidence,transcription
function_tokens: def get_tl_dict_values ( detection , withTranscription = False , withConfidence = False , imWidth = 0 , imHeight = 0 , validNumPoints = [ ] , validate_cw = True ) : confidence = 0.0 transcription = "" points = [ ] if isinstance ( detection , dict ) == False : raise Exception ( "Incorrect format. Object has to be a dictionary" ) if not 'points' in detection : raise Exception ( "Incorrect format. Object has no points key)" ) if isinstance ( detection [ 'points' ] , list ) == False : raise Exception ( "Incorrect format. Object points key have to be an array)" ) num_points = len ( detection [ 'points' ] ) if num_points < 3 : raise Exception ( "Incorrect format. Incorrect number of points. At least 3 points are necessary. Found: " + str ( num_points ) ) if ( len ( validNumPoints ) > 0 and num_points in validNumPoints == False ) : raise Exception ( "Incorrect format. Incorrect number of points. Only allowed 4,8 or 12 points)" ) for i in range ( num_points ) : if isinstance ( detection [ 'points' ] [ i ] , list ) == False : raise Exception ( "Incorrect format. Point #" + str ( i + 1 ) + " has to be an array)" ) if len ( detection [ 'points' ] [ i ] ) != 2 : raise Exception ( "Incorrect format. Point #" + str ( i + 1 ) + " has to be an array with 2 objects(x,y) )" ) if isinstance ( detection [ 'points' ] [ i ] [ 0 ] , ( int , float ) ) == False or isinstance ( detection [ 'points' ] [ i ] [ 1 ] , ( int , float ) ) == False : raise Exception ( "Incorrect format. Point #" + str ( i + 1 ) + " childs have to be Integers)" ) if ( imWidth > 0 and imHeight > 0 ) : validate_point_inside_bounds ( detection [ 'points' ] [ i ] [ 0 ] , detection [ 'points' ] [ i ] [ 1 ] , imWidth , imHeight ) points . append ( float ( detection [ 'points' ] [ i ] [ 0 ] ) ) points . append ( float ( detection [ 'points' ] [ i ] [ 1 ] ) ) if validate_cw : validate_clockwise_points ( points ) if withConfidence : if not 'confidence' in detection : raise Exception ( "Incorrect format. No confidence key)" ) if isinstance ( detection [ 'confidence' ] , ( int , float ) ) == False : raise Exception ( "Incorrect format. Confidence key has to be a float)" ) if detection [ 'confidence' ] < 0 or detection [ 'confidence' ] > 1 : raise Exception ( "Incorrect format. Confidence key has to be a float between 0.0 and 1.0" ) confidence = detection [ 'confidence' ] if withTranscription : if not 'transcription' in detection : raise Exception ( "Incorrect format. No transcription key)" ) if isinstance ( detection [ 'transcription' ] , str ) == False : raise Exception ( "Incorrect format. Transcription has to be a string. Detected: " + type ( detection [ 'transcription' ] ) . __name__ ) transcription = detection [ 'transcription' ] if 'illegibility' in detection : #Ensures that if illegibility atribute is present and is True the transcription is set to ### (don't care) if detection [ 'illegibility' ] == True : transcription = "###" if 'dontCare' in detection : #Ensures that if dontCare atribute is present and is True the transcription is set to ### (don't care) if detection [ 'dontCare' ] == True : transcription = "###" return points , confidence , transcription