为了让数据集能够有旋转不变形,希望在caffe训练处好结果,我对采集的数据集进行了一个仿射变换。
利用opencv可以比较方便的实现这个事情。
我的数据集还有一些点标注。标注需要在图片旋转的同时把关键点也旋转到合适的位置。
Mat affineTransform(Mat src, std::vector<float>& v)
{
Mat rot_mat(2, 3, CV_32FC1);
Mat dst = Mat::zeros(src.rows, src.cols, src.type());
/** Rotating the image after Warp */
/// Compute a rotation matrix with respect to the center of the image
Point center = Point(dst.cols / 2, dst.rows / 2);
double scale = 0.7;

为了使数据集具有旋转不变性,本文介绍了如何利用OpenCV的AffineTransform进行图像旋转,并同时更新关键点的位置。通过getRotationMatrix2D计算旋转矩阵,然后使用warpAffine进行仿射变换。同时,提供了将关键点坐标转换为旋转后坐标的函数。
最低0.47元/天 解锁文章
1786

被折叠的 条评论
为什么被折叠?



