当前位置: 首页>>代码示例>>C++>>正文


C++ Image::AsMat方法代码示例

本文整理汇总了C++中Image::AsMat方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::AsMat方法的具体用法?C++ Image::AsMat怎么用?C++ Image::AsMat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image的用法示例。


在下文中一共展示了Image::AsMat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetImage

Image* Frame::GetImage(int width, int height,
                       VideoMode::PixelFormat pixelFormat, int jpegQuality) {
  if (!m_impl) return nullptr;
  std::lock_guard<wpi::recursive_mutex> lock(m_impl->mutex);
  Image* cur = GetNearestImage(width, height, pixelFormat);
  if (!cur || cur->Is(width, height, pixelFormat)) return cur;

  DEBUG4("converting image from "
         << cur->width << "x" << cur->height << " type " << cur->pixelFormat
         << " to " << width << "x" << height << " type " << pixelFormat);

  // If the source image is a JPEG, we need to decode it before we can do
  // anything else with it.  Note that if the destination format is JPEG, we
  // still need to do this (unless the width/height were the same, in which
  // case we already returned the existing JPEG above).
  if (cur->pixelFormat == VideoMode::kMJPEG) cur = ConvertMJPEGToBGR(cur);

  // Resize
  if (!cur->Is(width, height)) {
    // Allocate an image.
    auto newImage = m_impl->source.AllocImage(
        cur->pixelFormat, width, height,
        width * height * (cur->size() / (cur->width * cur->height)));

    // Resize
    cv::Mat newMat = newImage->AsMat();
    cv::resize(cur->AsMat(), newMat, newMat.size(), 0, 0);

    // Save the result
    cur = newImage.release();
    m_impl->images.push_back(cur);
  }

  // Convert to output format
  return Convert(cur, pixelFormat, jpegQuality);
}
开发者ID:FRCTeam1967,项目名称:FRCTeam1967,代码行数:36,代码来源:Frame.cpp

示例2: GetCv

bool Frame::GetCv(cv::Mat& image, int width, int height) {
  Image* rawImage = GetImage(width, height, VideoMode::kBGR);
  if (!rawImage) return false;
  rawImage->AsMat().copyTo(image);
  return true;
}
开发者ID:FRCTeam1967,项目名称:FRCTeam1967,代码行数:6,代码来源:Frame.cpp


注:本文中的Image::AsMat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。