in ReplicaSDK/src/MirrorSurface.cpp [107:127]
void MirrorSurface::GenerateMask(pangolin::ManagedImage<float>& image, int w, int h) {
std::vector<Eigen::Vector2f> bounding_rect_mani;
for (size_t i = 0; i < bounding_rect_w.size(); i++) {
bounding_rect_mani.push_back(T_mani_plane * Unproject(bounding_rect_w[i]));
}
image.Reinitialise(w, h);
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
const float u = 1.0f - ((x + 0.5f) / (float)w);
const float v = 1.0f - ((y + 0.5f) / (float)h);
const Eigen::Vector2f p0 = u * bounding_rect_mani[0] + (1.0f - u) * bounding_rect_mani[1];
const Eigen::Vector2f p1 = u * bounding_rect_mani[2] + (1.0f - u) * bounding_rect_mani[3];
const Eigen::Vector2f p_mani = v * p0 + (1.0f - v) * p1;
const Eigen::Vector3f p_w = T_plane_mani * Unproject(p_mani);
image(x, y) = InBoundary(Eigen::Vector4f(p_w(0), p_w(1), p_w(2), 1.0f)) ? 1.0f : 0.0f;
}
}
}