Add option to export OBJs using a single material
Add a --texturing-single-material option that post-processes the 3D model output to use a single material (something similar to https://github.com/theFroh/imagepacker/blob/master/objuvpacker.py, but with support for multispectral TIFFs inputs, thus using rasterio instead of PIL).
I'd like to help in this one. Please let me know which package are you planning to use for texturing. I'll integrate that in https://github.com/OpenDroneMap/ODM/blob/master/stages/odm_postprocess.py
That would be awesome. :pray:
I think you will need to modify https://github.com/theFroh/imagepacker/blob/master/objuvpacker.py to make it work with rasterio instead of PIL, write a module to bring into ODM (based on imagepacker), then call the module when required. It would be best to add it at the mvs_texturing step, replacing the multi-material model (we don't want two textured model outputs).
I doubt there's a pre-made package that does exactly what we need here.
Please don't mind if it's a noob question, but why do we need rasterio instead of pillow? The module above uses .obj & .mtl file as input. It used PIL to extract images from .mtl. I'm assuming they'll be in jpg/png. Or will they be in .tif for our use case?
Also if possible, please share a sample dataset so that I can fully understand the code and make necessary modifications.
Because multispectral datasets use 16bit/32bit TIFFs, which are not supported by PIL.
https://github.com/pierotofy/drone_dataset_micasense
(Pass --radiometric-calibration camera to generate 32bit TIFFs).
I've created a public repo where I will add the code for the module. I'll get started in a day or two :)
Please share a valid dataset. I'm not able to process this even with min-num-features=32000
[ERROR] The program could not process this dataset using the current settings.
Check that the images have enough overlap, that there are enough recognizable features
and that the images are in focus. You could also try to increase the --min-num-features
parameter.The program will now exit.
Or it'd be awesome if someone can directly share the multispectral obj and mtl files.
Mm, try this one otherwise: https://community.opendronemap.org/t/dji-phantom-4-pro-multipectral-w-o-rtk/4978 (or a subset of it, it's quite large for just testing).
Created 3d models successfully. If anyone wants to use them, download here Now I can get started <3
So far, everything is going well with rasterio integration. There's one thing that I noticed, the .tif texture files that I've generated from ODM don't have any crs, transforms etc. Is it normal??
Yep! You can ignore rasterio's warning.
Help wanted:
I've been wanting to replicate this line, which use arrays extracted from images using PIL:
output_array.paste(image, (block.x, block.y))
I want to do exactly this with our multispectral texture files. Insert the smaller array into the larger. For that, I've made this function:
def insert_at(big, pos, small):
#https://stackoverflow.com/questions/66896138/python-numpy-insert-2d-array-into-bigger-2d-array-on-given-posiiton
x1 = pos[0]
y1 = pos[1]
x2 = x1 + small.shape[1]
y2 = y1 + small.shape[2]
print(x1, '\t', x2, '\t', y1, '\t', y2)
assert x2 <= big.shape[1], "the position will make the small matrix exceed the boundaries at x"
assert y2 <= big.shape[2], "the position will make the small matrix exceed the boundaries at y"
big[x1:x2,y1:y2] = small
return big
output_array = insert_at(output_array, (block.x, block.y), image)
'''
output_array.shape -> (1, 4096, 4608)
image.shape -> (1, 4096, 4096)
block.x -> 0
block.y -> 0
'''
And I'm getting this broadcast error:
ValueError: could not broadcast input array from shape (1,4096,4096) into shape (1,4096,4608)
I have no experience with numpy... Let me know how to solve this.
Try:
big[:,x1:x2,y1:y2] = small
https://numpy.org/devdocs/user/basics.indexing.html
@pierotofy Worked like charm! Now I can proceed further.
Can I inquire about the status of this issue? We also very strongly need to be able to generate single texture map from ODM. Going through blender for this task is not a feasible solution for us. We are not developers but happy to help as much as can (testing feedback etc)...
@muratmaga I'm working on this. Unfortunately, my workload is very heavy. But among my other open source work, this one is high priority. I'll inform once I get this working. I intend to do it by end of month. Sure, testing & feedback will be welcomed! :)
Just have to make minor changes, and it'll be ready for testing. I'll add instructions to run the code as well in the readme.
We are getting ready to submit a paper that uses ODM and 3D Slicer to obtain 3D models of biological specimens. Since we can't use the multi-file texture maps in Slicer currently, we are converting the texture maps into vertex color in meshlab as a preprocessing step, which reduces their quality. Because of that step, textures look inferior to the ones generated by commercial photogrammetry software (which tpyically output a single texture file). It will be great if this is incorporated prior to our paper (which is still some time out), so that we stop doing the step that degrades, what is otherwise a great texture.
Again happy to test and report back...
@muratmaga if you need this in a hurry, perhaps you could offer to sponsor the development of this feature (and I'm sure @theoway would appreciate it). https://docs.opendronemap.org/requesting-features/
I would be happy to sponsor (to a certain amount), but unfortunately it is not as easy as doing a paypal or patreon or something like that as @smathermather can attest.
Please feel free to test it out. I have added instructions on how to use. Note: This still under progress. Some small changes have to be made. I'll get to them in a few days. Please feel free to add issues if you see any bugs. Keep the issues detailed so it'd be easier for me to debug.
And I'd like to thank all of you for your patience and support! Waiting for your feedback. CC @muratmaga @pierotofy
@theoway thank you very much.
I tried with one of my samples, and while the command worked (i.e., produced an output), I have trouble loading the textures. I opened an issue at your repo. I also think that tiff file is not quite standard (it looks like a multichannel image, with three channels containing the identical RGB image). The GH issue contains the dataset I experimented and the commands and outputs.
Thanks all for your help/contributions.
This has now been implemented in #1582. :pray: :tada:
@muratmaga -- check it out... .
Works great. Thank you all. This has been a great addition for us...
I just really appreciate Murat's first example in slicermorph, including QR code "ground" control points for accurate measurements:

It works even nicer and accurate, when the photography is done more carefully (this was just a quick test). Thanks again everyone, much appreciate this feature and the background removal (this is raw output from ODM, no post-processing beyond what's provided).
