david-cattermole / mayaMatchMoveSolver

A Bundle Adjustment solver for MatchMove related tasks.
https://david-cattermole.github.io/mayaMatchMoveSolver/
Other
101 stars 29 forks source link

Current Frame solve erroring in Maya 2019 #232

Closed ktonegawa closed 2 years ago

ktonegawa commented 2 years ago

Problem or Feature

Submitting as per recommendation from David. Feel free to disregard if its a non-issue.

When trying to solve a simple bundle with the "current frame" mode in any of the solvers in versions of the mmSolver plugin v0.3.12 and newer we get an error.

Expected behavior: regular solve on current frame

Actual behavior: errors with:

# Traceback (most recent call last):
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\tools\solver\ui\solver_window.py", line 696, in apply
#     self)
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\tools\solver\lib\collection.py", line 810, in run_solve_ui
#     info_fn=info_fn,
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\tools\solver\lib\collection.py", line 653, in execute_collection
#     info_fn=info_fn,
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\execute.py", line 727, in execute
#     status_fn=status_fn
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\compile.py", line 794, in collection_compile
#     withtest=withtest):
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\solverstandard.py", line 1371, in compile
#     for action, vaction in generator:
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\solverstandard.py", line 813, in _compile_single_frame
#     sol.set_remove_unused_markers(remove_unused_objects)
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\solverstep.py", line 294, in set_remove_unused_markers
#     assert isinstance(value, (bool, int))
# AssertionError

Steps to Reproduce

  1. [First Step]
  2. [Second Step]
  3. [and so on...]

Software Versions

Operating System: Microsoft Windows 7 Business Edition, 64-bit Windows 7 Service Pack 1 (Build 7601)

Cut ID: 201905131615-158f5352ad Maya Version: Autodesk Maya 2019.1 Maya API: 20190100 Qt Version: 5.6.1 Compositing Manager: True Window Manager: Windows Aero GPU: Version : 2016.11.44.12. Feature Level 5. Adapter : GeForce GTX 560 Ti/PCIe/SSE2 Vendor ID: 4318. Device ID : 4608 Driver : nvoglv64.dll:23.21.13.9135. API : OpenGL V.4.6. Max texture size : 16384 * 16384. Max tex coords : 32 Shader versions supported (Vertex: 5, Geometry: 5, Pixel 5). Shader compiler profile : (Best card profile) Active stereo support available : 0 GPU Memory Limit : 1024 MB. CPU Memory Limit: 31107 MB. -->

david-cattermole commented 2 years ago

It was also mentioned that this was using the develop_v0.3.x branch.

This shouldn't be happening... initially I'm not sure what could be wrong. I'll do some tests with the latest develop_v0.3.x branch.

ktonegawa commented 2 years ago

an additional note: I did create a quick scene from scratch (since the scene i was getting this error on was created with i believe v0.3.11) to create a collection from the latest v0.3.15 (compiled from source) to see what happens and what is interesting is that in this scene it does not error on a "Current frame" solve but rather it just does not solve in general, and gives this output:

// Warning: mmSolver._api.solverstep : No Attributes found! //
// mmSolver.tools.solver.lib.collection : Total Time: 0.118 seconds //
// mmSolver.tools.solver.lib.collection : Max Frame Deviation: -0.00 pixels at frame None //
// mmSolver.tools.solver.lib.collection : Average Deviation: 0.00 pixels //
// Warning: mmSolver.tools.solver.lib.collection : 2022-01-02 11:51:43 | Solved | Average Deviation 0.00px | Max Deviation -0.00px at None | Time 0.118sec //
david-cattermole commented 2 years ago

Hello @ktonegawa,

I have a feeling the issue you're having is related to #222. I added a feature to automatically detect and determine the relationships between the Markers and Attributes. Unfortunately there was a bug that caused the feature to never be turned off once it was enabled (using the "Object Relationships" check box) for a Collection.

I suspect that if you delete the Collection in your original scene (created in v0.3.11) and re-create a new one with v0.3.15 then it will produce Warning: mmSolver._api.solverstep : No Attributes found!.

The fact that no attributes can be found can be caused by a few reasons: 1) You're using the "Basic" solver tab with only static attributes - "Basic" tab will only solve keyed animated attributes. 2) If the user preference "Allow Object Relationships" is "Yes" and the Solver UI's "Evaluate Object Relationships" check box is enabled and your scene is using custom nodes or weird/unsupported connections or very complex node setups then the feature may not be able correctly find the object relationships and will filter all attributes and produce the warning you see.

I think the reason 1 is more likely.

I have attached a screenshot (taken in an experimental branch - so you won't have the "Scene Graph" option) showing the "Evaluate Object Relationships" and the preferences option too: image

ktonegawa commented 2 years ago

Hi @david-cattermole, i just tried out some more things and i have confirmed that even in the "Standard" solver tab the "Current Frame" mode does not work and once again gives this error:

# Traceback (most recent call last):
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\tools\solver\ui\solver_window.py", line 696, in apply
#     self)
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\tools\solver\lib\collection.py", line 810, in run_solve_ui
#     info_fn=info_fn,
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\tools\solver\lib\collection.py", line 653, in execute_collection
#     info_fn=info_fn,
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\execute.py", line 727, in execute
#     status_fn=status_fn
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\compile.py", line 794, in collection_compile
#     withtest=withtest):
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\solverstandard.py", line 1371, in compile
#     for action, vaction in generator:
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\solverstandard.py", line 813, in _compile_single_frame
#     sol.set_remove_unused_markers(remove_unused_objects)
#   File "C:\Users\Desktop02\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\solverstep.py", line 294, in set_remove_unused_markers
#     assert isinstance(value, (bool, int))
# AssertionError

I then tested the "Legacy" tab and tried to set the frame range to 1-1, which actually did seem to solve the bundle correctly.

So is the "Current Frame" option also in theory not supposed to work in "Standard" mode as well? If so perhaps these options should be removed from "Basic" and "Standard" tabs to avoid confusion...?

david-cattermole commented 2 years ago

I'll dig deeper into this issue.

So is the "Current Frame" option also in theory not supposed to work in "Standard" mode as well? If so perhaps these options should be removed from "Basic" and "Standard" tabs to avoid confusion...?

"Current Frame" should work in the Standard and Basic tabs - if it's broken it should be fixed.

david-cattermole commented 2 years ago

@ktonegawa I can confirm using your test scenes I can reproduce the same error in the latest v0.3.15, in both Basic and Standard tabs.

The steps for reproducing the problem are: 1) Create a new scene. 2) Create a camera. 3) Add a marker (with a bundle created too) 4) Open the Solver UI 5) Add the marker to the Input objects. 6) Add the bundle translate X and Y attributes to the Output Attributes.

The same error will occur with the "Basic" tab if the bundle's attributes are keyed. The reason the "No Attributes found!" warning was displayed in the Basic tab is because the attributes are Static and therefore ignored. Using the Standard solver stops the solver from filtering the static attributes and therefore producing the same error.

I will look into this problem and create a fix for the v0.3.15 release milestone.

The following error will be displayed:

# Traceback (most recent call last):
#   File "C:\Users\username\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\tools\solver\ui\solver_window.py", line 696, in apply
#     self)
#   File "C:\Users\username\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\tools\solver\lib\collection.py", line 810, in run_solve_ui
#     info_fn=info_fn,
#   File "C:\Users\username\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\tools\solver\lib\collection.py", line 653, in execute_collection
#     info_fn=info_fn,
#   File "C:\Users\username\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\execute.py", line 727, in execute
#     status_fn=status_fn
#   File "C:\Users\username\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\compile.py", line 794, in collection_compile
#     withtest=withtest):
#   File "C:\Users\username\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\solverstandard.py", line 1371, in compile
#     for action, vaction in generator:
#   File "C:\Users\username\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\solverstandard.py", line 813, in _compile_single_frame
#     sol.set_remove_unused_markers(remove_unused_objects)
#   File "C:\Users\username\Documents\maya\2019\modules\mayaMatchMoveSolver-0.3.15-maya2019-win64\python\mmSolver\_api\solverstep.py", line 294, in set_remove_unused_markers
#     assert isinstance(value, (bool, int))
# AssertionError

Thanks for reporting this @ktonegawa!

david-cattermole commented 2 years ago

I see the bug now. I have incorrectly passed the arguments to the function creating the "single frame solver" recipe. This created a silent error where the "precomputed data" (a dict) was passed to the remove_unused_objects argument which then asserted the wrong type.

The moral of the bug is that I should have added asserts to the mmSolver._api.solverstandard._compile_single_frame() function confirming the types of each argument.

Although this bug started in the Standard solver tab, I think the data on the Collection became corrupted somehow, which caused the Basic solver tab to also produce the same error.

I actually found this bug yesterday and fixed it in another branch; 2c7d6c9d3390329fa5eab9496e41b214121ad6c6 as part of #114 (to be part of the v0.4.0 release)

I have ported this fix over to the develop_v0.3.x in 5a39fa014f530fef5e8826e1eb8013cf6ef6c7e1, and also added more assert statements to try to stop this same problem from happening again.

@ktonegawa can you pull the latest commit and confirm this is now working for you?

This fix will be part of the v0.3.15 release.

ktonegawa commented 2 years ago

I just compiled the latest changes and here are the test results:

########## Basic Tab Current Frame mode ##########
// Warning: mmSolver._api.solverstep : No Attributes found! // 
// mmSolver.tools.solver.lib.collection : Total Time: 0.112 seconds // 
// mmSolver.tools.solver.lib.collection : Max Frame Deviation: -0.00 pixels at frame None // 
// mmSolver.tools.solver.lib.collection : Average Deviation: 0.00 pixels // 
// Warning: mmSolver.tools.solver.lib.collection : 2022-01-02 22:40:02 | Solved | Average Deviation 0.00px | Max Deviation -0.00px at None | Time 0.112sec // 

########## Standard Tab Current Frame mode ##########
# Warning: No plugs or nodes selected. Nothing to do. # 
// mmSolver.tools.solver.lib.collection : Total Time: 0.123 seconds // 
// mmSolver.tools.solver.lib.collection : Max Frame Deviation: 57.73 pixels at frame 120 // 
// mmSolver.tools.solver.lib.collection : Average Deviation: 57.73 pixels // 
// Warning: mmSolver.tools.solver.lib.collection : 2022-01-02 22:39:15 | Solved | Average Deviation 57.73px | Max Deviation 57.73px at 120 | Time 0.123sec // 

So it seems to snap fine in Standard but not Basic (which seems to be in line with what you described).

Is this the result you are expecting?

david-cattermole commented 2 years ago

Yes, this seems like it's working correctly! This is now fixed and working as I expect.

ktonegawa commented 2 years ago

Perfect thank you so much for looking into this David! I honestly figured it was just my Maya acting up again so good to know this was an actual issue.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: David Cattermole @.> Sent: Sunday, January 2, 2022 11:22:06 PM To: david-cattermole/mayaMatchMoveSolver @.> Cc: ktonegawa @.>; Mention @.> Subject: Re: [david-cattermole/mayaMatchMoveSolver] Current Frame solve erroring in Maya 2019 (Issue #232)

Closed #232https://github.com/david-cattermole/mayaMatchMoveSolver/issues/232.

— Reply to this email directly, view it on GitHubhttps://github.com/david-cattermole/mayaMatchMoveSolver/issues/232#event-5833905186, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AP6TJNUK2M7PGCNKWSYPQELUUFFB5ANCNFSM5LCI4NEQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://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 were mentioned.Message ID: @.***>