SBCV / Blender-Addon-Photogrammetry-Importer

Addon to import different photogrammetry formats into Blender
MIT License
889 stars 78 forks source link

Not an issue - but a request! #30

Closed PLAN8VR closed 3 years ago

PLAN8VR commented 3 years ago

Hi,

Thank you for this amazing set of tools - really really handy!

I use Meshroom, which is all working brilliantly for me, and I particularly love the way the cameras import allows interpolation and animation of the actual camera points -

I also use Metashape from agisoft (will output from this be possible to import in the future?) , but for now, I can import the cameras and model using Alembic ex/import, but it does not create the keyframe animation - are you able to explain the process of animating between the fixed positions? - Thanks!

SBCV commented 3 years ago

I've not worked with metashape myself, but adding support for it is something we can look into. What file formats does it support? If you could share an example reconstruction of the sceaux castle (like in Blender-Addon-Photogrammetry-Importer/examples) this would simplify the process a lot.

To see what the animation does, have a look at: add_camera_animation() in photogrammetry_importer/utility/blender_camera_utility.py and add_transformation_animation() in photogrammetry_importer/utility/blender_animation_utility.py

In add_transformation_animation() you can see that the addon uses simply Blender's fcurve interpolation functionality to define the interpolation. In addition, the addon ensures that the quaternions (representing the camera motion) show the same sign. This is important to avoid strange results.

Does that help?

PLAN8VR commented 3 years ago

Hi Sebastian,

Thank you very much for taking the time to point me in the right direction - really helpful.

RE metashape - I have attached a low res working file from the Sceaux castle set for you to take a look at.

RE export types, it can manage quite a few depending on whether you are exporting the mesh, the pointcloud, the camera, the depth maps etc - but the image is of the export options when exporting the textured model ... Metashape_File_Types

Sceaux_Castle_Metashape.zip

You can download and use Metashape for free for the first 30 days I believe -

Thanks for your help!

SBCV commented 3 years ago

Since you are primarily interested in importing the camera motion, could you also share a screen shot of the formats that allow to export camera information?

Btw: The Sceaux_Castle_Metashape.zip file you've uploaded does not contain any reconstruction data.

SBCV commented 3 years ago

I found this library for collada, which could be an option to import metashape reconstructions, since it can be installed with pip install pycollada. Can you export your reconstruction as .dae file and post here too?

PLAN8VR commented 3 years ago

Since you are primarily interested in importing the camera motion, could you also share a screen shot of the formats that allow to export camera information?

Btw: The Sceaux_Castle_Metashape.zip file you've uploaded does not contain any reconstruction data.

Hi Sebastian,

Sorry about the attached file, I assumed you wanted Metashape's native save file which is what I attached.

RE collada, yes, it can export .dae, I have attached the Sceaux example (again, very quick and low res build) Sceaux_Castle.zip

RE camera imports from cameras

There is a plugin by Uhlik for importing to Blender Metashape's native camera file (XML) https://github.com/uhlik/bpy#import-agisoft-photoscan-cameras - however, this doesn't really do any more than simply using blender's native Alembic format, but might be worth looking at - I think I noticed he had helped you with the pointcloud part of your addon?

So, I must say a big thank you for taking the time to look at all this for me, and I also must apologize that I am not a coder, so cannot be of much assistance other than sending file formats if required - thank you!

SBCV commented 3 years ago

Sorry about the attached file, I assumed you wanted Metashape's native save file which is what I attached.

The file Sceaux_Castle_Metashape.zip contains currently only the following two lines

<?xml version="1.0" encoding="UTF-8"?>
<document version="1.2.0" path="{projectname}.files/project.zip"/>

RE camera imports from 100205159-a7654400-2efc-11eb-9a46-cf2e9fe1e7ec

Are these the import or the export options? (Because you've wrote RE camera imports from) If these are the import options, please post the export options. If these are the export options, you can export it to the (*.nvm) format, which is already supported by this addon.

Thank you for pointing out the script by Uhlik. According to the description (Import cameras from Agisoft PhotoScan xml.) this imports an xml file. This is another option, which should be easy to implement. In this case please post the xml file exported from your sceaux castle reconstruction.

PLAN8VR commented 3 years ago

Hi, The link on my last post has the caollada file in it. (or at least that's what is in it when I download the file)

Sorry for confusion - these are the list of camera export file options.

I have attached the .nvm format for you. sceaux_cams.zip

Sceaux_cams_xml.zip

Hope these work.

PLAN8VR commented 3 years ago

I can confirm I am able to import the Metashape .nvm file into blender using your addon, which surprisingly imports the pointcloud (even though I just exported the cameras) but it doesn't appear to import the cameras

SBCV commented 3 years ago

I can import your nvm file without problems. Just use the nvm-importer of this addon. That means: in Blender select File/import/VisualSfM (.nvm), then set the path to sceaux_cams.nvm and in the corresponding import options set Image Directory to the directory of your input images. I've read that you can also export the undistorted images with metashape. This will remove radial distortions effects - read more about this here.

SBCV commented 3 years ago

I can confirm I am able to import the Metashape .nvm file into blender using your addon, which surprisingly imports the pointcloud (even though I just exported the cameras) but it doesn't appear to import the cameras

If you check the information in Blender's info panel you will find some messages like

Corresponding image not found at: /home/sebastian/Desktop/100_7100.JPG
Invalid default values provided for width (-1) and height (-1)
Adjust the image path or the default width/height values to import the NVM / LOG file.

This is caused by the fact that the nvm file does not contain information about the image size. Either you can set them by hand (in the import options) or add the path to the images (in the import options). If you have installed pillow for blender (see here), the addon will automatically read the image sizes from disk.

PLAN8VR commented 3 years ago

Hmm, I do get the error you mentioned, but even by adding the path to the undistorted files, I still get no cameras - I do have all extensions (pillow etc) installed.

Metashape does rename the undistorted camera images though - could this be the issue?

Even without the camera background images, should I not be able to see the camera positions and animated track?

PLAN8VR commented 3 years ago

Ah, yes, if I manually re-name the undistort images to the original camera names - all as expected - phew - thanks!

SBCV commented 3 years ago

The names of the images are important, since the original image name is stored in the nvm file (and used to find the corresponding file on disk)

PLAN8VR commented 3 years ago

Understood, I also found a way to edit the naming of the Metashape undistort images during export to be the same as the original, so in the end all good - I can export model and animated cameras from Metashape and import to Blender using your amazing plugin - Thanks!

SBCV commented 2 years ago

Just reinstalled the addon for 93.4 and it works without any issues.

Can you open a new issue and report more details there, such as:

Bests

SBCV commented 2 years ago

Hi Andrew, no problem. Best regards,Sebastian

Am Montag, 4. Oktober 2021, 10:30:05 MESZ hat Andrew Wood ***@***.***> Folgendes geschrieben:  

Hi Sebastian,

Sorry for wasting your time, I just realised that I have mixed up two different plugins and authors! Yours works fine – sorry about that!!

Thanks!

Best regards,

Andrew Wood.

Tel: 01736 366004

Mob: 07843 229941

www.solosails.com

From: Sebastian @.> Sent: 03 October 2021 21:40 To: SBCV/Blender-Addon-Photogrammetry-Importer @.> Cc: Andrew Wood @.>; State change @.> Subject: Re: [SBCV/Blender-Addon-Photogrammetry-Importer] Not an issue - but a request! (#30)

Just reinstalled the addon for 93.4 and it works without any issues.

Can you open a new issue and report more details there, such as:

Bests

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/SBCV/Blender-Addon-Photogrammetry-Importer/issues/30#issuecomment-933021746 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AB36R5KOTELLKFRJ2LXC5MLUFC5S3ANCNFSM4T6TLF2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.