Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obs object in calibrationUtils.py throws an incorrect class type #1612

Open
elvizer opened this issue Nov 30, 2024 · 7 comments
Open

obs object in calibrationUtils.py throws an incorrect class type #1612

elvizer opened this issue Nov 30, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@elvizer
Copy link

elvizer commented Nov 30, 2024

Describe the bug
When running calibrationUtils.py found in the latest version of the docs, I get this error:
AttributeError: 'Generic' object has no attribute 'snapshotData'. Did you mean: 'snapshotName'?

However, when printing the type of obs in obs.snapshotData.data, it prints:
<class '__main__.convert_photon_to_mrcal.<locals>.Generic'>

When hovering over obs in Visual Studios Code, it says that it is of type Observation

To Reproduce
Steps to reproduce the behavior:

  1. Download calibrationUtils.py from the latest version of PhotonVision docs, found here.
  2. Run python3 /path/to/calibrationUtils.py path/to/photon_calibration.json /path/to/output/folder (in my case WSL).
  3. See error

Screenshots / Videos
image
image

Platform:

  • Windows 10 (Version 19045.5131)
  • Ubuntu 24.04.1 LTS (WSL)
  • Visual Studios Code
@elvizer elvizer added the bug Something isn't working label Nov 30, 2024
@mcm001
Copy link
Contributor

mcm001 commented Dec 7, 2024

@Juniormunk did cal json format change over the summer? Either way I have a patched version floating around.

@Juniormunk
Copy link
Contributor

Yes. We no longer store the images in the json.

@PureRandomGit
Copy link

Hi, @mcm001 would it be possible for you to post the patch version, I cannot find it, Thanks!

@mcm001
Copy link
Contributor

mcm001 commented Dec 12, 2024

Maybe #1615

@PureRandomGit
Copy link

Sadly I still get the same error as above.

Traceback (most recent call last):
  File "/calibrationUtils.py", line 254, in <module>
    main()
  File "/calibrationUtils.py", line 250, in main
    convert_photon_to_mrcal(args.input, args.output_folder)
  File "/calibrationUtils.py", line 210, in convert_photon_to_mrcal
    image = obs.snapshotData.data
            ^^^^^^^^^^^^^^^^
AttributeError: 'Generic' object has no attribute 'snapshotData'. Did you mean: 'snapshotName'?

Platform:
KDE Neon6.2
Photonvision v2025.0.0-beta-6

@Juniormunk
Copy link
Contributor

@PureRandomGit Sorry. I meant to fix this a while ago. I don't have a good way to test this code, but here are the changes. #1633

@PureRandomGit
Copy link

Thank you, it fixes that problem but I encountered two others so far.
First is this one which I bypassed by changing the json width to remove the floats

Traceback (most recent call last):
  File "/calibrationUtils.py", line 237, in <module>
    main()
  File "/calibrationUtils.py", line 233, in main
    convert_photon_to_mrcal(args.input, args.output_folder)
  File "/calibrationUtils.py", line 210, in convert_photon_to_mrcal
    mrcal_model = __convert_cal_to_mrcal_cameramodel(camera_cal_data)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/calibrationUtils.py", line 129, in __convert_cal_to_mrcal_cameramodel
    ).reshape((cal.calobjectSize.width, cal.calobjectSize.height, 3))
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'float' object cannot be interpreted as an integer

At this point it was able to generate the corners.vnl but errors when trying to reshape the array due to some of the images not getting all the points, at least I think.

Traceback (most recent call last):
  File "/calibrationUtils.py", line 237, in <module>
    main()
  File "/calibrationUtils.py", line 233, in main
    convert_photon_to_mrcal(args.input, args.output_folder)
  File "/calibrationUtils.py", line 210, in convert_photon_to_mrcal
    mrcal_model = __convert_cal_to_mrcal_cameramodel(camera_cal_data)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/calibrationUtils.py", line 129, in __convert_cal_to_mrcal_cameramodel
    ).reshape((cal.calobjectSize.width, cal.calobjectSize.height, 3))
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: cannot reshape array of size 135 into shape (7,7,3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants