IVALab Python Libraries
Collection of code for computer vision and robotics with specific API.
Classes | Functions | Variables
puzzle.utils.dataProcessing Namespace Reference

Classes

class  copyAttributes
 

Functions

def agglomerativeclustering_id_2d (dict_id_2d, cluster_num)
 
def calculateMatches (des1, des2, ratio_threshold=0.7)
 Calculate the matches based on KNN. More...
 
def checkKey (dict1, dict2, value)
 
def closestNumber (num, basis=50, lower=True)
 
def convert_dict2ROS (info_dict)
 
def convert_ROS2dict (message)
 
def convert_serializable (input)
 
def kmeans_id_2d (dict_id_2d, kmeans_num)
 
def partition_even (data_list, partition_num, order="ascend")
 
def updateLabel (x_list, x_label)
 Update the label according to the ranking of all the elements' (with the same label) mean value. More...
 

Variables

dictionary dict_id_2d = {0: [0, 0], 1: [1, 1], 2: [0.4, 0.4], 3: [3, 3], 4: [4, 4], 5: [5, 5], 6: [0.6, 0.6], 7: [7, 7], 8: [8, 8], 9: [0.9, 0.9]}
 

Function Documentation

◆ agglomerativeclustering_id_2d()

def puzzle.utils.dataProcessing.agglomerativeclustering_id_2d (   dict_id_2d,
  cluster_num 
)
@brief  Agglomerative clustering for a dict of id: 2D data.

Args:
    dict_id_2d: The dictionary of id: 2D data.

Returns:
    dict_id_label: The updated dictionary of 2D data.

◆ calculateMatches()

def puzzle.utils.dataProcessing.calculateMatches (   des1,
  des2,
  ratio_threshold = 0.7 
)

Calculate the matches based on KNN.

For premise behind this approach, see https://github.com/adumrewal/SIFTImageSimilarity/blob/master/SIFTSimilarityInteractive.ipynb

Parameters
[in]des1First descriptor.
[in]des2Second descriptor.
[in]topResultsFinal matches.

◆ checkKey()

def puzzle.utils.dataProcessing.checkKey (   dict1,
  dict2,
  value 
)
@brief Check the key & value pairs between two dicts given a query value.

Args:
    dict1: Query dict 1.
    dict2:  Query dict 2.
    value:  Query value.

Returns:
    Whether the keys found are the same.

◆ closestNumber()

def puzzle.utils.dataProcessing.closestNumber (   num,
  basis = 50,
  lower = True 
)
@brief Get the closest number to the basis target for the input number.
e.g., 580 with 50 -> 550

Args:
    num: The input number.
    basis: The basis target number.
    lower: The direction.

Returns:
    The integer of the closest number.

◆ convert_dict2ROS()

def puzzle.utils.dataProcessing.convert_dict2ROS (   info_dict)
@brief Convert the dict to ROS string. See https://github.com/uos/rospy_message_converter

Args:
    info_dict: the input dict.

Returns:
    json_str: the ROS string.

◆ convert_ROS2dict()

def puzzle.utils.dataProcessing.convert_ROS2dict (   message)
@brief Convert the ROS string to dict.

Args:
    message: the input ROS string.

Returns:
    info_dict: the obtained dict.

◆ convert_serializable()

def puzzle.utils.dataProcessing.convert_serializable (   input)
@brief Convert the object to a serializable object.

Args:
    input: the input object.

Returns:
    The serializable object.

◆ kmeans_id_2d()

def puzzle.utils.dataProcessing.kmeans_id_2d (   dict_id_2d,
  kmeans_num 
)
@brief  Kmeans clustering for a dict of id: 2D data.

Args:
    dict_id_2d: The dictionary of id: 2D data.
    kmeans_num: The number of clusters.

Returns:
    dict_id_label: The updated dictionary of 2D data.

◆ partition_even()

def puzzle.utils.dataProcessing.partition_even (   data_list,
  partition_num,
  order = "ascend" 
)
Partition a list of numbers evenly into a number of sets based on their values
e.g. data = [4, 11, 14, 3, 32, 35], partition_number = 3, order=ascend.
result: labels = [0, 1, 1, 0, 2, 2]

Args:
    data_list ((N, )):              The list of data
    partition_num (int):            The partition numebr
    order (str):                    ascend or descend. THe partition is based on increase order or decrease order
                                    (i.e. The numbers in the first set is the lowest or the highest)
Returns:
    labels ((N, 1)):                                                The partition label
    part_results ((partition_num, N/partition_num)):                The partition results

◆ updateLabel()

def puzzle.utils.dataProcessing.updateLabel (   x_list,
  x_label 
)

Update the label according to the ranking of all the elements' (with the same label) mean value.

E.g., x_list = [28,137,263,269,33,151] / x_label = [2,3,1,1,2,3] -> x_label_updated = [0,1,2,2,0,1]

Parameters
[in]x_listValue list.
[in]x_labelOriginal label.
[out]x_label_updatedThe updated label.

Variable Documentation

◆ dict_id_2d

dictionary dict_id_2d = {0: [0, 0], 1: [1, 1], 2: [0.4, 0.4], 3: [3, 3], 4: [4, 4], 5: [5, 5], 6: [0.6, 0.6], 7: [7, 7], 8: [8, 8], 9: [0.9, 0.9]}