/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2013, 2016
*
* Tomasz Trzcinski <t dot trzcinski at ii dot pw dot edu dot pl>
* Mario Christoudias <mariochristoudias at gmail dot com>
* Vincent Lepetit <lepetit at icg dot tugraz dot at>
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
/*
"Learning Image Descriptors with Boosting"
T. Trzcinski, M. Christoudias and V. Lepetit
IEEE Transactions on Pattern Analysis and Machine Intelligence, 2013
"Boosting Binary Keypoint Descriptors"
T. Trzcinski, M. Christoudias, V. Lepetit and P. Fua
Computer Vision and Pattern Recognition (CVPR), 2013
Original code: Tomasz Trzcinski <t dot trzcinski at ii dot pw dot edu dot pl>
OpenCV port by: Cristian Balint <cristian dot balint at gmail dot com>
*/
#include <bitset>
#include "precomp.hpp"
using namespace cv;
using namespace std;
namespace cv
{
namespace xfeatures2d
{
/*
!BoostDesc implementation
*/
class BoostDesc_Impl : public BoostDesc
{
public:
// constructor
explicit BoostDesc_Impl( int desc = BINBOOST_256,
bool use_scale_orientation = true,
float scale_factor = 6.25f );
// destructor
virtual ~BoostDesc_Impl();
// returns the descriptor length in bytes
virtual int descriptorSize() const { return m_descriptor_size; }
// returns the descriptor type
virtual int descriptorType() const { return m_descriptor_type; }
// returns the default norm type
virtual int defaultNorm() const { return m_descriptor_norm; }
// compute descriptors given keypoints
virtual void compute( InputArray image, vector<KeyPoint>& keypoints, OutputArray descriptors );
protected:
/*
* BoostDesc parameters
*/
// size, type, norm
int m_descriptor_size;
int m_descriptor_type;
int m_descriptor_norm;
// desc type
int m_desc_type;
// gradient
// assignment types
enum Assign
{
ASSIGN_HARD = 0,
ASSIGN_BILINEAR = 1,
ASSIGN_SOFT = 2,
ASSIGN_HARD_MAGN = 3,
ASSIGN_SOFT_MAGN = 4
};
// dims
int m_Dims;
// no. weak
// learners
int m_nWLs;
// gradient type
int m_grad_atype;
// patch size
int m_patch_size;
// orient quantitiy
int m_orient_q;
// patch scale factor
float m_scale_factor;
/*
* BoostDesc switches
*/
// switch to enable sample by keypoints orientation
bool m_use_scale_orientation;
/*
* BoostDesc arrays
*/
// image
Mat m_image;
// parameters
// weak learner
Mat m_wl_thresh;
Mat m_wl_orient;
Mat m_wl_x_min, m_wl_x_max;
Mat m_wl_y_min, m_wl_y_max;
Mat m_wl_alpha, m_wl_beta;
private:
/*
* BoostDesc functions
*/
// initialize parameters
inline void ini_params( const int orientQuant, const int patchSize,
const int iGradAssignType,
const int nDim, const int nWLs,
const unsigned int thresh[], const int orient[],
const int x_min[], const int x_max[],
const int y_min[], const int y_max[],
const unsigned int alpha[], const unsigned int beta[] );
}; // END BoostDesc_Impl CLASS
// -------------------------------------------------
/* BoostDesc internal routines */
static void computeGradientMaps( const Mat& im,
const int gradAssignType,
const int orientQuant,
vector<Mat>& gradMap )
{
enum Assign
{
ASSIGN_HARD = 0,
ASSIGN_BILINEAR = 1,
ASSIGN_SOFT = 2,
ASSIGN_HARD_MAGN = 3,
ASSIGN_SOFT_MAGN = 4
};
Mat derivx( im.size(), CV_32FC1 );
Mat derivy( im.size(), CV_32FC1 );
Sobel( im, derivx, derivx.depth(), 1, 0 );
Sobel( im, derivy, derivy.depth(), 0, 1 );
for ( int i = 0; i < orientQuant; i++ )
gradMap.push_back( Mat::zeros( im.size(), CV_8UC1 ) );
int index, index2;
double binCenter, weight;
double binSize = (2 * CV_PI) / orientQuant;
// fill in temp matrices with
// respones to edge detection
const float* pDerivx = derivx.ptr<float>();
const float* pDerivy = derivy.ptr<float>();
for ( int i = 0; i < im.rows; i++ )
{
for ( int j = 0; j < im.cols; j++ )
{
float gradMagnitude = sqrt( (*pDerivx) * (*pDerivx)
+ (*pDerivy) * (*pDerivy) );
if ( gradMagnitude > 20 )
{
double theta = atan2( *pDerivy, *pDerivx );
theta = ( theta < 0 ) ? theta + 2*CV_PI : theta;
index = int( theta / binSize );
index = ( index == orientQuant ) ? 0 : index;
switch ( gradAssignType )
{
case ASSIGN_HARD:
gradMap[index].at<uchar>(i,j) = 1;
break;
case ASSIGN_HARD_MAGN:
gradMap[index].at<uchar>(i,j) = (uchar) cvRound( gradMagnitude );
break;
case ASSIGN_BILINEAR:
index2 = (int) ceil( theta / binSize );
index2 = ( index2 == orientQuant ) ? 0 : index2;
binCenter = ( index + 0.5f ) * binSize;
weight = 1 - abs( theta - binCenter ) / binSize;
gradMap[index ].at<uchar>(i,j) = (uchar) cvRound( 255 * weight );
gradMap[index2].at<uchar>(i,j) = (uchar) cvRound( 255 * ( 1 - weight ) );
break;
case ASSIGN_SOFT:
for ( int binNum = 0; binNum < orientQuant/2 + 1; binNum++ )
{
index2 = ( binNum + index + orientQuant - orientQuant/4 ) % orientQuant;
binCenter = ( index2 + 0.5f ) * binSize;
weight = cos( theta - binCenter );
weight = ( weight < 0 ) ? 0 : weight;
gradMap[index2].at<uchar>(i,j) = (uchar) cvRound( 255 * weight );
}
break;
case ASSIGN_SOFT_MAGN:
for ( int binNum = 0; binNum < orientQuant/2 + 1; binNum++ )
{
index2 = ( binNum + index + orientQuant - orientQuant/4 ) % orientQuant;
binCenter = ( index2 +
没有合适的资源?快使用搜索试试~ 我知道了~
opencv_contrib xfeatures2d boostdesc

温馨提示
boostdesc.cpp boostdesc_bgm.i boostdesc_bgm_bi.i boostdesc_bgm_hd.i boostdesc_binboost_064.i boostdesc_binboost_128.i boostdesc_binboost_256.i boostdesc_lbgm.i
资源推荐
资源详情
资源评论



























收起资源包目录









共 8 条
- 1
资源评论

- zhangwenjie892018-04-09很不错的资源,感谢分享
- yangboy4582018-08-10可以用 非常完美~
- hisway2018-07-28编译可以用
- DennyXu2018-06-15编译linux下的opencv计算机视觉基础库用的着的东西,点赞
- ctguyichang2017-11-14编译opencv3.3需要

yelanggl
- 粉丝: 5
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 1#楼钢筋工程施工方案.doc
- [山东]钢结构工业厂房建设监理规划(图表丰富).doc
- 电缆截面估算方法.doc
- Django可视化人工智能科普平台lw+ppt.rar
- 给排水工程质量检查要点.doc
- 夸脱_使用QT编写的能够实现人脸图片检测以及人脸视频检测的项目.zip
- [福州]商务住宅项目地下室基坑开挖影响分析.docx
- 前端vue2实习笔记记录
- 平板拖车安全操作规程技术交底.doc
- 大学生暑期社会实践活动总结.doc
- ONNX定时器PP-YOLOE PP-YOLOE-s PP-YOLOE-PP-YOLOE-1 PP-YOLOE-x C
- 2015年8月建设工程造价指标(各类建筑).doc
- 长春某住宅楼电气施工组织设计.doc
- 护板与密封装置安装作业指导书.doc
- 住宅项目质量通病防治措施方案.doc
- 地铁车站工程冲孔桩植筋施工工艺.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
