1 #include "../lib/common.h" 2 #include "../lib/args.h" 3 #include "../lib/image_io.h" 4 #include "../lib/opencv.h" 5 #include "../lib/json.h" 6 #include "../lib/border.h" 7 #include "../lib/view_homography.h" 13 int main(
int argc,
const char* argv[]) {
14 get_args(argc, argv,
"homography.json in_image.png out_image.png texture/depth [border.json]");
18 std::string image_type =
enum_arg({
"texture",
"depth" });
29 mat33 H = offset_mat * homography.
mat;
31 if(image_type ==
"texture") {
32 cv::Mat_<cv::Vec3b> in_image =
load_texture(in_image_filename);
33 cv::Mat_<cv::Vec3b> out_image;
34 cv::Size dsize =
add_border(bord, in_image.size());
35 cv::warpPerspective(in_image, out_image, H, dsize, cv::INTER_CUBIC, cv::BORDER_CONSTANT, cv::Scalar(
background_color));
38 }
else if(image_type ==
"depth") {
39 cv::Mat_<ushort> in_image =
load_depth(in_image_filename);
40 cv::Mat_<ushort> out_image;
41 cv::Size dsize =
add_border(bord, in_image.size());
42 cv::warpPerspective(in_image, out_image, H, dsize, cv::INTER_NEAREST, cv::BORDER_CONSTANT, 0);
void save_depth(const std::string &filename, const cv::Mat_< ushort > &depth)
void save_texture(const std::string &filename, const cv::Mat_< cv::Vec3b > &texture)
std::string in_filename_arg()
std::string enum_arg(const std::vector< std::string > &options)
cv::Mat_< ushort > load_depth(const std::string &filename)
border decode_border(const json &j_bord)
const cv::Vec3b background_color(0, 0, 0)
cv::Mat_< cv::Vec3b > load_texture(const std::string &filename)
int main(int argc, const char *argv[])
cv::Matx< real, 3, 3 > mat33
view_homography homography_arg()
cv::Size add_border(const border &bord, const cv::Size &sz)
std::string out_filename_arg()
json import_json_file(const std::string &filename)
std::string in_filename_opt_arg(const std::string &def="")
void get_args(int argc, const char *argv[], const std::string &usage)