本文整理汇总了C++中InputArray::at方法的典型用法代码示例。如果您正苦于以下问题:C++ InputArray::at方法的具体用法?C++ InputArray::at怎么用?C++ InputArray::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputArray
的用法示例。
在下文中一共展示了InputArray::at方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyFilter
void GrayFilterWidget::applyFilter(InputArray in, OutputArray out) const
{
// check weather the filter can be applied
if (!(checkInput(in).first))
{
return;
}
// the filter can be applied
// split the cannels of the input image
auto channels = splitChannels(in.at(0).get());
// create a zero image
cv::Mat tmp = cv::Mat::zeros(in.at(0).get().rows, in.at(0).get().cols,
in.at(0).get().depth());
// multiply all channels with their factor and add it to tmp
// if there are factors for more channels than the input image has, this
// channels
// will be ignored
for (std::size_t i = 0;
((i < channels.size()) && (i < chanValues_.size())); i++)
{
// multiply each channel with its factor and add the result to
// tmp
tmp += channels.at(i) * (chanValues_.at(i)->value());
}
// finally assign tmp to out
out.at(0).get() = tmp;
}
示例2: make_pair
std::pair<bool, QString> ChangedPixelsWidget::checkInput(InputArray in) const
{
if (in.at(0).get().size() != in.at(1).get().size())
{
return std::make_pair(false, "images need to have same size");
}
size_t inChannels = in.at(0).get().channels();
if (inChannels != static_cast<size_t>(in.at(1).get().channels()))
{
return std::make_pair(
false, "images need to have same number of channels");
}
if (inChannels>10 || inChannels<1)
{
return std::make_pair(
false, "images need to have 1 up to 10 channels");
}
int i0depth=in.at(0).get().depth();
if (i0depth!=in.at(1).get().depth())
{
return std::make_pair(
false, "images need to have the same depth");
}
if (!((i0depth==CV_8U)||(i0depth==CV_8S)||(i0depth==CV_16U)||(i0depth==CV_16S)||
(i0depth==CV_32S)||(i0depth==CV_32F)||(i0depth==CV_64F)))
{
return std::make_pair(false, "images have unknown depth");
}
return std::make_pair(true, "");
}