Stereo-processing of Deimos2 images

70 views
Skip to first unread message

Marin Kneib

unread,
Aug 3, 2021, 3:13:51 AM8/3/21
to Ames Stereo Pipeline Support
Hello,

I am trying to stereo-process a set of Deimos-2 images with ASP - I have scripts that work for Pléiades, but the Deimos-2 images come with the RPC info in a different format (as a text file, see example attached). I first mapproject the images on a reference DEM, which works using the following command:

mapproject -t rpc --t_srs "+proj=utm +zone=45 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" --tr 0.75 $refDEM $img1 $rpc1 ./proj1.tif

It worked with and without specifying the RPC textfile (I can open the resulting images in QGIS and they seem well projected), which makes me think that mapproject reads the information directly from the TIF image.

However, when trying to run stereo, it fails and I get a message saying the images are not map-projected:

stereo -t rpc --subpixel-mode 1 --alignment-method affineepipolar $img1 $img2 ./im12 $refDEM

I read in the documentation that mapproject could output the RPC data, but could not find how to prescribe this? Or am I getting one of the commands wrong?

Thanks for your help!

Marin

DE2_PAN_L1B_000000_20210727T044415_20210727T044421_DE2_38495_DE02_RPC.txt

Oleg Alexandrov

unread,
Aug 3, 2021, 4:14:39 AM8/3/21
to Ames Stereo Pipeline Support
According to your notation, $img1 is not projected and proj1.tif is projected. Then the stereo command can use either the non-projected images without the DEM:

stereo -t rpc --subpixel-mode 1 --alignment-method affineepipolar $img1 $img2 ./im12

or with mapprojected images and the DEM:

stereo -t rpc --subpixel-mode 1 --alignment-method affineepipolar proj1.tif proj2.tif ./im12 $refDEM

I hope both of these work, or else let us know. If things work out, you can also try experimenting with --stereo-algorithm 3 and --subpixel-mode 1 or 3 and see which work better for you.



Marin Kneib

unread,
Aug 3, 2021, 10:04:12 AM8/3/21
to Ames Stereo Pipeline Support
Dear Oleg,

Thanks for the quick reply. Indeed, the stereo command works for the non-projected images without DEM (Option 1 in your answer), however, it fails to run with the mapprojected images and the DEM (Unable to load RPC model from images)).

Cheers

Marin

Oleg Alexandrov

unread,
Aug 3, 2021, 11:50:44 PM8/3/21
to Ames Stereo Pipeline Support
The RPC data is there, since you were able to mapproject things. I guess it is running into trouble when it comes to looking up the RPC cameras from the mapprojected images.

I would not have time to look into this for a few days being on travel. I noticed however that the doc at https://stereopipeline.readthedocs.io/en/latest/examples.html#rpc-images-including-geoeye-airbus-cartosat-1-and-perusat-1 says this:

If the RPC coefficients are not stored in the original Tif images, but rather in associated .RPB or _RPC.TXT files, mapproject creates these files automatically for each map-projected image.

Maybe you can peek where your images are stored and see if you find any .RPB files or _RPC.txt files for the input images, which would have the RPC coefficients. (Or something named along the same lines.) Then the mapprojected images can be created in the same directory as the input images, and one can manually create such files for the mapprojected images using the same convention as for the input images.

We use GDAL to load the RPC camera, so there's a chance it does not get what it expects, and hopefully some trick will help it out. If not, it could be a bug on our side which would need a closer look.

Marin Kneib

unread,
Aug 4, 2021, 4:29:05 AM8/4/21
to Ames Stereo Pipeline Support
I had indeed seen this sentence in the description and looked for possible output files from the mapproject step but couldn't find anything. 

Ok, that's fine for now I think, I'm reasonably happy with the results from the stereo without prior map-projection, so can work with this for now! But let me know if you can find a way around this!

Thanks a lot for your help!

Cheers

Marin

Shashank Bhushan

unread,
Aug 4, 2021, 11:28:05 AM8/4/21
to Oleg Alexandrov, Ames Stereo Pipeline Support
Hi,
You could also copy RPC from original images onto the mapprojected images using gdal like here: https://github.com/uw-cryo/skysat_stereo/blob/468499682ff25040cbeee0cdc53a74f1bb0f6054/skysat_stereo/skysat.py#L99 and then run stereo on those. 

Cheers,
Shashank

--
You received this message because you are subscribed to the Google Groups "Ames Stereo Pipeline Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ames-stereo-pipeline...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ames-stereo-pipeline-support/d20951a5-4522-4ecf-adf6-1ca990a8492cn%40googlegroups.com.


--
Shashank Bhushan
Graduate Student/Research Assistant
Civil & Environmental Engineering
University of Washington, Seattle

Marin Kneib

unread,
Aug 17, 2021, 3:12:13 AM8/17/21
to Ames Stereo Pipeline Support
Dear Shashank,

Sorry for the late reply.

This actually solved the issue, thanks a lot for the great tip!

Cheers

Marin

Oleg Alexandrov

unread,
Aug 19, 2021, 7:33:16 PM8/19/21
to Ames Stereo Pipeline Support
Glad to hear Shashank's suggestion solved your issue. 

I was wrong then that the metadata for this particular camera, Deimos-2, would be in an auxiliary file, as it happens for other datasets, so perhaps it is actually embedded in the .tif file. 

I should be able to incorporate something along the lines of Shashank's logic into our mapproject tool, but regretfully I have no data to test it on. If at some point I get hold of representative data I will put a fix. 


Oleg Alexandrov

unread,
Aug 30, 2021, 1:08:38 PM8/30/21
to Ames Stereo Pipeline Support
Shashank provided me with test data, thank you. 

I put a fix. If the RPC model is embedded in the image file, rather than being in a separate file, the mapproject tool will now embed it in the output image file. This way stereo with mapprojected images works.  

ben.pu...@gmail.com

unread,
Aug 31, 2021, 3:25:30 AM8/31/21
to Ames Stereo Pipeline Support
Hi all, perfect timing for me to be running into the same issue it seems. I'm using SPOT6 images, bundle adjusting then mapproject. After mapproject the images look great (aligned in QGIS) but the RPC metadata wasn't in the .tif. I wrote a little python script per Shashank's suggestion to copy the RPC metadata (using the function here: https://github.com/uw-cryo/skysat_stereo/blob/468499682ff25040cbeee0cdc53a74f1bb0f6054/skysat_stereo/skysat.py#L99) and a gdalinfo call on the mapprojected GeoTiffs now displays the RPC info... but when I run stereo on the mapprojected images I still get the same "Unable to load RPC model". Maybe I need to wait for the next release with the mapproject updates made by Oleg, but I'm surprised, since the RPC metadata is definitely in the mapprojected images and it matches the metadata by in the original un-projected.

ben.pu...@gmail.com

unread,
Aug 31, 2021, 9:43:56 AM8/31/21
to Ames Stereo Pipeline Support
Just a quick update, the nightly build solved the issue and wrote the correct RPC info to the map projected images. Not sure what the issue was with my work-around, but it works now, so no complaints. Thanks!

Oleg Alexandrov

unread,
Aug 31, 2021, 11:53:43 AM8/31/21
to ben.pu...@gmail.com, Ames Stereo Pipeline Support
My own fix for Deimos 2 just made it to the nightly build now. I guess your issue was somewhat unrelated but I am glad either way your problem is solved. 

You received this message because you are subscribed to a topic in the Google Groups "Ames Stereo Pipeline Support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ames-stereo-pipeline-support/UkOpj0kzxsw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ames-stereo-pipeline...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ames-stereo-pipeline-support/8f81e1d3-dc4b-4d20-b95b-443d1ce558b4n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages