Пример #1
0
cv::Mat3b OpenCVUtil::pad_image(const cv::Mat3b& image, int paddingSize)
{
  cv::Mat3b paddedImage = cv::Mat3b::zeros(image.rows + paddingSize * 2, image.cols + paddingSize * 2);
  cv::Rect roi(paddingSize, paddingSize, image.cols, image.rows);
  image.copyTo(paddedImage(roi));
  return paddedImage;
}
Пример #2
0
void tgTextureModel::TextureFromImage(const tgCamera& cam, const cv::Mat3b& image)
{
  ComputeFaceNormals();
  m_face_tex_id.clear();

  std::vector<bool> vertex_used(m_vertices.size(), false);
  for (size_t i = 0; i < m_faces.size(); i++)
  {
    TomGine::tgFace &f = m_faces[i];

    for (size_t j = 0; j < f.v.size(); j++)
    {
      const unsigned &vidx = f.v[j];
      if (vertex_used[vidx])
        continue;

      vertex_used[vidx] = true;
      TomGine::tgVertex &v = m_vertices[vidx];

      v.texCoord = cam.GetTexCoords(v.pos);
      v.texCoord.y = 1.0f - v.texCoord.y; // cv::Mat to OpenGL
    }
    m_face_tex_id.push_back(0);
  }
  m_tex_cv.resize(1);
  image.copyTo(m_tex_cv[0]);
}