Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Rafes

Pages: [1]
1
Note the cameras no longer match the reference data when this happens. The whole chunk changes and if I reset the camera, the reference data is in the original place/space. It isn't clear to us how reference data is used during alignment, especially in this case. I would really love to have Metashape obey the reference data as a hard constraint (or at least have deterministic control). If I say a camera location is accurate to 1mm, it really should not be moved more than 1mm.

2

Quote
But does it bring any inconvenience on your side?

It feels non-deterministic If we remove a camera, or do more solves of the content over time, where cameras can shift or fail to align for some reason, then the resulting reconstruction shifts in "world space". It is possible I am misunderstanding a concept or misusing the resulting data. I will send you a DM

3
Hi,

(I'm not sure how many variables to explain here, so please let me know if there are any ideas that I can follow up on for more information.)

The basic setup:
  • I have a lot of cameras in a chunk. Some are already aligned by importing cameras .xml.
  • The cameras that are not aligned all have very accurate reference data for the location
  • I used the python API to matchPhotos

I reset the transform for this chunk and duplicated it twice before continuing, we'll call them "A" and "B"

In chunk A...
I run "Workflow > Align Photos..." 
The chunk transform changes!

In Chunk B...
I clear all reference data
I run "Workflow > Align Photos..." 
The chunk transform does not change!

I then reset chunk B and it essentially aligned back to what chunk A looks like (not exactly because they are 2 different solves, but obviously correct anyway.)


My question is why is the chunk transform changing only when reference data is being used?




4
I just realized we were not working with psx for debug projects until recently. That could be why it feels new.

5
Interesting! So doc.save() somehow disconnects the chunk in memory from the document and starts a new chunk copy? So then my code continues to work with the original chunk reference, but the doc doesn't know about it?

Note I never duplicate or create a new chunk myself. I just keep working and saving.
Also note, we just switched to Metashape 2.x and this code didn't exhibit this behavior in 1.x.

6
Thank you for the reply.

In the current code, each save is to a different file path, not the same file path. While I agree adding named chunks could be a nice way to debug multiple steps within the same file, in this case I can't change the codebase.

I tried setting both reference location and rotation attributes as well as the camera labels and the modified state did not go back to True.

7
(Note: I had perplexity generate this bug report as I was using it to debug and find the issue. I did not reproduce this in simple isolation as implied here. This is just to illustrate the point. I did see in my debugging session that the modified state did not become `True` again once the doc was saved, and I also confirmed the workaround to use the chunks argument. I am leaving all of this information here in case it is helpful)

Metashape Version: 2.1.1

Description:
When using the Metashape Python API, the document modification state is not being updated correctly after saving the document. This leads to subsequent changes not being saved in following save operations unless a specific workaround is used.

Steps to Reproduce:
1. Open a new or existing document in Metashape using the Python API.
2. Make initial changes to the document (e.g., add photos, align cameras).
3. Save the document using `doc.save(path)`.
4. Make additional changes.
5. Check the modification state using `doc.modified`. It is still False.
6. Save the document again using `doc.save(path)`.
7. Open the saved document to verify changes.

Expected Behavior:
After making changes in step 4, `doc.modified` should return `True`. The second save operation should include all changes made after the first save.

Actual Behavior:
After making changes in step 4, `doc.modified` remain `False`. The second save operation does not include changes made after the first save, particularly changes to camera reference data.

Workaround:
The issue can be resolved by explicitly specifying the chunks to save using the `chunks` parameter in the `save` method:

```python
doc.save(path, chunks=[doc.chunk])

This workaround ensures that all changes to the specified chunks are saved, even if the modification state is not correctly updated.

Additional Observations:
The exportReference function correctly exports the changed reference data to a CSV file, confirming that the changes are made in memory.
Even changing camera labels after the first save does not trigger the modified state or get saved in subsequent save operations without the workaround.
If the initial save operation (step 3) is omitted, all changes are saved correctly without needing the workaround.

Code Example:
Code: (python) [Select]
import Metashape

doc = Metashape.Document()
chunk = doc.addChunk()

# Initial setup and changes
# ... (add photos, align cameras, etc.)

doc.save("project.psx")  # First save

# Make changes to reference data
for camera in chunk.cameras:
    camera.reference.location = [1, 2, 3]
    camera.label = camera.label + "_NEW"

print("Modified state:", doc.modified)  # Prints False

# Workaround: Save with explicit chunks parameter
doc.save("project.psx", chunks=[chunk])  # Second save

# Open project.psx manually to verify - changes are now saved



8
Thank you for testing! The docs should be updated to avoid confusion when debugging on the user side.

Pages: [1]