本文整理汇总了C++中cv::Ptr::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::init方法的具体用法?C++ Ptr::init怎么用?C++ Ptr::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv::Ptr
的用法示例。
在下文中一共展示了Ptr::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateModule
bool updateModule()
{
if (ImageOf<PixelRgb> *iImg=iPort.read())
{
LockGuard lg(mutex);
ImageOf<PixelRgb> &oImg=oPort.prepare();
oImg=*iImg;
cv::Mat frame=cv::cvarrToMat((IplImage*)oImg.getIplImage());
cv::Rect2d result;
if (state==init)
{
tracker=cv::Tracker::create("BOOSTING");
tracker->init(frame,initRect);
result=initRect;
state=run;
}
else if (state==run)
tracker->update(frame,result);
if (state!=idle)
cv::rectangle(frame,
cv::Point((int)result.x,(int)result.y),
cv::Point((int)(result.x+result.width),(int)(result.y+result.height)),
cv::Scalar(0,255,0),2);
oPort.write();
}
return true;
}
示例2: predict
void FisherFaceRecognizer::predict(cv::InputArray _src, cv::Ptr<cv::face::PredictCollector> collector) const
{
qCWarning(DIGIKAM_FACESENGINE_LOG) << "Predicting face image using fisherfaces";
if (m_projections.empty())
{
// throw error if no data (or simply return -1?)
String error_message = "This Fisherfaces model is not computed yet. Did you call the train method?";
CV_Error(CV_StsBadArg, error_message);
}
Mat src = _src.getMat();//254*254
//make sure the size of input image is the same as training image
if (m_src.size() >= 1 && (src.rows != m_src[0].rows || src.cols != m_src[0].cols))
{
//resize(src, src, Size(m_src[0].rows, m_src[0].cols), (0, 0), (0, 0), INTER_LINEAR);
resize(src, src, Size(m_src[0].rows, m_src[0].cols));
}
collector->init(0);//here need to confirm
Mat q = LDA::subspaceProject(m_eigenvectors, m_mean, src.reshape(1, 1));
//find nearest neighbor
for (size_t sampleIdx = 0 ; sampleIdx < m_projections.size() ; sampleIdx++)
{
double dist = norm(m_projections[sampleIdx], q, NORM_L2);
int label = m_labels.at<int>((int) sampleIdx);
if (!collector->collect(label, dist))
{
return;
}
}
}