在410c上做一个拍照号码识别遇上问题,opencv 派生类LogisticRegressionImpl 没有完全实现基类LogisticRe

liangeng4271 2016-10-13 10:07:25
派生类中没有完全实现基类中的纯虚函数,为什么能够使用基类的纯虚函数?下面是opencv的一个使用例子和部分源代码。不知道opencv是如何处理的,各位帮忙指点一下吧。

opencv 机器学习头文件ml.hpp 定义LogisticRegression类代码
class CV_EXPORTS_W LogisticRegression : public StatModel
{
public:

/** Learning rate. */
/** @see setLearningRate */
CV_WRAP virtual double getLearningRate() const = 0;
/** @copybrief getLearningRate @see getLearningRate */
CV_WRAP virtual void setLearningRate(double val) = 0;

/** Number of iterations. */
/** @see setIterations */
CV_WRAP virtual int getIterations() const = 0;
/** @copybrief getIterations @see getIterations */
CV_WRAP virtual void setIterations(int val) = 0;

/** Kind of regularization to be applied. See LogisticRegression::RegKinds. */
/** @see setRegularization */
CV_WRAP virtual int getRegularization() const = 0;
/** @copybrief getRegularization @see getRegularization */
CV_WRAP virtual void setRegularization(int val) = 0;

/** Kind of training method used. See LogisticRegression::Methods. */
/** @see setTrainMethod */
CV_WRAP virtual int getTrainMethod() const = 0;
/** @copybrief getTrainMethod @see getTrainMethod */
CV_WRAP virtual void setTrainMethod(int val) = 0;

/** Specifies the number of training samples taken in each step of Mini-Batch Gradient
Descent. Will only be used if using LogisticRegression::MINI_BATCH training algorithm. It
has to take values less than the total number of training samples. */
/** @see setMiniBatchSize */
CV_WRAP virtual int getMiniBatchSize() const = 0;
/** @copybrief getMiniBatchSize @see getMiniBatchSize */
CV_WRAP virtual void setMiniBatchSize(int val) = 0;

/** Termination criteria of the algorithm. */
/** @see setTermCriteria */
CV_WRAP virtual TermCriteria getTermCriteria() const = 0;
/** @copybrief getTermCriteria @see getTermCriteria */
CV_WRAP virtual void setTermCriteria(TermCriteria val) = 0;

//! Regularization kinds
enum RegKinds {
REG_DISABLE = -1, //!< Regularization disabled
REG_L1 = 0, //!< %L1 norm
REG_L2 = 1 //!< %L2 norm
};

//! Training methods
enum Methods {
BATCH = 0,
MINI_BATCH = 1 //!< Set MiniBatchSize to a positive integer when using this method.
};

/** @brief Predicts responses for input samples and returns a float type.

@param samples The input data for the prediction algorithm. Matrix [m x n], where each row
contains variables (features) of one object being classified. Should have data type CV_32F.
@param results Predicted labels as a column matrix of type CV_32S.
@param flags Not used.
*/
CV_WRAP virtual float predict( InputArray samples, OutputArray results=noArray(), int flags=0 ) const = 0;

/** @brief This function returns the trained paramters arranged across rows.

For a two class classifcation problem, it returns a row matrix. It returns learnt paramters of
the Logistic Regression as a matrix of type CV_32F.
*/
CV_WRAP virtual Mat get_learnt_thetas() const = 0;

/** @brief Creates empty model.

Creates Logistic Regression model with parameters given.
*/
CV_WRAP static Ptr<LogisticRegression> create();

opencv LogisticRegression的派生类LogisticRegressionImpl定义代码

本人怀疑和LogisticRegressionImpl定义中下面的代码有关, 因为下面6个代码分别和没有实现的纯虚函数有关,不知道CV_IMPL_PROPERTY宏是如何实现定义纯虚函数的。

CV_IMPL_PROPERTY(double, LearningRate, params.alpha)
CV_IMPL_PROPERTY(int, Iterations, params.num_iters)
CV_IMPL_PROPERTY(int, Regularization, params.norm)
CV_IMPL_PROPERTY(int, TrainMethod, params.train_method)
CV_IMPL_PROPERTY(int, MiniBatchSize, params.mini_batch_size)
CV_IMPL_PROPERTY(TermCriteria, TermCriteria, params.term_crit)
...全文
1884 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Winston_Jory 2016-10-13
  • 打赏
  • 举报
回复
可能是opencv就是利用了CV_IMPL_PROPERTY宏定义进行get和set开头的内联函数的定义。所以在派生类中还是有积累纯虚函数的定义的。
高通骁龙410C开发板是基于高通400系列处理器的第一块开发板,性能优异,方便调试。它包含先进的电源管理,WIFI 蓝牙,GPS等等,所有都集成在一张信用卡大小的PCB板上。基于64位的410处理器,该开发板支持快速软件开发,可作为样机设计学习参考,并符合消费者96Boards 规范(就是ARM联合Linaro定义的一个以Cortex-A系列处理器开发板为主的ARM开放平台规范,取名96Boards)。这使得它非常易于实现物联网产品的嵌入式计算,包含下一代的机器人,相机,医疗设备,自动售货机,智能建筑,数字标牌,游戏机,等等。 性能特征:支持众多操作系统:安卓5.1&Linux; Kernel3.1,Linux Debian8.0,与WINDOWS 10基于移动物联网核心;性能优异的CPU核心:4核A53能达到1.2GHz,并支持32位与64位;内存存储:1GB LPDDR3 533MHz,8GB eMMC 4.5,SD3.0;图像处理部分:Adreno 306 GPU,支持先进的应用编程接口包含OpenGL ES 3.0, OpenCL, DirectX, 与 content security;视频部分:支持1080P 30帧的高清播放与H.264与H.265 720P的播放与捕获;相机集成ISP能达到13MP;无线部分:支持WIFI 802.11/b/g/n 2.4GHz,蓝牙4.1,Qualcomm® IZat™ Gen8C定位技术,板载WIFI,BT与GPS天线;还拥有丰富的外设有TYPEA HDMI连接器,一个micro usb连接器(只能用在设备模式),两路usb2.0(只能用在主机模式),micro SD卡。

2,851

社区成员

发帖
与我相关
我的任务
社区描述
本论坛以AI、WoS 、XR、IoT、Auto、生成式AI等核心板块组成,为开发者提供便捷及高效的学习和交流平台。 高通开发者专区主页:https://qualcomm.csdn.net/
人工智能物联网机器学习 技术论坛(原bbs) 北京·东城区
社区管理员
  • csdnsqst0050
  • chipseeker
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧