mihaidusmanu / d2-net

D2-Net: A Trainable CNN for Joint Description and Detection of Local Features
Other
761 stars 163 forks source link

Question about the image undistortion #94

Open ewrfcas opened 1 year ago

ewrfcas commented 1 year ago

Thanks for your great work!

I am using your undistort_reconstructions.py to undistort megadepth images, but some problems have happened. There are 195 scenes in megadepth at all, but only 163 scenes are undistorted successfully. And for those failed cases, they fail to be checked with the image sizes as follows (happened in scene 0001):

Undistorting image [2476/3409]
Undistorting image [2477/3409]
F0906 10:57:19.824895 51649 undistortion.cc:941] Check failed: distorted_camera.Width() == distorted_bitmap.Width() (1280 v
s. 960)
*** Check failure stack trace: ***
    @     0x7f1324b745cd  google::LogMessage::Fail()
    @     0x7f1324b76433  google::LogMessage::SendToLog()
    @     0x7f1324b7415b  google::LogMessage::Flush()
    @     0x7f1324b76e1e  google::LogMessageFatal::~LogMessageFatal()
    @           0x6cc243  colmap::UndistortImage()
    @           0x6cc601  colmap::COLMAPUndistorter::Undistort()
    @           0x6d2974  std::_Function_handler<>::_M_invoke()
Undistorting image [2478/3409]
Undistorting image [2479/3409]
Undistorting image [2480/3409]
    @           0x601b29  std::__future_base::_State_baseV2::_M_do_set()
    @     0x7f13207daa99  __pthread_once_slow
    @           0x6d35ec  std::__future_base::_Task_state<>::_M_run()
    @           0x8655dc  colmap::ThreadPool::WorkerFunc()
    @     0x7f13200acd4e  (unknown)
    @     0x7f13207d36ba  start_thread
    @     0x7f131f7f851d  clone
    @              (nil)  (unknown)
leon5678 commented 1 year ago

hi, i tried to download the MegaDepth_SfM_v1.tar.xz, but failed. could you tell me that how did you download the dataset successfully?

cailile commented 3 weeks ago

I encountered the same problem. I check the camera width in cameras.txt and the image dimension of the corresponding image, and I found that they are actually the same. It is weird that after reading into memory, the dimensions became mismatched. Have you figured out how to get around with it?

mihaidusmanu commented 3 weeks ago

Hello. I remember that some scenes used the default COLMAP parameters (notably the image_undistorter --max_image_size), while some others used some custom values. This is why in the script I try to decide on the right resolution based on the output depthmaps / images provided by MegaDepth. Could it be that there is an issue in the propagation of these params (I have not used these scripts for quite a while now)?

Alternatively, you can directly download the undistorted data from https://cvg-data.inf.ethz.ch/megadepth/

mihaidusmanu commented 3 weeks ago

Another reason why the image sizes might be mismatched is due to EXIF information (notably image rotation) > maybe at some point they were ignored but now they are taken into account.

cailile commented 3 weeks ago

Hello. I remember that some scenes used the default COLMAP parameters (notably the image_undistorter --max_image_size), while some others used some custom values. This is why in the script I try to decide on the right resolution based on the output depthmaps / images provided by MegaDepth. Could it be that there is an issue in the propagation of these params (I have not used these scripts for quite a while now)?

Alternatively, you can directly download the undistorted data from https://cvg-data.inf.ethz.ch/megadepth/

Thanks a lot for the prompt reply and the download link. I look into the source code in colmap/src/colmap/image/undistortion.cc, and found that the error occur in the first line of the function UndistortImage() -- basically the program just done some I/O, not started the undistortion procedure yet. So my feeling is that there should be some bug in the image reading I/O of colmap.

image
mihaidusmanu commented 3 weeks ago

Do you by any chance have one such image where the undistortion fails at hand? I can try to look into it and submit a fix upstream if I figure it out.

cailile commented 3 weeks ago

Do you by any chance have one such image where the undistortion fails at hand? I can try to look into it and submit a fix upstream if I figure it out.

I believe images from MegaDepth_v1_SfM/5017 can be used for debugging. From cameras.txt, you can see that images from this scene is captured by 1 camera:

image

The camera width and height is 2000, 1500. However, with colmap 3.7, I got the following error when running the undistortion script:

image

And I have checked the image size for all the images in MegaDepth_v1_SfM/5017/images, all of them has width 2000 and height 1500.

I believe the undistortion program iterate the images according to the order specified in images.txt. Since it fails at the first one, I think the corresponding image would be the first one in images.txt, which is: image_id 560: P1080890.JPG (though I suspect that all images in this scene would fail)