Train and use an SVM to predict antipodal grasps. More...
#include <learning.h>
Classes | |
struct | Instance |
Learning instance representing a grasp hypothesis. More... | |
struct | UniqueVectorComparator |
Comparator for 2D vectors. More... | |
Public Member Functions | |
std::vector< GraspHypothesis > | classify (const std::vector< GraspHypothesis > &hands_list, const std::string &svm_filename, const Eigen::Matrix3Xd &cam_pos, bool is_plotting=false) |
Predict antipodal grasps using an SVM classifier. | |
Learning () | |
Constructor. | |
Learning (int num_threads) | |
Constructor. Set the number of threads to be used for prediction. | |
void | train (const std::vector< GraspHypothesis > &hands_list, const std::vector< int > &sizes, const std::string &file_name, const Eigen::Matrix3Xd &cam_pos, int max_positive=1000000000, bool is_plotting=false) |
Train an SVM classifier to predict antipodal grasps. | |
void | train (const std::vector< GraspHypothesis > &hands_list, const std::string &file_name, const Eigen::Matrix3Xd &cam_pos, bool is_plotting=false) |
Train an SVM classifier to predict antipodal grasps. | |
void | trainBalanced (const std::vector< GraspHypothesis > &hands_list, const std::vector< int > &sizes, const std::string &file_name, const Eigen::Matrix3Xd &cam_pos, int max_positive=1000000000, bool is_plotting=false) |
Train an SVM classifier to predict antipodal grasps. Uses the same number of positives and negatives for each training point cloud. | |
Private Member Functions | |
void | convertData (const std::vector< Instance > &instances, const std::string &file_name, bool is_plotting=false, bool uses_linear_kernel=false) |
Convert a set of learning instances to training data readable by the SVM. | |
cv::Mat | convertToImage (const Instance &ins) |
Convert a learning instance to a grasp image. | |
Instance | createInstance (const GraspHypothesis &h, const Eigen::Matrix3Xd &cam_pos, int cam=-1) |
Create a learning instance from a grasp hypothesis. | |
Eigen::VectorXi | floorVector (const Eigen::VectorXd &a) |
Round a vector's elements down to the closest, smaller integers. | |
Private Attributes | |
int | num_horizontal_cells_ |
the width of a grasp image | |
int | num_threads_ |
the number of threads used for prediction | |
int | num_vertical_cells_ |
the height of a grasp image |
Train and use an SVM to predict antipodal grasps.
Learning class
This class trains an SVM classifier to predict antipodal grasps. Once trained, it can be used to predict antipodal grasps. The classifier is trained with HOG features obtained from grasp images. A grasp image is a 2D image representation of a grasp hypothesis.
Definition at line 56 of file learning.h.
Learning::Learning | ( | ) | [inline] |
Constructor.
Definition at line 63 of file learning.h.
Learning::Learning | ( | int | num_threads | ) | [inline] |
Constructor. Set the number of threads to be used for prediction.
Definition at line 71 of file learning.h.
std::vector< GraspHypothesis > Learning::classify | ( | const std::vector< GraspHypothesis > & | hands_list, |
const std::string & | svm_filename, | ||
const Eigen::Matrix3Xd & | cam_pos, | ||
bool | is_plotting = false |
||
) |
Predict antipodal grasps using an SVM classifier.
hands_list | the set of grasp hypotheses to be tested for being antipodal grasps |
file_name | the location and name of the file in which the SVM is stored |
cam_pos | the camera poses |
is_plotting | whether the training process is visualized |
Definition at line 165 of file learning.cpp.
void Learning::convertData | ( | const std::vector< Instance > & | instances, |
const std::string & | file_name, | ||
bool | is_plotting = false , |
||
bool | uses_linear_kernel = false |
||
) | [private] |
Convert a set of learning instances to training data readable by the SVM.
instances | the training instances to be converted |
file_name | the location and name of the file in which the SVM is stored |
is_plotting | whether the conversion process is visualized |
uses_linear_kernel | whether a linear or a quadratic kernel is used in the SVM |
Definition at line 249 of file learning.cpp.
cv::Mat Learning::convertToImage | ( | const Instance & | ins | ) | [private] |
Convert a learning instance to a grasp image.
ins | the learning instance to be converted |
Definition at line 320 of file learning.cpp.
Learning::Instance Learning::createInstance | ( | const GraspHypothesis & | h, |
const Eigen::Matrix3Xd & | cam_pos, | ||
int | cam = -1 |
||
) | [private] |
Create a learning instance from a grasp hypothesis.
h | the grasp hypothesis from which the learning instance is created |
cam_pos | the camera poses |
cam | index of the camera which produced the points in the grasp hypothesis |
Definition at line 375 of file learning.cpp.
Eigen::VectorXi Learning::floorVector | ( | const Eigen::VectorXd & | a | ) | [private] |
Round a vector's elements down to the closest, smaller integers.
a | the vector whose elements are rounded down |
Definition at line 367 of file learning.cpp.
void Learning::train | ( | const std::vector< GraspHypothesis > & | hands_list, |
const std::vector< int > & | sizes, | ||
const std::string & | file_name, | ||
const Eigen::Matrix3Xd & | cam_pos, | ||
int | max_positive = 1000000000 , |
||
bool | is_plotting = false |
||
) |
Train an SVM classifier to predict antipodal grasps.
hands_list | the set of grasp hypotheses to be used for training |
sizes | the number of grasp hypotheses found for each training point cloud |
file_name | the location and name of the file in which the SVM is stored |
max_positive | the maximum number of positives examples to be used from each training point cloud |
cam_pos | the camera poses |
is_plotting | whether the training process is visualized |
Definition at line 76 of file learning.cpp.
void Learning::train | ( | const std::vector< GraspHypothesis > & | hands_list, |
const std::string & | file_name, | ||
const Eigen::Matrix3Xd & | cam_pos, | ||
bool | is_plotting = false |
||
) |
Train an SVM classifier to predict antipodal grasps.
hands_list | the set of grasp hypotheses to be used for training |
sizes | the number of grasp hypotheses found for each training point cloud |
file_name | the location and name of the file in which the SVM is stored |
is_plotting | whether the training process is visualized |
Definition at line 143 of file learning.cpp.
void Learning::trainBalanced | ( | const std::vector< GraspHypothesis > & | hands_list, |
const std::vector< int > & | sizes, | ||
const std::string & | file_name, | ||
const Eigen::Matrix3Xd & | cam_pos, | ||
int | max_positive = 1000000000 , |
||
bool | is_plotting = false |
||
) |
Train an SVM classifier to predict antipodal grasps. Uses the same number of positives and negatives for each training point cloud.
hands_list | the set of grasp hypotheses to be used for training |
sizes | the number of grasp hypotheses found for each training point cloud |
file_name | the location and name of the file in which the SVM is stored |
cam_pos | the camera poses |
max_positive | the maximum number of positives examples to be used from each training point cloud |
is_plotting | whether the training process is visualized |
Definition at line 3 of file learning.cpp.
int Learning::num_horizontal_cells_ [private] |
the width of a grasp image
Definition at line 198 of file learning.h.
int Learning::num_threads_ [private] |
the number of threads used for prediction
Definition at line 200 of file learning.h.
int Learning::num_vertical_cells_ [private] |
the height of a grasp image
Definition at line 199 of file learning.h.