OpenDroneMap / ODM

A command line toolkit to generate maps, point clouds, 3D models and DEMs from drone, balloon or kite images. 📷
https://opendronemap.org
GNU Affero General Public License v3.0
4.86k stars 1.1k forks source link

"--resize-to -1" doesn't work #691

Closed tmizu23 closed 6 years ago

tmizu23 commented 6 years ago

if "--resize-to" is -1, odm_georeferencing.py or Georef.cpp does't process as original size. value -1 valid only opensfm process. Until it is fixed, It is better to modify help and manual.

dakotabenjamin commented 6 years ago

Hi, Are you running from master, or v0.3.1?

tmizu23 commented 6 years ago

I run it with Windows docker latest opendronemap/opendronemap image. "img_size" parameter in odmgeoreferencing.py is "bundleResizedTo" in Georef.cpp as without change. And bundleResizedTo_ is used in caliculating cam.focal_length. Then cam.focal_length is used in isFaceProjected() and getPixelCoordinates() function in modifiedPclFunctions.cpp

dakotabenjamin commented 6 years ago

Instead of running --resize-to -1 try --skip-resize

tmizu23 commented 6 years ago

Hi,thank you reply. --skip-resize was removed at "Remove Resize module" committed on 25 Aug

tmizu23 commented 6 years ago

I tried to fix this issue by changing Georef.cpp.

and this code will also fix the issue that gcp with resized image by --resize-to doesn't return correct result. When using GCP, the previous code seems to be the correct result only for the original size image.

and I think that gcp_list.txt should be made with the original image size even if setting the resize option, so I changed the code like it. ref. #541 #632

Please check the code. Changing Georef.cpp from L797 https://github.com/OpenDroneMap/OpenDroneMap/blob/master/modules/odm_georef/src/Georef.cpp#L797

    // Caluculate resize scale
    double resize_scale = 1.0;
    cv::Mat image = cv::imread(cam.texture_file);
    if(bundleResizedTo_ == -1) bundleResizedTo_ = image.cols;
    resize_scale = static_cast<double>(bundleResizedTo_)/image.cols;

    // Rescale the heigh, width, focal_length 
    cam.height = static_cast<double>(image.rows) * resize_scale;
    cam.width = static_cast<double>(image.cols) * resize_scale;
    cam.focal_length *= resize_scale;

    // Rescale the pixcelX, pixcelY of gcp_list.txt
    // The pixel position for the GCP in pcl-format in order to use pcl-functions 
    pcl::PointXY gcpPos;
    gcpPos.x = static_cast<float>(gcps_[gcpIndex].pixelX_ * resize_scale );
    gcpPos.y = static_cast<float>(gcps_[gcpIndex].pixelY_ * resize_scale);
dakotabenjamin commented 6 years ago

Sorry, I forgot that was my removal 😨

So now in the code there is no resizing done, the --resize-to only applies to OpenSfM for speeding up the process. Everything else uses the original images for maximum resolution. When georef is called, it uses the original image size, therefore resize_scale should always be 1. We should simply remove all the resize stuff from odm_georeferencing to make it simple.

tmizu23 commented 6 years ago

almost +1, but there is a bug at the moment, so please fix following points.

Georef.cpp L800 should be commented out for georeferencing correctly https://github.com/OpenDroneMap/OpenDroneMap/blob/master/modules/odm_georef/src/Georef.cpp#L800

dakotabenjamin commented 6 years ago

This should be fixed in latest master